diff --git a/CHANGELOG b/CHANGELOG index 7dbc7774ff74e5e8b611bf4f16da31b7ecd09d58..5862e538e395e35d7934b71bcbca21aa7f6b0af0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,12 +1,22 @@ smasch (1.1.0~alpha.0-1) unstable; urgency=low - * improvement: remove sorting from columns that do not require sorting in - mail template menu and languages menu - * improvement: added explanatory tooltip for the column `order` in language menu + * improvement: remove sorting from columns that do not require sorting in + mail template menu and languages menu (#436) + * improvement: added explanatory tooltip for the column `order` in language + menu (#436) + * improvement: warn the user on invalid date range when creating a + holidays/extra availability (#427) * improvement: user can modify/add Subject types with custom follow up schema (#371) + * improvement: added week day to daily planning main date (#425) * improvement: possibility to import custom fields data from csv file (#385) + * improvement: added warning in case of printing voucher with no voucher + templates (#451) * bug fix: privacy notice files were not removed when policy was removed + * bug fix: holidays were wrongly encoded and displayed when they span + multiple days (#430, #429) + * bug fix: Search form should always redirect to web.views.kit_requests + (#433) -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 25 Feb 2021 17:00:00 +0200 @@ -82,7 +92,7 @@ smasch (0.14.0) stable; urgency=low (#312) * small improvement: there is possibility to select RedCap checks (#300) * small improvement: permissions list extended. New permissions: view daily - planning; modify sample kits (equipement items); modify flying teams; + planning; modify sample kits (equipment items); modify flying teams; modify rooms; view kit requests; view statistics; modify mail templates; can export (#322) * small improvement: next of keen data added to subject (#318) @@ -107,7 +117,7 @@ smasch (0.13.1) stable; urgency=low smasch (0.13.0) stable; urgency=low - * small improvement: Enpoint reached column added + * small improvement: Endpoint reached column added * small improvement: Option "removed" to vouchers * small improvement: Option to show all voucher types when issuing a voucher to a subject @@ -341,7 +351,7 @@ smasch (0.6.0) stable; urgency=low * improvement: add command to import public holidays (#100) * small improvement: field "pd in family" has now three states ("unknown", "false" or "true"). All entries which has this value set to "false" are now - set to "unknown". An import from excel should in the futur fix this to + set to "unknown". An import from excel should in the future fix this to restore the real "false" values (#107) * small improvement: a link to navigate to the corresponding visit from an appointment has been added (#111) @@ -378,16 +388,16 @@ smasch (0.5.0) stable; urgency=low * improvement: contact attempts * improvement: automatic post mail creation * improvement: configuration panel for system configuration options (like - colors, mail adresses, etc) + colors, mail addresses, etc) * small improvement: after subject is added system stays on the edit subject page - * small improvement: cancelled appointments are 'GREY' in callendar view - * small improvement: no show appointments are "RED' in callendar view + * small improvement: cancelled appointments are 'GREY' in calendar view + * small improvement: no show appointments are "RED' in calendar view * small improvement: kit requests (equipment&rooms->kit request) contain information about location and person who is responsible for the appointment * small improvement: subject contain two additional boolean fields: PD in - family, information sent. Infomration sent is also visible in subject list + family, information sent. Information sent is also visible in subject list webpage * small improvement: appointment contains additional boolean field: post mail sent @@ -426,7 +436,7 @@ smasch (0.4.0) stable; urgency=low * bug fix: when marking subject as deceased/resigned information was not saved properly * bug fix: when marking visit as finished information was not saved properly - * bug fix: list of visits/appoitntments from reminder is sorted by date + * bug fix: list of visits/appointments from reminder is sorted by date * bug fix: visit id field removed from editing appointment * bug fix: visit list doesn't allow to change properties of the visit * bug fix: login problem for users with non ascii characters in their names @@ -444,16 +454,16 @@ smasch (0.3.1) stable; urgency=low smasch (0.3.0) stable; urgency=low * improvement: there is view for upcoming examinations requiring kits - (disponsible items) - * improvement: notification with remonder to send post email for upcoming + (disposable items) + * improvement: notification with reminder to send post email for upcoming visit (3-6 months before visit) * improvement: selecting appointment type in appointment view automatically recalculate time required for appointment - * improvement: each subjest has optional field with requested contact date, + * improvement: each subject has optional field with requested contact date, this date is used to create a notification about contact request * improvement: subject has possibility to be 'postponed' - this will exclude subject from list of subjects without visit - * bug fix: refirection after login fixed + * bug fix: redirection after login fixed -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 17 Mar 2017 08:43:10 +0100 @@ -470,7 +480,7 @@ smasch (0.2.1) stable; urgency=low * improvement: click oin calendar redirects to edit appointment view * improvement: after new visit is added there is button to add new appointment - * bug fix: export to csv was broken when new line appeard in comment + * bug fix: export to csv was broken when new line appeared in comment -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 09 Mar 2017 18:40:22 +0100 @@ -478,7 +488,7 @@ smasch (0.2.0) stable; urgency=low * improvement: export of subjects and appointments to csv added * improvement: notifications added (exceeded visit time, subject without - visit, unfinished visits, approching visits, unfinished appointments) + visit, unfinished visits, approaching visits, unfinished appointments) * improvement: calendar is separated between locations -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 07 Mar 2017 18:10:42 +0100 diff --git a/smash/web/api_views/daily_planning.py b/smash/web/api_views/daily_planning.py index 67861857f285340da8e35f060fa4f13ca9c29f5a..420f72930831c3f5eaa99028dadce7625fb2ddcd 100644 --- a/smash/web/api_views/daily_planning.py +++ b/smash/web/api_views/daily_planning.py @@ -55,10 +55,21 @@ def get_holidays(worker, date): minutes = int( (holiday.datetime_end - holiday.datetime_start).total_seconds() / 60) # hack for time zones - start_date = datetime.datetime.combine( + if holiday.datetime_start < today_start: + #if the start date of the holiday is before than today, we put the link_start today 00.00 + start_date = today_start + else: + start_date = datetime.datetime.combine( today_start, holiday.datetime_start.time()) - end_date = datetime.datetime.combine( - today_start, holiday.datetime_end.time()) + + if holiday.datetime_end > today_end: + #if the end date of the holiday is later than today, we put the link_end today 23.59 + end_date = today_end + else: + #truncates the end link to today at the time of the holiday end date + end_date = datetime.datetime.combine( + today_start, holiday.datetime_end.time()) + event = { 'duration': build_duration(minutes), 'link_when': start_date, diff --git a/smash/web/static/js/daily_planning.js b/smash/web/static/js/daily_planning.js index 70e0f899361aaac5f57f8a5388d00ace6095a456..043bcfe0922fb79fa10d31b55d0890b02ada7dad 100644 --- a/smash/web/static/js/daily_planning.js +++ b/smash/web/static/js/daily_planning.js @@ -490,6 +490,7 @@ function addDailyPlanningCalendar(calendar_selector, replace_all, calendar_dict_ snapDuration: '00:05', minTime: "08:00:00", maxTime: "19:00:00", + titleFormat: 'dddd, MMMM D, YYYY', businessHours: { start: '08:00', end: '19:00' diff --git a/smash/web/templates/doctors/add_holiday.html b/smash/web/templates/doctors/add_holiday.html index 63f441eb289a8baa9f3d12be9ed38d0bfae64ceb..3a7fa0464bcba052e08384d9a9d6e6a7e6b79b1b 100644 --- a/smash/web/templates/doctors/add_holiday.html +++ b/smash/web/templates/doctors/add_holiday.html @@ -32,7 +32,7 @@ changes)</a> </div> - <form method="post" action="" class="form-horizontal"> + <form id="add_holiday_form" method="post" action="" class="form-horizontal"> {% csrf_token %} <div class="box-body"> @@ -78,4 +78,18 @@ {{ block.super }} {% include "includes/datetimepicker.js.html" %} + <script> + $(function(){ + $('#add_holiday_form').on('submit', function(e){ + var start = moment($('#id_datetime_start').val()); + var end = moment($('#id_datetime_end').val()); + if(end <= start){ + e.preventDefault(); + alert('End date must be greater than start date.'); + return false; + } + return true; + }); + }) + </script> {% endblock scripts %} diff --git a/smash/web/templates/equipment_and_rooms/kit_requests/kit_requests.html b/smash/web/templates/equipment_and_rooms/kit_requests/kit_requests.html index 2e3beade15126929fe26f78953645c7bb949726e..96d934c163865bcd88051755b2d5fdb1b9d568c9 100644 --- a/smash/web/templates/equipment_and_rooms/kit_requests/kit_requests.html +++ b/smash/web/templates/equipment_and_rooms/kit_requests/kit_requests.html @@ -21,7 +21,7 @@ {% block content %} <div class="box box-info"> - <form method="post" action="" class="form-horizontal"> + <form method="post" action="{% url 'web.views.kit_requests' %}" class="form-horizontal"> {% csrf_token %} <div class="box-body"> diff --git a/smash/web/tests/api_views/test_daily_planning.py b/smash/web/tests/api_views/test_daily_planning.py index 3e082f788dae27b016e3bc37e382c6a7825c8be3..56e73bce467668f1bebffe84b2c69eba5fb57ac3 100644 --- a/smash/web/tests/api_views/test_daily_planning.py +++ b/smash/web/tests/api_views/test_daily_planning.py @@ -126,9 +126,9 @@ class TestDailyPlanningApi(LoggedInWithWorkerTestCase): availability.save() holiday = Holiday.objects.create(person=self.worker, - datetime_start=timezone.now().replace(year=2017, month=9, day=6, + datetime_start=timezone.now().replace(year=2017, month=9, day=5, hour=12), - datetime_end=timezone.now().replace(year=2017, month=9, day=6, + datetime_end=timezone.now().replace(year=2017, month=9, day=7, hour=20) ) holiday.save() @@ -137,9 +137,50 @@ class TestDailyPlanningApi(LoggedInWithWorkerTestCase): self.assertEqual(response.status_code, 200) availabilities = json.loads(response.content)['availabilities'] - self.assertEqual(1, len(availabilities)) + holidays = json.loads(response.content)['holidays'] + self.assertEqual(1, len(holidays)) + + def test_multi_day_holiday(self): + holiday = Holiday.objects.create(person=self.worker, + datetime_start=timezone.now().replace(year=2017, month=9, day=4, + hour=10, minute=0, second=0, microsecond=0), + datetime_end=timezone.now().replace(year=2017, month=9, day=6, + hour=15, minute=0, second=0, microsecond=0) + )#monday to wed + holiday.save() + + #monday + response = self.client.get(reverse('web.api.events', kwargs={'date': "2017-09-04"})) + self.assertEqual(response.status_code, 200) + holidays = json.loads(response.content)['holidays'] + self.assertEqual(1, len(holidays)) + + holiday = holidays[0] + self.assertTrue('2017-09-04T10:00:00' in holiday['link_when']) + self.assertTrue('2017-09-04T23:59:00' in holiday['link_end']) + + #tuesday + response = self.client.get(reverse('web.api.events', kwargs={'date': "2017-09-05"})) + self.assertEqual(response.status_code, 200) + holidays = json.loads(response.content)['holidays'] + self.assertEqual(1, len(holidays)) + + holiday = holidays[0] + self.assertTrue('2017-09-05T00:00:00' in holiday['link_when']) + self.assertTrue('2017-09-05T23:59:00' in holiday['link_end']) + + #wed + response = self.client.get(reverse('web.api.events', kwargs={'date': "2017-09-06"})) + self.assertEqual(response.status_code, 200) + holidays = json.loads(response.content)['holidays'] + self.assertEqual(1, len(holidays)) + + holiday = holidays[0] + self.assertTrue('2017-09-06T00:00:00' in holiday['link_when']) + self.assertTrue('2017-09-06T15:00:00' in holiday['link_end']) + def test_nonempty_availabilities_with_included_holidays(self): availability = Availability.objects.create(person=self.worker, day_number=TUESDAY_AS_DAY_OF_WEEK, available_from="8:00", available_till="16:00") @@ -157,6 +198,8 @@ class TestDailyPlanningApi(LoggedInWithWorkerTestCase): self.assertEqual(response.status_code, 200) availabilities = json.loads(response.content)['availabilities'] + holidays = json.loads(response.content)['holidays'] + self.assertEqual(1, len(holidays)) self.assertEqual(2, len(availabilities)) diff --git a/smash/web/views/kit.py b/smash/web/views/kit.py index 3a3fb57ef33e76fab957936e381cc934c825f5ad..69c9a7e6cf46565d855180a0248ef36e2d114043 100644 --- a/smash/web/views/kit.py +++ b/smash/web/views/kit.py @@ -225,10 +225,8 @@ def kit_requests_send_mail(request, start_date, end_date=None): except Exception as e: traceback.print_exc() - logger.warning('Kit Request Send Mail Failed: |{}|\n{}'.format( - e.message, e.args)) - messages.add_message(request, messages.ERROR, - 'There was problem with sending email') + logger.warning('Kit Request Send Mail Failed: |{}|\n{}'.format(str(e), e.args)) + messages.add_message(request, messages.ERROR, 'There was problem with sending email') return wrap_response(request, 'equipment_and_rooms/kit_requests/kit_requests.html', get_kit_requests_data(request)) diff --git a/smash/web/views/mails.py b/smash/web/views/mails.py index f675955abfbc898f11882a9166c1426c3e5e9320..2e13b20fa54a7cb90a0f15eea357072befb709e2 100644 --- a/smash/web/views/mails.py +++ b/smash/web/views/mails.py @@ -121,6 +121,10 @@ def generate_for_vouchers(request): vouchers.append(Voucher.objects.get(pk=int(voucher_id))) templates = MailTemplate.get_voucher_mail_templates([])[0] + if len(templates) == 0: + messages.add_message(request, messages.WARNING, 'There are no voucher mail templates. Please add one in order to print vouchers.') + return redirect(request.META.get('HTTP_REFERER', 'web.views.subjects')) + output_stream = io.BytesIO() inputs = []