add 3 checkbox for terms and conditions
This commit is contained in:
parent
3eeff7bca2
commit
fb41f1b2fe
|
@ -62,7 +62,7 @@ class TermsAndConditionsView(AdminView, FormView):
|
|||
template_name = "idhub/admin/terms_conditions.html"
|
||||
title = _("GDPR")
|
||||
section = ""
|
||||
subtitle = _('Accept Terms and Conditions')
|
||||
subtitle = _('Terms and Conditions')
|
||||
icon = 'bi bi-file-earmark-medical'
|
||||
form_class = TermsConditionsForm
|
||||
success_url = reverse_lazy('idhub:admin_dashboard')
|
||||
|
|
|
@ -11,7 +11,12 @@
|
|||
</h3>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -20,38 +20,28 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<div class="row mt-4">
|
||||
<div class="col">
|
||||
You must read the terms and conditions of this service and accept the
|
||||
<a class="btn btn-green-user" href="jacascript:void()" data-bs-toggle="modal" data-bs-target="#gdpr" title="{% trans 'GDPR' %}">Read GDPR</a>
|
||||
{{ form.accept_privacy }}
|
||||
{{ form.privacy_label|safe }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
{% bootstrap_form form %}
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
{{ form.accept_legal }}
|
||||
{{ form.legal_label|safe }}
|
||||
</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>
|
||||
<input class="btn btn-green-user" type="submit" name="submit" value="{% translate 'Save' %}" />
|
||||
</div>
|
||||
|
||||
</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 %}
|
||||
|
|
|
@ -15,8 +15,16 @@ class ProfileForm(forms.ModelForm):
|
|||
|
||||
|
||||
class TermsConditionsForm(forms.Form):
|
||||
accept = forms.BooleanField(
|
||||
label=_("Accept terms and conditions of the service"),
|
||||
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
|
||||
)
|
||||
|
||||
|
@ -24,9 +32,33 @@ class TermsConditionsForm(forms.Form):
|
|||
self.user = kwargs.pop('user', None)
|
||||
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):
|
||||
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
|
||||
else:
|
||||
self.user.accept_gdpr = False
|
||||
|
|
|
@ -100,6 +100,13 @@ class ProfileView(MyProfile, UpdateView, SingleTableView):
|
|||
|
||||
def form_valid(self, 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):
|
||||
|
@ -137,7 +144,7 @@ class TermsAndConditionsView(UserView, FormView):
|
|||
template_name = "idhub/user/terms_conditions.html"
|
||||
title = _("GDPR")
|
||||
section = ""
|
||||
subtitle = _('Accept Terms and Conditions')
|
||||
subtitle = _('Terms and Conditions')
|
||||
icon = 'bi bi-file-earmark-medical'
|
||||
form_class = TermsConditionsForm
|
||||
success_url = reverse_lazy('idhub:user_dashboard')
|
||||
|
@ -145,7 +152,12 @@ class TermsAndConditionsView(UserView, 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):
|
||||
|
|
Loading…
Reference in a new issue