add terms and conditions for admin too

This commit is contained in:
Cayo Puigdefabregas 2024-02-05 12:25:02 +01:00
parent 2d4273032c
commit a09d969dba
10 changed files with 164 additions and 27 deletions

View File

@ -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' <a class="btn btn-green-admin" 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
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(

View File

@ -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):

View File

@ -5,14 +5,14 @@
<div class="well">
<div class="row-fluid">
<h2>{% trans 'Doble Factor of Authentication' %}</h2>
<h2>{% trans 'Two-factor Authentication' %}</h2>
</div>
</div>
<div class="well">
<div class="row-fluid">
<div>
<span>{% trans "We have sent an email with a link that you have to select in order to login." %}</span>
<span>{% trans "We have sent you an email with a link that you have to click to log in." %}</span>
</div>
</div><!-- /.row-fluid -->
</div><!--/.well-->

View File

@ -1,6 +1,6 @@
{% load i18n %}{% autoescape off %}
<p>
{% 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 %}
</p>
<p>

View File

@ -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 %}

View File

@ -20,38 +20,68 @@
</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-admin" 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">
<a class="btn btn-grey" href="{% url 'idhub:admin_dashboard' %}">{% translate "Cancel" %}</a>
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
<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 href="javascript:accepts();" type="button" class="btn btn-green-admin">{% trans 'Confirm' %}</a>
</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>
<h5 class="modal-title" id="exampleModalLabel">{% trans 'Data protection' %}</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>
{% blocktrans %}
<p>If you do not consent to all terms and conditons this service may not be available to
anyone in your organization.<br /><br />
If you are sure to opt out of using this service please contact <a href="mailto:suport@pangea.org">suport@pangea.org</a> to unsubscribe. If you wish to continue, you must consent to all terms and conditions.</p>
{% endblocktrans %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans 'Close' %}</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans 'No' %}</button>
<input id="submit" class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Yes' %}" />
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block extrascript %}
<script>
$(document).ready(function() {
});
function accepts() {
var privacy = $("#id_accept_privacy").prop("checked");
var policy = $("#id_accept_legal").prop("checked");
var cookies = $("#id_accept_cookies").prop("checked");
if (privacy && policy && cookies) {
$("#submit").trigger("click");
} else {
$("#gdpr").modal("show");
}
}
</script>
{% endblock %}

View File

@ -88,7 +88,7 @@
</li>
<li class="nav-item">
<a class="nav-link {% if path == 'user_gdpr' %}active2{% endif %}" href="{% url 'idhub:user_gdpr' %}">
{% trans 'GDPR info' %}
{% trans 'Data protection' %}
</a>
</li>
</ul>
@ -150,9 +150,12 @@
</div>
</div>
{% block script %}
<script src="{% static "js/jquery-3.3.1.slim.min.js" %}"></script>
<script src="/static/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js" integrity="sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha" crossorigin="anonymous"></script>
<script src="/static/js/dashboard.js"></script>
{% block extrascript %}{% endblock %}
{% endblock %}
</body>
</html>

View File

@ -39,9 +39,49 @@
</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' %}" />
<a href="javascript:accepts();" type="button" class="btn btn-green-user">{% trans 'Confirm' %}</a>
</div>
<!-- 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 'Data protection' %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
{% blocktrans %}
<p>If you do not accept all the terms and conditions of this service you will not be able
to continue.
<br /><br />
Are you sure to opt out of using this service?</p>
{% endblocktrans %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans 'No' %}</button>
<input id="submit" class="btn btn-green-user" type="submit" name="submit" value="{% translate 'Yes' %}" />
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block extrascript %}
<script>
$(document).ready(function() {
});
function accepts() {
var privacy = $("#id_accept_privacy").prop("checked");
var policy = $("#id_accept_legal").prop("checked");
var cookies = $("#id_accept_cookies").prop("checked");
if (privacy && policy && cookies) {
$("#submit").trigger("click");
} else {
$("#gdpr").modal("show");
}
}
</script>
{% endblock %}

View File

@ -33,7 +33,7 @@ class TermsConditionsForm(forms.Form):
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 = _('I read and accepted the')
label += f' <a class="btn btn-green-user" target="_blank" href="{url}" '
label += f'title="{read}">{read}</a>'
return label

View File

@ -123,7 +123,7 @@ class RolesView(MyProfile, SingleTableView):
class GDPRView(MyProfile, TemplateView):
template_name = "idhub/user/gdpr.html"
subtitle = _('GDPR info')
subtitle = _('Data protection')
icon = 'bi bi-file-earmark-medical'
@ -142,7 +142,7 @@ class CredentialsView(MyWallet, SingleTableView):
class TermsAndConditionsView(UserView, FormView):
template_name = "idhub/user/terms_conditions.html"
title = _("GDPR")
title = _("Data Protection")
section = ""
subtitle = _('Terms and Conditions')
icon = 'bi bi-file-earmark-medical'