-// var cards;
-var idToUse;
+var bayIdToUse;
+var horseIdToUse;
-function generateCards() {
- // console.log(this.response);
- // cards += this.response;
- document.getElementById(idToUse).innerHTML = this.response;
- // console.log(cards);
+function generateBayCards() {
+ document.getElementById(bayIdToUse).innerHTML = this.response;
}
-function getBayCards(id, stablepartId) {
- // console.log(bayIds);
- // cards = '';
- idToUse = id;
+function getBayCards(docIdForData, stablepartId) {
+ bayIdToUse = docIdForData;
const xhr = new XMLHttpRequest();
- // console.log('loading bay', bay);
xhr.open('GET', '/stablepart/'.concat(stablepartId));
- xhr.addEventListener('load', generateCards);
+ xhr.addEventListener('load', generateBayCards);
xhr.send();
}
+
+function getHorseDetails(docIdForData, horseId) {
+ horseIdToUse = docIdForData;
+ const xhr = new XMLHttpRequest();
+ xhr.open('GET', '/horse/'.concat(horseId));
+ xhr.addEventListener('load', generateHorseDetail);
+ xhr.send();
+}
+
+function generateHorseDetail() {
+ document.getElementById(horseIdToUse).innerHTML = this.response;
+}
--- /dev/null
+<div class="card">
+<h3>{{ object.name }}</h3>
+<div class="flexrow">
+{% for fodder in object.hasfodderplan_set.all %}
+ <div class="card">
+ <h4>{{ fodder.valid_since }} - {{ fodder.valid_until }}</h4>
+ <div>{{ fodder.fodderplan.fodder }}</div>
+ </div>
+{% endfor %}
+</div>
+</div>
<h3>{{ bay }} </h3>
<div>
{% for inbay in bay.isinbay_set.all %}
- <div class="card"><h4><button class="text">{{ inbay.horse }}</button></h4>
+ <div class="card"><h4><button class="text" onclick="getHorseDetails('footer', {{inbay.horse.pk}})">{{ inbay.horse }}</button></h4>
<div>{{ inbay.valid_since }} bis {{ inbay.valid_until }}</div>
</div>
{% endfor %}
app_name = 'core'
urlpatterns = [
path('stableparts', views.StableParts.as_view(), name='StableParts'),
- path('stablepart/<int:pk>', views.StablePartDetail.as_view(), name='StablePartDetail'),
+ path('stablepart/<int:pk>', views.StablePartDetail.as_view(),
+ name='StablePartDetail'),
path('bay/<int:pk>', views.BayDetail.as_view(), name='BayDetail'),
+ path('horse/<int:pk>', views.HorseDetail.as_view(), name='HorseDetail'),
]
from django.shortcuts import render
from django.views.generic import ListView, DetailView
-from core.models import StablePart, Bay
+from core.models import StablePart, Bay, Horse
# Create your views here.
class BayDetail(DetailView):
model = Bay
+
+
+class HorseDetail(DetailView):
+ model = Horse
div#nav {
grid-area: nav;
+ border-right: 2px solid rebeccapurple;
/* border: 1px solid red; */
}
div#footer {
grid-area: footer;
- border-top: 2px solid darkgrey;
+ border-top: 2px solid rebeccapurple;
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+}
+
+div.flexrow {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+}
+
+div.flexrow > div.card {
+ width: 15em;
+ overflow-y: auto;
}
div.card {
</head>
<body>
<div id="header">{% block header %}<div id="headertitle">Stable Management</div>{% endblock %}</div>
- <div id="nav">{% block nav %}nav{% endblock %}</div>
+ <div id="nav">{% block nav %}{% endblock %}</div>
<div id="main">{% block main %}{% endblock %}</div>
- <div id="footer">{%block footer %}footer{% endblock %}</div>
+ <div id="footer">{% block footer %}{% endblock %}</div>
</body>
</html>