Skip to content
Snippets Groups Projects
Commit 300931a1 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

list of active visits without appointments is sorted by start date

parent 5c0d17e6
No related branches found
No related tags found
1 merge request!24Sort by date of visit lists
Pipeline #
...@@ -18,7 +18,8 @@ from web.views.notifications import \ ...@@ -18,7 +18,8 @@ from web.views.notifications import \
get_visits_without_appointments_count, \ get_visits_without_appointments_count, \
get_today_midnight_date, \ get_today_midnight_date, \
get_unfinished_appointments, \ get_unfinished_appointments, \
get_unfinished_appointments_count get_unfinished_appointments_count, \
get_unfinished_visits
class NotificationViewTests(TestCase): class NotificationViewTests(TestCase):
...@@ -84,6 +85,28 @@ class NotificationViewTests(TestCase): ...@@ -84,6 +85,28 @@ class NotificationViewTests(TestCase):
notification = get_visits_without_appointments_count(self.user) notification = get_visits_without_appointments_count(self.user)
self.assertEquals(original_notification.count + 1, notification.count) self.assertEquals(original_notification.count + 1, notification.count)
def test_get_unfinished_visits_order(self):
subject = create_subject()
visit = create_visit(subject)
visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=-10)
visit.save()
visit = create_visit(subject)
visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=-8)
visit.save()
visit = create_visit(subject)
visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=-12)
visit.save()
visits = get_unfinished_visits(self.user)
self.assertEquals(3, len(visits))
# check sort order
self.assertTrue(visits[0].datetime_begin < visits[1].datetime_begin)
self.assertTrue(visits[1].datetime_begin < visits[2].datetime_begin)
def test_get_approaching_visits_without_appointments_count(self): def test_get_approaching_visits_without_appointments_count(self):
original_notification = get_approaching_visits_without_appointments_count(self.user) original_notification = get_approaching_visits_without_appointments_count(self.user)
subject = create_subject() subject = create_subject()
......
...@@ -218,7 +218,7 @@ def get_active_visits_without_appointments(user): ...@@ -218,7 +218,7 @@ def get_active_visits_without_appointments(user):
datetime_end__gt=today, datetime_end__gt=today,
is_finished=False, is_finished=False,
subject__default_location__in=get_filter_locations(user), subject__default_location__in=get_filter_locations(user),
my_count=0) my_count=0).order_by('datetime_begin')
def get_filter_locations(user): def get_filter_locations(user):
......
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