From 0e3d3e711df8c19299554cb7400522679df1a19e Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 6 Mar 2017 13:11:49 +0100 Subject: [PATCH] notifications for the subjects without visit added --- smash/web/tests/test_view_notifications.py | 32 ++++++++++++++++------ smash/web/urls.py | 1 + smash/web/views.py | 21 +++++++++----- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/smash/web/tests/test_view_notifications.py b/smash/web/tests/test_view_notifications.py index f3137142..b28faa74 100644 --- a/smash/web/tests/test_view_notifications.py +++ b/smash/web/tests/test_view_notifications.py @@ -51,14 +51,6 @@ class NotificationViewTests(TestCase): notification = get_visits_without_appointments_count() self.assertEquals(original_notification.count + 1, notification.count) - def test_get_visits_without_appointments_count_2(self): - original_notification = get_visits_without_appointments_count() - subject = create_subject() - visit = create_visit(subject) - appointment = create_appointment(visit) - - notification = get_visits_without_appointments_count() - self.assertEquals(original_notification.count, notification.count) def test_get_visits_without_appointments_count_3(self): original_notification = get_visits_without_appointments_count() @@ -149,3 +141,27 @@ class NotificationViewTests(TestCase): notification = get_subject_with_no_visit_notifications_count() self.assertEquals(original_notification.count, notification.count) + + def test_get_unfinished_appointments_count(self): + original_notification = get_unfinished_appointments_count() + subject = create_subject() + visit = create_visit(subject) + appointment = create_appointment(visit) + appointment.datetime_when = "2011-01-01" + appointment.status = Appointment.APPOINTMENT_STATUS_SCHEDULED + appointment.save() + + notification = get_unfinished_appointments_count() + self.assertEquals(original_notification.count + 1, notification.count) + + def test_get_unfinished_appointments_count_2(self): + original_notification = get_unfinished_appointments_count() + subject = create_subject() + visit = create_visit(subject) + appointment = create_appointment(visit) + appointment.datetime_when = "2011-01-01" + appointment.status = Appointment.APPOINTMENT_STATUS_CANCELLED + appointment.save() + + notification = get_unfinished_appointments_count() + self.assertEquals(original_notification.count, notification.count) diff --git a/smash/web/urls.py b/smash/web/urls.py index dd2a30e7..f37a8120 100644 --- a/smash/web/urls.py +++ b/smash/web/urls.py @@ -35,6 +35,7 @@ urlpatterns = [ url(r'visit/mark/(?P<id>\d+)/(?P<as_what>[A-z]+)$', views.visit_mark, name='web.views.visit_mark'), url(r'subjects$', views.subjects, name='web.views.subjects'), + url(r'subjects/no_visit$', views.subject_no_visits, name='web.views.subject_no_visits'), url(r'subjects/add$', views.subject_add, name='web.views.subject_add'), url(r'subjects/details/(?P<id>\d+)$', views.subject_details, name='web.views.subject_details'), url(r'subjects/subject_visit_details/(?P<id>\d+)$', views.subject_visit_details, name='web.views.subject_visit_details'), diff --git a/smash/web/views.py b/smash/web/views.py index 2069b461..14708239 100644 --- a/smash/web/views.py +++ b/smash/web/views.py @@ -30,17 +30,17 @@ def index(request): return redirect(login) -def e404_page_not_found(request): - return render(request, "errors/404.html", context) +def e404_page_not_found(request, context = None): + return render(request, "errors/404.html", context, status=404) def e500_error(request, context = None): return render(request, "errors/500.html", context, status=500) -def e403_permission_denied(request): - return render(request, "errors/403.html", context) +def e403_permission_denied(request, context = None): + return render(request, "errors/403.html", context, status=403) -def e400_bad_request(request): - return render(request, "errors/400.html", context) +def e400_bad_request(request, context = None): + return render(request, "errors/400.html", context, status=400) def login(request): @@ -125,7 +125,7 @@ def get_approaching_visits_without_appointments(): def get_unfinished_appointments_count(): return NotificationCount( title = "unfinished appointments ", - count = get_unfinished_appointments(), + count = get_unfinished_appointments().count(), style = "fa fa-history text-yellow", type = 'web.views.unfinished_appointments') @@ -264,6 +264,13 @@ def subject_add(request): return wrap_response(request, 'subjects/add.html', {'form': form}) +def subject_no_visits(request): + subjects_list = get_subjects_with_no_visit().order_by('-last_name') + context = { + 'subjects_list': subjects_list + } + + return wrap_response(request, 'subjects/index.html', context) def subject_details(request, id): the_subject = get_object_or_404(Subject, id=id) -- GitLab