Merge branch 'main' of gitea.pangea.org:trustchain-oc1-orchestral/IdHub

This commit is contained in:
Cayo Puigdefabregas 2024-02-02 09:18:27 +01:00
commit f613f99fdd
5 changed files with 70 additions and 31 deletions

View File

@ -62,7 +62,7 @@ class TermsAndConditionsView(AdminView, FormView):
template_name = "idhub/admin/terms_conditions.html" template_name = "idhub/admin/terms_conditions.html"
title = _("GDPR") title = _("GDPR")
section = "" section = ""
subtitle = _('Accept Terms and Conditions') subtitle = _('Terms and Conditions')
icon = 'bi bi-file-earmark-medical' icon = 'bi bi-file-earmark-medical'
form_class = TermsConditionsForm form_class = TermsConditionsForm
success_url = reverse_lazy('idhub:admin_dashboard') success_url = reverse_lazy('idhub:admin_dashboard')

View File

@ -11,7 +11,12 @@
</h3> </h3>
</div> </div>
<div class="col text-center"> <div class="col text-center">
<a href="javascript:void()" type="button" class="btn btn-green-user me-3">{% trans 'ARCO Forms' %}</a> {% if lang == 'es' %}
<a href="https://laweb.pangea.org/es/politica-de-proteccion-de-datos/acceso-a-los-formularios-arco/" target="_blank" type="button" class="btn btn-green-user me-3">{% trans 'ARCO Forms' %}</a>
{% else %}
<a href="https://laweb.pangea.org/politica-de-proteccio-de-dades/acces-als-formularis-arco/" target="_blank" type="button" class="btn btn-green-user me-3">{% trans 'ARCO Forms' %}</a>
{% endif %}
<a href="javascript:void()" type="button" class="btn btn-green-user">{% trans 'Notice of Privacy' %}</a> <a href="javascript:void()" type="button" class="btn btn-green-user">{% trans 'Notice of Privacy' %}</a>
</div> </div>
</div> </div>

View File

@ -20,38 +20,28 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
<div class="row"> <div class="row mt-4">
<div class="col"> <div class="col">
You must read the terms and conditions of this service and accept the {{ form.accept_privacy }}
<a class="btn btn-green-user" href="jacascript:void()" data-bs-toggle="modal" data-bs-target="#gdpr" title="{% trans 'GDPR' %}">Read GDPR</a> {{ form.privacy_label|safe }}
</div> </div>
</div> </div>
<div class="row"> <div class="row mt-2">
<div class="col-sm-4"> <div class="col">
{% bootstrap_form form %} {{ form.accept_legal }}
{{ form.legal_label|safe }}
</div> </div>
</div> </div>
<div class="form-actions-no-box"> <div class="row mt-2">
<div class="col">
{{ form.accept_cookies }}
{{ form.cookies_label|safe }}
</div>
</div>
<div class="form-actions-no-box mt-4">
<a class="btn btn-grey" href="{% url 'idhub:user_dashboard' %}">{% translate "Cancel" %}</a> <a class="btn btn-grey" href="{% url 'idhub:user_dashboard' %}">{% translate "Cancel" %}</a>
<input class="btn btn-green-user" type="submit" name="submit" value="{% translate 'Save' %}" /> <input class="btn btn-green-user" type="submit" name="submit" value="{% translate 'Save' %}" />
</div> </div>
</form> </form>
<!-- Modal -->
<div class="modal" id="gdpr" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{% trans 'GDPR info' %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Here we write the info about GDPR</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans 'Close' %}</button>
</div>
</div>
</div>
</div>
{% endblock %} {% endblock %}

View File

@ -15,8 +15,16 @@ class ProfileForm(forms.ModelForm):
class TermsConditionsForm(forms.Form): class TermsConditionsForm(forms.Form):
accept = forms.BooleanField( accept_privacy = forms.BooleanField(
label=_("Accept terms and conditions of the service"), 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 required=False
) )
@ -24,9 +32,33 @@ class TermsConditionsForm(forms.Form):
self.user = kwargs.pop('user', None) self.user = kwargs.pop('user', None)
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def get_label(self, url, read):
label = _('You must read the terms and conditions of this service and accept the')
label += f' <a class="btn btn-green-user" target="_blank" href="{url}" '
label += f'title="{read}">{read}</a>'
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): def clean(self):
data = self.cleaned_data data = self.cleaned_data
if data.get("accept"): 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 self.user.accept_gdpr = True
else: else:
self.user.accept_gdpr = False self.user.accept_gdpr = False

View File

@ -101,6 +101,13 @@ class ProfileView(MyProfile, UpdateView, SingleTableView):
def form_valid(self, form): def form_valid(self, form):
return super().form_valid(form) return super().form_valid(form)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'lang': self.request.LANGUAGE_CODE,
})
return context
class RolesView(MyProfile, SingleTableView): class RolesView(MyProfile, SingleTableView):
template_name = "idhub/user/roles.html" template_name = "idhub/user/roles.html"
@ -137,7 +144,7 @@ class TermsAndConditionsView(UserView, FormView):
template_name = "idhub/user/terms_conditions.html" template_name = "idhub/user/terms_conditions.html"
title = _("GDPR") title = _("GDPR")
section = "" section = ""
subtitle = _('Accept Terms and Conditions') subtitle = _('Terms and Conditions')
icon = 'bi bi-file-earmark-medical' icon = 'bi bi-file-earmark-medical'
form_class = TermsConditionsForm form_class = TermsConditionsForm
success_url = reverse_lazy('idhub:user_dashboard') success_url = reverse_lazy('idhub:user_dashboard')
@ -145,7 +152,12 @@ class TermsAndConditionsView(UserView, FormView):
def get_form_kwargs(self): def get_form_kwargs(self):
kwargs = super().get_form_kwargs() kwargs = super().get_form_kwargs()
kwargs['user'] = self.request.user 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 return kwargs
def form_valid(self, form): def form_valid(self, form):