Skip to content
Snippets Groups Projects
Commit 27e41817 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

privacy notice acceptance is simplified

parent a60e315c
No related branches found
No related tags found
1 merge request!276Resolve "privacy notice and usage terms"
......@@ -23,6 +23,11 @@ class WorkerAcceptPrivacyNoticeForm(ModelForm):
super(WorkerAcceptPrivacyNoticeForm, self).__init__(*args, **kwargs)
self.fields['privacy_notice_accepted'].label = 'Do you accept the privacy notice?'
def clean(self):
cleaned_data = super().clean()
cleaned_data['privacy_notice_accepted'] = True
return cleaned_data
class WorkerForm(ModelForm):
class Meta:
model = Worker
......
......@@ -26,47 +26,19 @@
<div class="box-body">
<div class="form-group {% if field.errors %}has-error{% endif %}">
<label class="col-sm-4 col-lg-offset-1 col-lg-2 control-label">
Privacy Notice Summary
<p >{{privacy_notice.summary}}. Read <a href="{{ privacy_notice.document.url }}">more</a></p>
</label>
<div class="col-sm-8 col-lg-4">
<textarea class="form-control" readonly>{{privacy_notice.summary}}</textarea>
</div>
</div>
{% for field in form %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
<label class="col-sm-4 col-lg-offset-1 col-lg-2 control-label">
{{ field.label }}
{% if field.help_text %}
<i class="fa fa-info-circle help_text" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="{{field.help_text}}"></i>
{% endif %}
</label>
<div class="col-sm-8 col-lg-4">
{{ field|add_class:'form-control' }}
{% if field.errors %}
<span class="help-block">{{ field.errors }}</span>
{% endif %}
</div>
</div>
{% endfor %}
</div><!-- /.box-body -->
<div class="box-footer">
<div class="alert alert-warning" role="alert">
IMPORTANT: <b>If you do not accept the privacy notice, your account will be disabled.</b>
</div>
</div>
<div class="box-footer">
<div class="col-sm-6">
<a class="btn btn-block btn-info" title="Download privacy notice" href="{{ privacy_notice.document.url }}">
Download Privacy Notice &nbsp; <i class="fa fa-download"></i>
<a class="btn btn-block btn-info" href="{% url 'logout' %}">
I do not agree
</a>
</div>
<div class="col-sm-6">
<button type="submit" class="btn btn-block btn-success">{% block save-button %}
Submit{% endblock %}</button>
I agree{% endblock %}</button>
</div>
</div><!-- /.box-footer -->
</form>
......
......@@ -26,6 +26,7 @@ class PrivacyNoticeListView(ListView, WrappedView):
def dispatch(self, *args, **kwargs):
return super(PrivacyNoticeListView, self).dispatch(*args, **kwargs)
@PermissionDecorator('change_privacynotice', 'privacynotice')
def privacy_notice_add(request):
if request.method == 'POST':
......@@ -55,7 +56,8 @@ def privacy_notice_edit(request, pk):
except:
messages.add_message(request, messages.ERROR, 'There was a problem when updating the privacy notice.'
'Contact system administrator.')
return wrap_response(request, 'privacy_notice/edit.html', {'form': form, 'privacy_notice': privacy_notice})
return wrap_response(request, 'privacy_notice/edit.html',
{'form': form, 'privacy_notice': privacy_notice})
else:
form = PrivacyNoticeForm(instance=privacy_notice)
......@@ -70,9 +72,9 @@ class PrivacyNoticeDeleteView(DeleteView, WrappedView):
@PermissionDecorator('change_privacynotice', 'privacynotice')
def delete(self, request, *args, **kwargs):
messages.success(request, "Privacy Notice deleted")
#try:
# try:
return super(PrivacyNoticeDeleteView, self).delete(request, *args, **kwargs)
#except:
# except:
# messages.add_message(request, messages.ERROR, 'There was a problem when deleting privacy notice. '
# 'Contact system administrator.')
return redirect('web.views.privacy_notices')
......@@ -84,6 +86,7 @@ def privacy_notice_accept(request, pk):
if request.method == 'POST':
form = WorkerAcceptPrivacyNoticeForm(request.POST, instance=worker)
if form.is_valid():
# noinspection PyBroadException
try:
form.save()
if form.cleaned_data['privacy_notice_accepted']:
......@@ -92,14 +95,14 @@ def privacy_notice_accept(request, pk):
return redirect(request.POST.get('next'))
return redirect('web.views.appointments')
else:
messages.add_message(request, messages.ERROR, 'Privacy notice not accepted. Your account has been disabled.')
worker.disable()
return redirect('logout')
except:
except BaseException:
messages.add_message(request, messages.ERROR, 'There was a problem when updating the privacy notice.'
'Contact system administrator.')
return wrap_response(request, 'privacy_notice/acceptance_study_privacy_notice.html', {'form': form, 'privacy_notice': privacy_notice})
return wrap_response(request, 'privacy_notice/acceptance_study_privacy_notice.html',
{'form': form, 'privacy_notice': privacy_notice})
else:
form = WorkerAcceptPrivacyNoticeForm(instance=worker)
return wrap_response(request, 'privacy_notice/acceptance_study_privacy_notice.html', {'form': form, 'privacy_notice': privacy_notice})
\ No newline at end of file
return wrap_response(request, 'privacy_notice/acceptance_study_privacy_notice.html',
{'form': form, 'privacy_notice': privacy_notice})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment