From 3408bb74e69b0b8952ff8840de5e1b35977e9c62 Mon Sep 17 00:00:00 2001 From: Taib Hayat Date: Wed, 20 Apr 2022 15:23:31 +0200 Subject: [PATCH 1/4] new tab for study consent blueprints --- .../studies/templates/studies/study_base.html | 3 +++ .../templates/studies/study_consent.html | 17 +++++++++++++++++ .../studies/templates/studies/study_form.html | 1 - castellum/studies/urls/__init__.py | 2 ++ castellum/studies/views/studies.py | 11 +++++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 castellum/studies/templates/studies/study_consent.html diff --git a/castellum/studies/templates/studies/study_base.html b/castellum/studies/templates/studies/study_base.html index c04a10b25..0a8d4f407 100644 --- a/castellum/studies/templates/studies/study_base.html +++ b/castellum/studies/templates/studies/study_base.html @@ -127,6 +127,9 @@ + diff --git a/castellum/studies/templates/studies/study_consent.html b/castellum/studies/templates/studies/study_consent.html new file mode 100644 index 000000000..cf4474fe1 --- /dev/null +++ b/castellum/studies/templates/studies/study_consent.html @@ -0,0 +1,17 @@ +{% extends "studies/study_base.html" %} +{% load static i18n django_bootstrap5 utils %} + +{% block title %}{% translate "Consent document" %}· {{ block.super }}{% endblock %} + +{% block content %} +
+ {% include 'utils/form_errors.html' with form=form %} + {% csrf_token %} + + {% bootstrap_field form.consent required_css_class='castellum-required' %} + +
+ +
+
+{% endblock %} diff --git a/castellum/studies/templates/studies/study_form.html b/castellum/studies/templates/studies/study_form.html index 1befb9350..55e05ed6a 100644 --- a/castellum/studies/templates/studies/study_form.html +++ b/castellum/studies/templates/studies/study_form.html @@ -30,7 +30,6 @@
{% bootstrap_field form.exportable_attributes required_css_class='castellum-required' %}
- {% bootstrap_field form.consent required_css_class='castellum-required' %} {% if CASTELLUM_STUDY_STATUS_NOTIFICATION_TO %} {% bootstrap_field form.announce_status_changes required_css_class='castellum-required' %} {% else %} diff --git a/castellum/studies/urls/__init__.py b/castellum/studies/urls/__init__.py index 9e54a76ae..579bc877c 100644 --- a/castellum/studies/urls/__init__.py +++ b/castellum/studies/urls/__init__.py @@ -26,6 +26,7 @@ from ..views.api import APIStudyDetailView from ..views.api import APIStudyListView from ..views.recruitment import AnonymousInvitationMailRecruitmentView from ..views.studies import FilterTrialCreateView +from ..views.studies import StudyConsentView from ..views.studies import StudyCreateView from ..views.studies import StudyDeleteView from ..views.studies import StudyDetailView @@ -53,6 +54,7 @@ urlpatterns = [ path('/delete/', StudyDeleteView.as_view(), name='delete'), path('/domains/', StudyDomainsView.as_view(), name='domains'), path('/domains/general/', StudyDomainsGeneralView.as_view(), name='domains-general'), + path('/consent/', StudyConsentView.as_view(), name='consent'), path( '/domains//', StudyDomainDeleteView.as_view(), diff --git a/castellum/studies/views/studies.py b/castellum/studies/views/studies.py index 4a362f30b..51d5c1298 100644 --- a/castellum/studies/views/studies.py +++ b/castellum/studies/views/studies.py @@ -469,6 +469,17 @@ class StudyDomainDeleteView(StudyDomainsMixin, DeleteView): return reverse('studies:domains', args=[self.study.pk]) +class StudyConsentView(PermissionRequiredMixin, UpdateView): + model = Study + permission_required = 'studies.change_study' + template_name = 'studies/study_consent.html' + subtab = 'consent' + fields = ['consent'] + + def get_success_url(self): + return reverse('studies:consent', args=[self.object.pk]) + + class StudyImportView(PermissionRequiredMixin, FormView): permission_required = 'studies.change_study' template_name = 'studies/study_import.html' -- GitLab From 85bc5d0f678d8987d4f1dd806533a17a2b45ecf1 Mon Sep 17 00:00:00 2001 From: Taib Hayat Date: Mon, 9 May 2022 11:34:53 +0200 Subject: [PATCH 2/4] remove consent from StudyForm --- castellum/studies/forms.py | 1 - 1 file changed, 1 deletion(-) diff --git a/castellum/studies/forms.py b/castellum/studies/forms.py index d5a1d1a6d..0eb2569a6 100644 --- a/castellum/studies/forms.py +++ b/castellum/studies/forms.py @@ -56,7 +56,6 @@ class StudyForm(forms.ModelForm): 'email', 'description', 'announce_status_changes', - 'consent', 'min_subject_count', 'exportable_attributes', 'is_anonymous_invitation', -- GitLab From 8d1d808d484acffa39608bf4c77ad5a5e4f31a24 Mon Sep 17 00:00:00 2001 From: Taib Hayat Date: Mon, 9 May 2022 15:04:07 +0200 Subject: [PATCH 3/4] make template title conform with tab name --- castellum/studies/templates/studies/study_consent.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/castellum/studies/templates/studies/study_consent.html b/castellum/studies/templates/studies/study_consent.html index cf4474fe1..978d308ed 100644 --- a/castellum/studies/templates/studies/study_consent.html +++ b/castellum/studies/templates/studies/study_consent.html @@ -1,7 +1,7 @@ {% extends "studies/study_base.html" %} {% load static i18n django_bootstrap5 utils %} -{% block title %}{% translate "Consent document" %}· {{ block.super }}{% endblock %} +{% block title %}{% translate "Consent" %} · {{ block.super }}{% endblock %} {% block content %}
-- GitLab From 55a07a22aac5f253ec2108357008eb86705e0386 Mon Sep 17 00:00:00 2001 From: Taib Hayat Date: Mon, 9 May 2022 15:04:15 +0200 Subject: [PATCH 4/4] add success message --- castellum/studies/views/studies.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/castellum/studies/views/studies.py b/castellum/studies/views/studies.py index 51d5c1298..be0bda0bb 100644 --- a/castellum/studies/views/studies.py +++ b/castellum/studies/views/studies.py @@ -479,6 +479,10 @@ class StudyConsentView(PermissionRequiredMixin, UpdateView): def get_success_url(self): return reverse('studies:consent', args=[self.object.pk]) + def form_valid(self, form): + messages.success(self.request, _('Data has been saved.')) + return super().form_valid(form) + class StudyImportView(PermissionRequiredMixin, FormView): permission_required = 'studies.change_study' -- GitLab