diff --git a/smash/web/forms.py b/smash/web/forms.py index 24053d959fef243c399b062606cb5539bc167af6..da8682ad36472273abe91ceb797a8267053c59f5 100644 --- a/smash/web/forms.py +++ b/smash/web/forms.py @@ -49,5 +49,5 @@ class AppointmentDetailForm(ModelForm): class VisitDetailForm(ModelForm): class Meta: - model = Subject - fields = '__all__' + model = Visit + exclude = ['visitFinished'] diff --git a/smash/web/templates/visits/details.html b/smash/web/templates/visits/details.html index 936f8889ae5987b143c69d978bb323827b108bf1..0a609e97ed9c0e856aeaddcad8bc5017a5353bff 100644 --- a/smash/web/templates/visits/details.html +++ b/smash/web/templates/visits/details.html @@ -26,9 +26,9 @@ <a href="{% url 'web.views.visits' %}" class="btn btn-block btn-default" onclick="history.back()">Back</a> </div> - {% comment %} <div class="box-header with-border"> + <div class="box-header with-border"> <h3 class="box-title">Details of visit</h3> - </div>{% endcomment %} + </div> <form class="form-horizontal"> <div class="box-body"> @@ -49,15 +49,17 @@ {% endif %} </div> {% endfor %} + + <td> + Visit finished: {% if visFinished %}<button type="button" class="btn btn-block btn-danger">YES</button> + {% else %}<button type="button" class="btn btn-block btn-success">NO</button> + {% endif %} + </td> </div><!-- /.box-body --> - <div class="box-footer"> - <a href="{% url 'web.views.subjects' %}" class="btn btn-block btn-default" onclick="history.back()">Back</a> - </div><!-- /.box-footer --> + </form> -</div> -</form> @@ -69,9 +71,11 @@ -{% comment %} <div class="box-header with-border"> + + +<div class="box-header with-border"> <h3 class="box-title">Visit's assignments</h3> -</div>{% endcomment %} +</div> {% if loApp %} <table id="table" class="table table-bordered table-striped"> @@ -81,14 +85,16 @@ <th>Type</th> <th>Date</th> <th>Time</th> - <th>Length</th> + <th>Length [min]</th> <th>Responsible</th> + <th>Plan/Modify</th> </tr> </thead> <tbody> {% for app in loApp %} <tr> <td>{{ forloop.counter }}</td> + <td>{{ app.appointmentType }}</td> <td>{{ app.appDateTime | date:"d-M-Y" }}</td> <td>{{ app.appDateTime | time:"H:i" }}</td> <td>{{ app.appLength }}</td> @@ -97,6 +103,7 @@ {% else %} {{ app.flyingTeam }} {% endif %} </td> + <td> <a href="" type="button" class="btn btn-block btn-default">TODO</a> </td> </tr> {% endfor %} @@ -116,13 +123,13 @@ -{% comment %} <div class="box-header with-border"> +<div class="box-header with-border"> <h3 class="box-title">Subject's details</h3> -</div>{% endcomment %} +</div> <form class="form-horizontal"> <div class="box-body"> - {% for field in vform %} + {% for field in sform %} <div class="col-md-6 form-group {% if field.errors %}has-error{% endif %}"> <label for="{# TODO #}" class="col-sm-4 control-label"> {{ field.label }} @@ -152,7 +159,7 @@ - +</div> {% endblock maincontent %} @@ -161,16 +168,5 @@ <script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script> <script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script> - <script> - $(function () { - $('#table').DataTable({ - "paging": true, - "lengthChange": false, - "searching": true, - "ordering": true, - "info": true, - "autoWidth": false - }); - }); - </script> + {% endblock scripts %} diff --git a/smash/web/views.py b/smash/web/views.py index b74e4f2079d84691b2ebdefad99b701194143781..b20d8c294f4124455a5d6b748589db7af30932fb 100644 --- a/smash/web/views.py +++ b/smash/web/views.py @@ -64,12 +64,13 @@ def visits(request): def visit_details(request, id): displayedVisit = Visit.objects.get(id=id) + visFinished = displayedVisit.visitFinished displayedSubject = displayedVisit.subject - listOfAppointments = displayedVisit.appointment_set + listOfAppointments = displayedVisit.appointment_set.all() vform = VisitDetailForm(instance=displayedVisit) sform = SubjectDetailForm(instance=displayedSubject) - return wrap_response(request, 'visits/details.html', {'vform': vform, 'sform': sform, 'loApp': listOfAppointments}) + return wrap_response(request, 'visits/details.html', {'vform': vform, 'sform': sform, 'loApp': listOfAppointments, 'visFinished': visFinished}) def subjects(request):