diff --git a/smash/web/forms/study_forms.py b/smash/web/forms/study_forms.py index a0c6b33f119b4fda87c67dcf3f5ae9fd20cb261b..df1874fa316d955ecd36530e99fa7f8866866738 100644 --- a/smash/web/forms/study_forms.py +++ b/smash/web/forms/study_forms.py @@ -19,8 +19,10 @@ class StudyEditForm(ModelForm): #check regex nd_number_study_subject_regex = cleaned_data.get('nd_number_study_subject_regex') + + instance = getattr(self, 'instance', None) - if nd_number_study_subject_regex is None or StudySubject.check_nd_number_regex(nd_number_study_subject_regex) == False: + if nd_number_study_subject_regex is None or StudySubject.check_nd_number_regex(nd_number_study_subject_regex, instance) == False: self.add_error('nd_number_study_subject_regex', 'Please enter a valid nd_number_study_subject_regex regex.') #check default_visit_duration_in_months diff --git a/smash/web/management/commands/holidays.py b/smash/web/management/commands/holidays.py index 7c01d080eecf0b2718506b3c7a33eebc566cf3ba..9ad587a79c97c0555a61a90cf3f4486d1792a29c 100644 --- a/smash/web/management/commands/holidays.py +++ b/smash/web/management/commands/holidays.py @@ -4,8 +4,6 @@ from django.core.management.base import BaseCommand from ...models import Appointment, Location, AppointmentType, AppointmentTypeLink -appointment_type_other = AppointmentType.objects.filter(code='OTHER').first() - def get_easter_monday(easter_sunday): return next_weekday(easter_sunday, 0) @@ -64,6 +62,7 @@ class Command(BaseCommand): holiday.comment = comment holiday.visit_id = None holiday.save() + appointment_type_other = AppointmentType.objects.get_or_create(code='OTHER', defaults={default_duration: 10}) link = AppointmentTypeLink(appointment=holiday, appointment_type=appointment_type_other) link.save() diff --git a/smash/web/models/study_subject.py b/smash/web/models/study_subject.py index 8994caff22f7f5833f03626c76baf08253c833fb..0f0c1ddd7859934cee742395134ffb572ec6d2f0 100644 --- a/smash/web/models/study_subject.py +++ b/smash/web/models/study_subject.py @@ -208,8 +208,8 @@ class StudySubject(models.Model): return matches + sorted(reminder, reverse=reverse) @staticmethod - def check_nd_number_regex(regex_str): - nd_numbers = StudySubject.objects.all().values_list('nd_number', flat=True) + def check_nd_number_regex(regex_str, study): + nd_numbers = StudySubject.objects.filter(study=study).exclude(nd_number__isnull=True).exclude(nd_number__exact='').all().values_list('nd_number', flat=True) regex = re.compile(regex_str) for nd_number in nd_numbers: if regex.match(nd_number) is None: diff --git a/smash/web/static/js/daily_planning.js b/smash/web/static/js/daily_planning.js index 816a1ec4256b40b965c969e9108898c3b77e47bf..1c02d38cb2652d73ebe3cee1c847d4bb2cb7e873 100644 --- a/smash/web/static/js/daily_planning.js +++ b/smash/web/static/js/daily_planning.js @@ -47,12 +47,12 @@ function add_event(event, color, subjectId, locationId, boxBody) { if (event_title === undefined || event_title === "") { event_title = event.title; } - eventElement.data('event', { + + event_data = { appointment_start: event.appointment_start, appointment_end: event.appointment_end, title: event_title, stick: true, - color: color + " !important", duration: event.duration, original_duration: event.duration, subject: event.subject, @@ -70,8 +70,13 @@ function add_event(event, color, subjectId, locationId, boxBody) { end: $.fullCalendar.moment(event.appointment_end) }, borderColor: borderColor + } - }); + if(color != undefined){ + event_data['color'] = color + " !important"; + } + + eventElement.data('event', event_data); eventElement.draggable({ zIndex: 999, revert: true, @@ -227,6 +232,10 @@ function get_subjects_events(day) { } function remove_event(event) { + if(event.className.includes("background-event")){ //avoid removing availabilities + return; + } + $('#calendar').fullCalendar('removeEvents', event.id); var selector; if (event.subject_id !== undefined) { @@ -239,7 +248,10 @@ function remove_event(event) { event.duration = event.original_duration; event.removed = true; //remove !important - event.color = event.color.substring(0, 7); + if(event.color != undefined){ + event.color = event.color.substring(0, 7); + } + if (event.link_id !== undefined) { eventsCleared.push(event.link_id); } else { diff --git a/smash/web/templates/_base.html b/smash/web/templates/_base.html index b08784ea6188dd5a401844dbe45cda74c254ba30..5cc08db6e30ed1aeb919f744570d6fac374b73d0 100644 --- a/smash/web/templates/_base.html +++ b/smash/web/templates/_base.html @@ -379,6 +379,10 @@ desired effect var activate = function (page_to_activate) { var $e = $(".sidebar-menu li[data-desc='" + page_to_activate + "']"); $e.addClass("active"); + if($($e).parents('li[data-desc]').length > 0){ //if there is a parent, it should also be active + $($e).parents('li[data-desc]').addClass("active"); + } + }; activate({% block ui_active_tab %}{% endblock ui_active_tab %}); diff --git a/smash/web/templates/configuration/breadcrumb.html b/smash/web/templates/configuration/breadcrumb.html index 236d1bc335add0ec4427809a9c3c7e94a6490f26..737ff03042e6505dee855e4cd14da66fc9a5937e 100644 --- a/smash/web/templates/configuration/breadcrumb.html +++ b/smash/web/templates/configuration/breadcrumb.html @@ -1,4 +1,5 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> +<li>Configuration</li> <li class="active"> - <a href="{% url 'web.views.configuration' %}">Configuration</a> + <a href="{% url 'web.views.configuration' %}">General</a> </li> diff --git a/smash/web/templates/configuration/index.html b/smash/web/templates/configuration/index.html index 7330cbc831b41c140a70a67eeeeb3aa1354305fc..d5580458239aeb03c3cd24323d5be81f70cfc513 100644 --- a/smash/web/templates/configuration/index.html +++ b/smash/web/templates/configuration/index.html @@ -9,7 +9,7 @@ {% endblock styles %} -{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %} +{% block ui_active_tab %}'general_conf'{% endblock ui_active_tab %} {% block page_header %}Configuration{% endblock page_header %} {% block page_description %}{% endblock page_description %} diff --git a/smash/web/templates/doctors/breadcrumb.html b/smash/web/templates/doctors/breadcrumb.html index 6d111dd545adc0d422fe4dfae996671af3c8f657..391f87d887db27dadfd5b2a7f390967d920769fd 100644 --- a/smash/web/templates/doctors/breadcrumb.html +++ b/smash/web/templates/doctors/breadcrumb.html @@ -1,2 +1,7 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> +{% if worker_type == 'HEALTH_PARTNER' %} +<li>Configuration</li> +{% elif worker_type == 'VOUCHER_PARTNER' %} +<li>Configuration</li> +{% endif %} <li class="active"><a href="{% url 'web.views.workers' %}">Workers</a></li> \ No newline at end of file diff --git a/smash/web/templates/doctors/index.html b/smash/web/templates/doctors/index.html index 0884c2a59d786277475519c5174b84311e09d260..e1b0fef9d130e9837600cea02f05ca0e849de70d 100644 --- a/smash/web/templates/doctors/index.html +++ b/smash/web/templates/doctors/index.html @@ -21,8 +21,18 @@ </style> {% endblock styles %} -{% block ui_active_tab %}'workers'{% endblock ui_active_tab %} +{% block ui_active_tab %} +{% if worker_type == 'STAFF' %} +'workers' +{% elif worker_type == 'HEALTH_PARTNER' %} +'health_partners' +{% elif worker_type == 'VOUCHER_PARTNER' %} +'voucher_partners' +{% endif %} +{% endblock ui_active_tab %} + {% block page_header %} + {% if worker_type == 'STAFF' %} Workers {% elif worker_type == 'HEALTH_PARTNER' %} @@ -30,6 +40,7 @@ {% elif worker_type == 'VOUCHER_PARTNER' %} Voucher Partners {% endif %} + {% endblock page_header %} {% block breadcrumb %} {% include "doctors/breadcrumb.html" %} diff --git a/smash/web/templates/languages/breadcrumb.html b/smash/web/templates/languages/breadcrumb.html index b3194bfb0a32794c726a75682425d7ea4b17f30d..6e78554facad42d8816fb4f9dd84e0a8f5dd3535 100644 --- a/smash/web/templates/languages/breadcrumb.html +++ b/smash/web/templates/languages/breadcrumb.html @@ -1,2 +1,5 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> -<li class="active"><a href="{% url 'web.views.languages' %}">Languages</a></li> \ No newline at end of file +<li>Configuration</li> +<li class="active"> + <a href="{% url 'web.views.languages' %}">Languages</a> +</li> \ No newline at end of file diff --git a/smash/web/templates/languages/list.html b/smash/web/templates/languages/list.html index eeb9eb68a3fff742857578282926129f210be213..33a5e5178c7c4b9355776bb5f588e0d2b76c64a3 100644 --- a/smash/web/templates/languages/list.html +++ b/smash/web/templates/languages/list.html @@ -7,7 +7,7 @@ <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}"> {% endblock styles %} -{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %} +{% block ui_active_tab %}'languages'{% endblock ui_active_tab %} {% block page_header %}Languages{% endblock page_header %} {% block page_description %}{% endblock page_description %} diff --git a/smash/web/templates/sidebar.html b/smash/web/templates/sidebar.html index f4b3c8575046b51a695816f564e40c7e02272e37..aedfcfa45b6717bdcb4fa35acfb5dbfa973d5a0c 100644 --- a/smash/web/templates/sidebar.html +++ b/smash/web/templates/sidebar.html @@ -83,16 +83,16 @@ </span> </a> <ul class="treeview-menu"> - <li><a href="{% url 'web.views.configuration' %}">General</a></li> - <li><a href="{% url 'web.views.languages' %}">Languages</a></li> + <li data-desc="general_conf"><a href="{% url 'web.views.configuration' %}">General</a></li> + <li data-desc="languages"><a href="{% url 'web.views.languages' %}">Languages</a></li> {% if study.has_voucher_types %} - <li><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li> + <li data-desc="voucher_types"><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li> {% endif %} {% if study.has_vouchers %} - <li><a href="{% url 'web.views.workers' 'VOUCHER_PARTNER' %}">Voucher partners</a></li> + <li data-desc="voucher_partners"><a href="{% url 'web.views.workers' 'VOUCHER_PARTNER' %}">Voucher partners</a></li> {% endif %} - <li><a href="{% url 'web.views.workers' 'HEALTH_PARTNER' %}">Health partners</a></li> - <li><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li> + <li data-desc="health_partners"><a href="{% url 'web.views.workers' 'HEALTH_PARTNER' %}">Health partners</a></li> + <li data-desc="study_conf"><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li> </ul> </li> diff --git a/smash/web/templates/study/breadcrumb.html b/smash/web/templates/study/breadcrumb.html new file mode 100644 index 0000000000000000000000000000000000000000..f6052818f23962928e0f9d250f8b163cbb5c7747 --- /dev/null +++ b/smash/web/templates/study/breadcrumb.html @@ -0,0 +1,3 @@ +<li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> +<li>Configuration</li> +<li class="active"><a href="{% url 'web.views.edit_study' study_id %}">Study</a></li> \ No newline at end of file diff --git a/smash/web/templates/study/edit.html b/smash/web/templates/study/edit.html index e1e8d594d914cae156ec0bbac6bb0b134b9e488b..760f930b8d2338ac28c97dc5a9a3aa825bdee8e2 100644 --- a/smash/web/templates/study/edit.html +++ b/smash/web/templates/study/edit.html @@ -16,14 +16,14 @@ {% include "includes/datetimepicker.css.html" %} {% endblock styles %} -{% block ui_active_tab %}'subjects'{% endblock ui_active_tab %} +{% block ui_active_tab %}'study_conf'{% endblock ui_active_tab %} {% block page_header %}Edit subject{% endblock page_header %} {% block page_description %}{% endblock page_description %} {% block title %}{{ block.super }} - Edit subject information{% endblock %} {% block breadcrumb %} - {% include "subjects/breadcrumb.html" %} + {% include "study/breadcrumb.html" %} {% endblock breadcrumb %} {% block maincontent %} diff --git a/smash/web/templates/voucher_types/breadcrumb.html b/smash/web/templates/voucher_types/breadcrumb.html index 844971e607ceace28009bea2b53bf6ccd423ba0d..d3fe1508ae40cd59514f2c828129472bb89bd6b1 100644 --- a/smash/web/templates/voucher_types/breadcrumb.html +++ b/smash/web/templates/voucher_types/breadcrumb.html @@ -1,2 +1,3 @@ <li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li> +<li>Configuration</li> <li class="active"><a href="{% url 'web.views.voucher_types' %}">Voucher types</a></li> \ No newline at end of file diff --git a/smash/web/templates/voucher_types/list.html b/smash/web/templates/voucher_types/list.html index dec5cde7cb9c8db00538232581c1ebc6d11bb42a..22ae47336625cf36d56ebf8d41793e45e0956cb2 100644 --- a/smash/web/templates/voucher_types/list.html +++ b/smash/web/templates/voucher_types/list.html @@ -7,7 +7,7 @@ <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}"> {% endblock styles %} -{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %} +{% block ui_active_tab %}'voucher_types'{% endblock ui_active_tab %} {% block page_header %}Voucher types{% endblock page_header %} {% block page_description %}{% endblock page_description %} diff --git a/smash/web/tests/forms/test_study_forms.py b/smash/web/tests/forms/test_study_forms.py index a6180017841b04dad385911f5b4e3781f16e12db..0fe2bd2cd5f0b9fce56a6f11feef5e9bb471fd49 100644 --- a/smash/web/tests/forms/test_study_forms.py +++ b/smash/web/tests/forms/test_study_forms.py @@ -1,6 +1,6 @@ from django.test import TestCase from django.forms import ValidationError -from web.tests.functions import create_study_subject +from web.tests.functions import get_test_study, create_study_subject from web.forms.study_forms import StudyEditForm from web.models.study import Study from web.models.study_subject import StudySubject @@ -12,6 +12,7 @@ class StudyFormTests(TestCase): StudySubject.objects.all().delete() create_study_subject(nd_number='ND0001') form = StudyEditForm() + form.instance = get_test_study() # set default regex nd_number_study_subject_regex_default = Study._meta.get_field( 'nd_number_study_subject_regex').get_default() @@ -21,6 +22,7 @@ class StudyFormTests(TestCase): self.assertTrue(form.clean()['nd_number_study_subject_regex'] == nd_number_study_subject_regex_default) # test wrong regex form = StudyEditForm() + form.instance = get_test_study() nd_number_study_subject_regex_default = r'^nd\d{5}$' form.cleaned_data = { 'nd_number_study_subject_regex': nd_number_study_subject_regex_default} @@ -31,6 +33,7 @@ class StudyFormTests(TestCase): # this will add a studysubject with a NDnumber create_study_subject(nd_number='nd00001') form = StudyEditForm() + form.instance = get_test_study() # test new regex nd_number_study_subject_regex_default = r'^nd\d{5}$' form.cleaned_data = { diff --git a/smash/web/tests/models/test_study_subject.py b/smash/web/tests/models/test_study_subject.py index a3506d3be75b9b4ebbf35414b4ee763628300d25..324702f6dcde4d9be69974cdb77bf03f145122e1 100644 --- a/smash/web/tests/models/test_study_subject.py +++ b/smash/web/tests/models/test_study_subject.py @@ -3,7 +3,7 @@ from django.test import TestCase from web.models import Appointment from web.models import Visit from web.models import StudySubject, Study -from web.tests.functions import create_study_subject, create_appointment, create_study_subject_with_multiple_screening_numbers +from web.tests.functions import get_test_study, create_study_subject, create_appointment, create_study_subject_with_multiple_screening_numbers from web.tests.functions import create_visit @@ -72,24 +72,24 @@ class SubjectModelTests(TestCase): Appointment.APPOINTMENT_STATUS_CANCELLED, appointment_status) def test_check_nd_number_regex(self): + study = get_test_study() + # delete everything StudySubject.objects.all().delete() # get default regex nd_number_study_subject_regex_default = Study._meta.get_field( 'nd_number_study_subject_regex').get_default() - self.assertTrue(StudySubject.check_nd_number_regex( - nd_number_study_subject_regex_default)) + + self.assertTrue(StudySubject.check_nd_number_regex(nd_number_study_subject_regex_default, study)) # this will add a studysubject with a NDnumber study_subject = create_study_subject(nd_number='ND0001') - self.assertTrue(StudySubject.check_nd_number_regex( - nd_number_study_subject_regex_default)) + self.assertTrue(StudySubject.check_nd_number_regex(nd_number_study_subject_regex_default, study)) # delete everything StudySubject.objects.all().delete() # this will add a studysubject with a NDnumber create_study_subject(nd_number='ND00001') - self.assertFalse(StudySubject.check_nd_number_regex( - nd_number_study_subject_regex_default)) + self.assertFalse(StudySubject.check_nd_number_regex(nd_number_study_subject_regex_default, study)) def test_sort_matched_screening_first(self):