diff --git a/smash/web/models.py b/smash/web/models.py index 096f3993c327bae3d8d2ad640a0a3e2c847547eb..5fef3370ed96a0ec46c4b71757dedda3389a031f 100644 --- a/smash/web/models.py +++ b/smash/web/models.py @@ -93,6 +93,9 @@ class Subject(models.Model): def __str__(self): return "%s %s" % (self.firstName, self.lastName) + def __unicode__(self): + return "%s %s" % (self.firstName, self.lastName) + class Visit(models.Model): subject = models.ForeignKey(Subject, on_delete=models.CASCADE, @@ -163,7 +166,8 @@ class AppType (models.Model): verbose_name='Required equipment' ) followUp = models.ForeignKey('self', - verbose_name='Follow-up visit' + verbose_name='Follow-up visit', + null=True, blank=True ) apCode = models.CharField(max_length=20, verbose_name='Appointment code' @@ -296,7 +300,8 @@ class Holiday(models.Model): class Appointment(models.Model): flyingTeam = models.ForeignKey(FlyingTeam, - verbose_name='Flying team (if applicable)' + verbose_name='Flying team (if applicable)', + null=True, blank=True ) appType = models.ForeignKey(AppType, verbose_name='Appointment type' diff --git a/smash/web/templates/assignments/index.html b/smash/web/templates/assignments/index.html index d6355e5c638394c193e986730171d726eba23232..b069a56a6810a7e68f77ebba718c58767ddedaef 100644 --- a/smash/web/templates/assignments/index.html +++ b/smash/web/templates/assignments/index.html @@ -5,7 +5,7 @@ {{ block.super }} <!-- DataTables --> <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}"> - + <!-- fullCalendar 2.2.5--> <link rel="stylesheet" href="{% static 'AdminLTE/plugins/fullcalendar/fullcalendar.min.css' %}"> <link rel="stylesheet" href="{% static 'AdminLTE/plugins/fullcalendar/fullcalendar.print.css' %}" media="print"> @@ -25,8 +25,12 @@ <div class="row"> <div class="col-md-5"> <h3>Planning</h3> - <table id="planning_table" class="table table-bordered table-striped"> - <thead> + + + + {% if planning_list %} + <table id="planning_table" class="table table-bordered table-striped"> + <thead> <tr> <th>Subject name</th> <th>Full information</th> @@ -34,65 +38,57 @@ <th>Details</th> </tr> </thead> - <tbody> - <tr> - <td>Aaron Aee</td> - <td><button type="button" class="btn btn-block btn-default btn-xs">See full information</button></td> - <td>26-11-2016</td> - <td><button type="button" class="btn btn-block btn-default">Details</button></td> - </tr> - <tr> - <td>Benny Bee</td> - <td><button type="button" class="btn btn-block btn-default btn-xs">See full information</button></td> - <td>27-11-2016</td> - <td><button type="button" class="btn btn-block btn-default">Details</button></td> - </tr> - <tr> - <td>Charlie Cee</td> - <td><button type="button" class="btn btn-block btn-default btn-xs">See full information</button></td> - <td>28-11-2016</td> - <td><button type="button" class="btn btn-block btn-default">Details</button></td> - </tr> - </tbody> - </table> - + <tbody> + + {% for planned in planning_list %} + <tr> + <td>{{planned.visit.subject.firstName}} {{planned.visit.subject.lastName}}</td> + <td><button type="button" class="btn btn-block btn-default btn-xs">See full information</button></td> + <td>{{planned.visitBegin}}</td> + <td><button type="button" class="btn btn-block btn-default">Details</button></td> + </tr> + {% endfor %} + + </tbody> + </table> + {% else %} + <p>No visits to plan in close future.</p> + {% endif %} + + <h3>Approaching</h3> + + {% if approaching_list %} <table id="approaching_table" class="table table-bordered table-striped"> <thead> <tr> <th>Subject name</th> <th>Full information</th> - <th>Suggested date</th> - <th>Suggested time</th> + <th>Date</th> + <th>Time</th> <th>Details</th> </tr> </thead> <tbody> - <tr> - <td>John Dee</td> - <td><button type="button" class="btn btn-block btn-default btn-xs">See full information</button></td> - <td>21-11-2016</td> - <td>10:00 am</td> - <td><button type="button" class="btn btn-block btn-default">Details</button></td> - </tr> - <tr> - <td>Mike Fee</td> - <td><button type="button" class="btn btn-block btn-default btn-xs">See full information</button></td> - <td>21-11-2016</td> - <td>14:00 am</td> - <td><button type="button" class="btn btn-block btn-default">Details</button></td> - </tr> - <tr> - <td>Penny Tee</td> - <td><button type="button" class="btn btn-block btn-default btn-xs">See full information</button></td> - <td>22-11-2016</td> - <td>9:00 am</td> - <td><button type="button" class="btn btn-block btn-default">Details</button></td> - </tr> + + {% for approach in approaching_list %} + <tr> + <td>{{approach.visit.subject.firstName}} {{approach.visit.subject.lastName}}</td> + <td><button type="button" class="btn btn-block btn-default btn-xs">See full information</button></td> + <td>{{approach.appDateTime|date:"d-M-Y" }}</td> + <td>{{approach.appDateTime|time:"H:i"}}</td> + <td><button type="button" class="btn btn-block btn-default">Details</button></td> + </tr> + {% endfor %} + </tbody> </table> + + {% else %} + <p>No visits approaching in close future.</p> + {% endif %} </div> - + <div class="col-md-7"> <div class="box box-primary"> <div class="box-body no-padding"> @@ -105,12 +101,12 @@ {% block scripts %} {{ block.super }} - + <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/moment.js/moment.min.js' %}"></script> <script src="{% static 'AdminLTE/plugins/fullcalendar/fullcalendar.min.js' %}"></script> - + <script> $(function () { $('#planning_table, #approaching_table').DataTable({ @@ -121,7 +117,7 @@ "info": true, "autoWidth": false }); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', diff --git a/smash/web/views.py b/smash/web/views.py index 453c49a23b1d2b9fa38288d684e3e0b6bb748b60..289832c49c3cd0f9d04b7a8f44ed63f0cfed54e8 100644 --- a/smash/web/views.py +++ b/smash/web/views.py @@ -186,4 +186,14 @@ def equipment_and_rooms(request): def mail_templates(request): return wrap_response(request, "mail_templates/index.html", {}) - + +def assignments(request): + planning_list = Appointment.objects.none() + approaching_list = Appointment.objects.filter(appDateTime__gt = datetime.datetime.now()) + + context = { + 'planning_list': planning_list, + 'approaching_list': approaching_list + } + + return wrap_response(request, "assignments/index.html",context)