Skip to content
Snippets Groups Projects
Commit 8347cf91 authored by Piotr Matyjaszyk's avatar Piotr Matyjaszyk
Browse files

Fixed the robust visit view

parent a00d2afc
No related branches found
No related tags found
No related merge requests found
...@@ -49,5 +49,5 @@ class AppointmentDetailForm(ModelForm): ...@@ -49,5 +49,5 @@ class AppointmentDetailForm(ModelForm):
class VisitDetailForm(ModelForm): class VisitDetailForm(ModelForm):
class Meta: class Meta:
model = Subject model = Visit
fields = '__all__' exclude = ['visitFinished']
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
<a href="{% url 'web.views.visits' %}" class="btn btn-block btn-default" onclick="history.back()">Back</a> <a href="{% url 'web.views.visits' %}" class="btn btn-block btn-default" onclick="history.back()">Back</a>
</div> </div>
{% comment %} <div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Details of visit</h3> <h3 class="box-title">Details of visit</h3>
</div>{% endcomment %} </div>
<form class="form-horizontal"> <form class="form-horizontal">
<div class="box-body"> <div class="box-body">
...@@ -49,15 +49,17 @@ ...@@ -49,15 +49,17 @@
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% 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><!-- /.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> </form>
</div>
</form>
...@@ -69,9 +71,11 @@ ...@@ -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> <h3 class="box-title">Visit's assignments</h3>
</div>{% endcomment %} </div>
{% if loApp %} {% if loApp %}
<table id="table" class="table table-bordered table-striped"> <table id="table" class="table table-bordered table-striped">
...@@ -81,14 +85,16 @@ ...@@ -81,14 +85,16 @@
<th>Type</th> <th>Type</th>
<th>Date</th> <th>Date</th>
<th>Time</th> <th>Time</th>
<th>Length</th> <th>Length [min]</th>
<th>Responsible</th> <th>Responsible</th>
<th>Plan/Modify</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for app in loApp %} {% for app in loApp %}
<tr> <tr>
<td>{{ forloop.counter }}</td> <td>{{ forloop.counter }}</td>
<td>{{ app.appointmentType }}</td>
<td>{{ app.appDateTime | date:"d-M-Y" }}</td> <td>{{ app.appDateTime | date:"d-M-Y" }}</td>
<td>{{ app.appDateTime | time:"H:i" }}</td> <td>{{ app.appDateTime | time:"H:i" }}</td>
<td>{{ app.appLength }}</td> <td>{{ app.appLength }}</td>
...@@ -97,6 +103,7 @@ ...@@ -97,6 +103,7 @@
{% else %} {{ app.flyingTeam }} {% else %} {{ app.flyingTeam }}
{% endif %} {% endif %}
</td> </td>
<td> <a href="" type="button" class="btn btn-block btn-default">TODO</a> </td>
</tr> </tr>
{% endfor %} {% endfor %}
...@@ -116,13 +123,13 @@ ...@@ -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> <h3 class="box-title">Subject's details</h3>
</div>{% endcomment %} </div>
<form class="form-horizontal"> <form class="form-horizontal">
<div class="box-body"> <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 %}"> <div class="col-md-6 form-group {% if field.errors %}has-error{% endif %}">
<label for="{# TODO #}" class="col-sm-4 control-label"> <label for="{# TODO #}" class="col-sm-4 control-label">
{{ field.label }} {{ field.label }}
...@@ -152,7 +159,7 @@ ...@@ -152,7 +159,7 @@
</div>
{% endblock maincontent %} {% endblock maincontent %}
...@@ -161,16 +168,5 @@ ...@@ -161,16 +168,5 @@
<script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script> <script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.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 %} {% endblock scripts %}
...@@ -64,12 +64,13 @@ def visits(request): ...@@ -64,12 +64,13 @@ def visits(request):
def visit_details(request, id): def visit_details(request, id):
displayedVisit = Visit.objects.get(id=id) displayedVisit = Visit.objects.get(id=id)
visFinished = displayedVisit.visitFinished
displayedSubject = displayedVisit.subject displayedSubject = displayedVisit.subject
listOfAppointments = displayedVisit.appointment_set listOfAppointments = displayedVisit.appointment_set.all()
vform = VisitDetailForm(instance=displayedVisit) vform = VisitDetailForm(instance=displayedVisit)
sform = SubjectDetailForm(instance=displayedSubject) 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): def subjects(request):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment