From 13e3552f0e6051ffd7c64f4cf9d325fde4462da3 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Thu, 9 Mar 2017 11:51:13 +0100 Subject: [PATCH] when editing appoijntment info about subject is visible (and link to edit subject is available) --- smash/web/templates/appointments/edit.html | 34 +++++++++++++++++++++- smash/web/views.py | 10 ++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/smash/web/templates/appointments/edit.html b/smash/web/templates/appointments/edit.html index 76515ca2..50d598d8 100644 --- a/smash/web/templates/appointments/edit.html +++ b/smash/web/templates/appointments/edit.html @@ -58,7 +58,7 @@ Status: </label> <div class="btn-group-vertical col-sm-8"> - <label class="btn btn-primary">{{ status }}</label> + <label class="btn btn-primary">{{ appointment.status }}</label> <a href="{% url 'web.views.appointment_mark' id 'finished' %}" class="btn btn-warning btn-block">Mark as finished</a> <a href="{% url 'web.views.appointment_mark' id 'cancelled' %}" class="btn btn-warning btn-block">Mark as cancelled</a> <a href="{% url 'web.views.appointment_mark' id 'no_show' %}" class="btn btn-warning btn-block">Mark as no show</a> @@ -74,6 +74,38 @@ <a href="{% url 'web.views.appointments' %}" class="btn btn-block btn-default" onclick="history.back()">Cancel</a> </div> </div><!-- /.box-footer --> + + <div class="box-header with-border"> + <h3 class="box-title">Subject's details</h3> + </div> + + <form class="form-horizontal"> + <div class="box-body"> + {% for field in subject_form %} + <div class="col-md-6 form-group {% if field.errors %}has-error{% endif %}"> + <label for="{# TODO #}" class="col-sm-4 control-label"> + {{ field.label }} + </label> + + <div class="col-sm-8"> + {{ field|disable|add_class:'form-control' }} + </div> + + {% if field.errors %} + <span class="help-block"> + {{ field.errors }} + </span> + {% endif %} + </div> + {% endfor %} + </div><!-- /.box-body --> + + <div class="box-footer"> + <a href="{% url 'web.views.subject_edit' appointment.visit.subject.id %}" type="button" class="btn btn-block btn-default">Edit subject</a> + <a href="{% url 'web.views.subjects' %}" class="btn btn-block btn-default" onclick="history.back()">Back</a> + </div><!-- /.box-footer --> + </form> + </form> </div> {% endblock %} diff --git a/smash/web/views.py b/smash/web/views.py index c1b7b59a..0af808bf 100644 --- a/smash/web/views.py +++ b/smash/web/views.py @@ -554,7 +554,15 @@ def appointment_edit(request, id): return redirect(appointments) else: form = AppointmentEditForm(instance=the_appointment) - return wrap_response(request, 'appointments/edit.html', {'form': form, 'id':id, 'status': the_appointment.status}) + + subject_form = SubjectDetailForm(instance=the_appointment.visit.subject) + + return wrap_response(request, 'appointments/edit.html', { + 'form': form, + 'subject_form': subject_form, + 'id':id, + 'appointment': the_appointment + }) def appointment_edit_datetime(request, id): -- GitLab