diff --git a/castellum/castellum_auth/fixtures/groups.json b/castellum/castellum_auth/fixtures/groups.json index bbbe6e54483045fad824a04f3d85624fe4129119..0760eefac6d1db28648b4fe82049614d65737717 100644 --- a/castellum/castellum_auth/fixtures/groups.json +++ b/castellum/castellum_auth/fixtures/groups.json @@ -52,6 +52,11 @@ "recruit", "recruitment", "participation" + ], + [ + "change_appointment", + "recruitment", + "appointment" ] ] } @@ -66,6 +71,11 @@ "conduct_study", "recruitment", "participation" + ], + [ + "change_appointment", + "recruitment", + "appointment" ] ] } diff --git a/castellum/execution/templates/execution/participation_appointments.html b/castellum/execution/templates/execution/participation_appointments.html index aee26fd53e86f5153f0fde9d6317cf958ee2cbdf..a2b71a553853beda962278f9a47e5210703a7c09 100644 --- a/castellum/execution/templates/execution/participation_appointments.html +++ b/castellum/execution/templates/execution/participation_appointments.html @@ -1,5 +1,5 @@ {% extends "execution/participation_base.html" %} -{% load i18n bootstrap4 utils %} +{% load i18n auth bootstrap4 utils %} {% block content %}
@@ -25,7 +25,10 @@ {% endfor %}
-
- {% translate 'Update' %} -
+ {% has_perm 'recruitment.change_appointment' user study as can_change_appointment %} + {% if can_change_appointment %} +
+ {% translate 'Update' %} +
+ {% endif %} {% endblock %} diff --git a/castellum/execution/templates/execution/participation_appointments_form.html b/castellum/execution/templates/execution/participation_appointments_form.html index faa487f0ba0870db13dd294bf41201592502375b..be89cbb7c9e9d9d8d17eb5075559fdf36cca6cd5 100644 --- a/castellum/execution/templates/execution/participation_appointments_form.html +++ b/castellum/execution/templates/execution/participation_appointments_form.html @@ -27,7 +27,7 @@ {% endfor %}
- {% translate 'Calendar' %} + {% translate 'Calendar' %}
diff --git a/castellum/execution/templates/execution/participation_base.html b/castellum/execution/templates/execution/participation_base.html index 5b86d58dd24056dbf5d214981a58a1f2afe63e51..1ba76987bbaca0fc10495c950064966f956475f7 100644 --- a/castellum/execution/templates/execution/participation_base.html +++ b/castellum/execution/templates/execution/participation_base.html @@ -1,5 +1,5 @@ {% extends "execution/base.html" %} -{% load i18n auth %} +{% load i18n %} {% block title %}{{ study }} · {{ block.super }}{% endblock %} diff --git a/castellum/execution/views.py b/castellum/execution/views.py index b8bdd2e76ecc59454730eca890dd2edf63256ea8..e5c64133c1eb45e3f4c084f3c526fc98823b852e 100644 --- a/castellum/execution/views.py +++ b/castellum/execution/views.py @@ -142,6 +142,7 @@ class ParticipationAppointmentsView(ParticipationDetailMixin, DetailView): class ParticipationAppointmentsUpdateView(ParticipationDetailMixin, UpdateView): template_name = 'execution/participation_appointments_form.html' + permission_required = ['recruitment.conduct_study', 'recruitment.change_appointment'] form_class = AppointmentsForm tab = 'appointments' diff --git a/castellum/recruitment/feeds.py b/castellum/recruitment/feeds.py index ba551e249ee70184a304069b98e41596a1f93bd5..b6f22d689c46960d99c049707dc40f0e8f0522e8 100644 --- a/castellum/recruitment/feeds.py +++ b/castellum/recruitment/feeds.py @@ -62,7 +62,7 @@ class FollowUpFeedForUser(BaseFollowUpFeed): class AppointmentFeed(BaseAppointmentFeed): def get_object(self, request, *args, **kwargs): study = get_object_or_404(Study, pk=kwargs['pk'], status=Study.EXECUTION) - perms = ['recruitment.recruit', 'studies.access_study'] + perms = ['recruitment.change_appointment', 'studies.access_study'] if not self.request.user.has_perms(perms, obj=study): raise PermissionDenied return study diff --git a/castellum/recruitment/forms.py b/castellum/recruitment/forms.py index 5f20df56771f32b0bfa05e4e6d4d2b8ffac64f4e..2918ecbdc7986f389988e7fed8a8dab5d177d94a 100644 --- a/castellum/recruitment/forms.py +++ b/castellum/recruitment/forms.py @@ -267,7 +267,7 @@ class AppointmentsForm(forms.ModelForm): yield self[name] -class ContactForm(AppointmentsForm): +class ContactForm(forms.ModelForm): class Meta: model = Participation fields = ['status', 'followup_date', 'followup_time', 'exclusion_criteria_checked'] @@ -290,6 +290,10 @@ class ContactForm(AppointmentsForm): self.fields['status'].widget.disabled_choices = [Participation.INVITED] +class ContactAndAppointmentsForm(ContactForm, AppointmentsForm): + pass + + class SendMailForm(forms.Form): batch_size = forms.IntegerField( min_value=1, label=_('How many subjects do you want to contact?') diff --git a/castellum/recruitment/templates/recruitment/contact.html b/castellum/recruitment/templates/recruitment/contact.html index 6d06ce8ef2644899c4770c394afad9aa30afc71c..ac8c55204be6fd2583d5d65cecdca01331caf551 100644 --- a/castellum/recruitment/templates/recruitment/contact.html +++ b/castellum/recruitment/templates/recruitment/contact.html @@ -36,6 +36,8 @@
{% endif %} + {% has_perm 'recruitment.change_appointment' user study as can_change_appointment %} +