diff --git a/idhub/admin/forms.py b/idhub/admin/forms.py index b8fcec4..1895195 100644 --- a/idhub/admin/forms.py +++ b/idhub/admin/forms.py @@ -23,7 +23,7 @@ from idhub.models import ( from idhub_auth.models import User -class TermsConditionsForm(forms.Form): +class TermsConditionsForm2(forms.Form): accept = forms.BooleanField( label=_("Accept terms and conditions of the service"), required=False @@ -50,6 +50,65 @@ class TermsConditionsForm(forms.Form): return +class TermsConditionsForm(forms.Form): + accept_privacy = forms.BooleanField( + widget=forms.CheckboxInput(attrs={'class': 'form-check-input'}), + required=False + ) + accept_legal = forms.BooleanField( + widget=forms.CheckboxInput(attrs={'class': 'form-check-input'}), + required=False + ) + accept_cookies = forms.BooleanField( + widget=forms.CheckboxInput(attrs={'class': 'form-check-input'}), + required=False + ) + + def __init__(self, *args, **kwargs): + self.user = kwargs.pop('user', None) + super().__init__(*args, **kwargs) + + def get_label(self, url, read): + label = _('I read and accepted the') + label += f' {read}' + return label + + def privacy_label(self): + url = "https://laweb.pangea.org/politica-de-privacitat/" + read = _("Read privacy policy") + return self.get_label(url, read) + + def legal_label(self): + url = "https://laweb.pangea.org/avis-legal/" + read = _("Read legal policy") + return self.get_label(url, read) + + def cookies_label(self): + url = "https://laweb.pangea.org/politica-de-cookies-2/" + read = _("Read cookies policy") + return self.get_label(url, read) + + def clean(self): + data = self.cleaned_data + privacy = data.get("accept_privacy") + legal = data.get("accept_legal") + cookies = data.get("accept_cookies") + if privacy and legal and cookies: + self.user.accept_gdpr = True + else: + self.user.accept_gdpr = False + return data + + def save(self, commit=True): + + if commit: + self.user.save() + return self.user + + return + + class ImportForm(forms.Form): did = forms.ChoiceField(label=_("Did"), choices=[]) eidas1 = forms.ChoiceField( diff --git a/idhub/admin/views.py b/idhub/admin/views.py index 31a9994..f680698 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -60,7 +60,7 @@ from idhub.models import ( class TermsAndConditionsView(AdminView, FormView): template_name = "idhub/admin/terms_conditions.html" - title = _("GDPR") + title = _('Data protection') section = "" subtitle = _('Terms and Conditions') icon = 'bi bi-file-earmark-medical' @@ -70,7 +70,12 @@ class TermsAndConditionsView(AdminView, FormView): def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs['user'] = self.request.user - kwargs['initial'] = {"accept": self.request.user.accept_gdpr} + if self.request.user.accept_gdpr: + kwargs['initial'] = { + "accept_privacy": True, + "accept_legal": True, + "accept_cookies": True + } return kwargs def form_valid(self, form): diff --git a/idhub/templates/auth/2fadmin.html b/idhub/templates/auth/2fadmin.html index 4dc2ae6..e96d1b7 100644 --- a/idhub/templates/auth/2fadmin.html +++ b/idhub/templates/auth/2fadmin.html @@ -5,14 +5,14 @@
-{% blocktrans %}You're receiving this email because you try to access in {{ site_name }}.{% endblocktrans %} +{% blocktrans %}You're receiving this email because you tried to access {{ site_name }}.{% endblocktrans %}
diff --git a/idhub/templates/auth/2fadmin_email.txt b/idhub/templates/auth/2fadmin_email.txt index a9ef3e5..6328f66 100644 --- a/idhub/templates/auth/2fadmin_email.txt +++ b/idhub/templates/auth/2fadmin_email.txt @@ -1,5 +1,5 @@ {% load i18n %}{% autoescape off %} -{% blocktrans %}You're receiving this email because you try to access in {{ site_name }}.{% endblocktrans %} +{% blocktrans %}You're receiving this email because you tried to access {{ site_name }}.{% endblocktrans %} {% trans "Please go to the following page" %} {% block reset_link %} diff --git a/idhub/templates/idhub/admin/terms_conditions.html b/idhub/templates/idhub/admin/terms_conditions.html index 51f8b6c..c73f953 100644 --- a/idhub/templates/idhub/admin/terms_conditions.html +++ b/idhub/templates/idhub/admin/terms_conditions.html @@ -20,38 +20,68 @@ {% endif %} -