Skip to content
Snippets Groups Projects
Commit fd7f6e30 authored by Carlos Vega's avatar Carlos Vega
Browse files

WIP: first draft of privacy notice, go to /privacy_notices to list them and...

WIP: first draft of privacy notice, go to /privacy_notices to list them and add them, please, create the folder privacy_notices/ before running
parent dee1c0fa
No related branches found
No related tags found
1 merge request!276Resolve "privacy notice and usage terms"
Pipeline #34363 failed
Showing
with 367 additions and 3 deletions
from django import forms
from django.forms import ModelForm
from web.models import PrivacyNotice
import logging
logger = logging.getLogger(__name__)
class PrivacyNoticeForm(ModelForm):
class Meta:
model = PrivacyNotice
fields = '__all__'
def clean(self):
cleaned_data = super(PrivacyNoticeForm, self).clean()
return cleaned_data
\ No newline at end of file
# Generated by Django 2.0.13 on 2020-11-16 15:08
import django.core.files.storage
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('web', '0176_configurationitem_local_setting_clean'),
]
operations = [
migrations.CreateModel(
name='PrivacyNotice',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('document', models.FileField(editable=False, upload_to='privacy_notices/', verbose_name='Study Privacy Notice file')),
],
),
migrations.AddField(
model_name='study',
name='study_privacy_notice',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='studies', to='web.PrivacyNotice', verbose_name='Study Privacy Note'),
)
]
# Generated by Django 2.0.13 on 2020-11-16 15:13
import django.core.files.storage
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('web', '0177_auto_20201116_1508'),
]
operations = [
migrations.AddField(
model_name='privacynotice',
name='study',
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='web.Study', verbose_name='Study'),
)
]
# Generated by Django 2.0.13 on 2020-11-16 15:28
import django.core.files.storage
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('web', '0178_auto_20201116_1513'),
]
operations = [
migrations.AddField(
model_name='privacynotice',
name='updated_at',
field=models.DateTimeField(auto_now=True),
)
]
......@@ -38,6 +38,7 @@ from .contact_attempt import ContactAttempt
from .mail_template import MailTemplate
from .missing_subject import MissingSubject
from .inconsistent_subject import InconsistentSubject, InconsistentField
from .privacy_notice import PrivacyNotice
__all__ = [Study, FlyingTeam, Appointment, AppointmentType, Availability, Holiday, Item, Language, Location, Room,
Subject, StudySubject, StudySubjectList, SubjectColumns, StudyNotificationParameters,
......
......@@ -94,6 +94,13 @@ class Study(models.Model):
blank=False
)
study_privacy_notice = models.ForeignKey("web.PrivacyNotice",
verbose_name='Study Privacy Note',
editable=True,
null=True, on_delete=models.CASCADE, #check cascade ondelete
related_name='studies'
)
def check_nd_number(self, nd_number):
regex = re.compile(self.nd_number_study_subject_regex)
return regex.match(nd_number) is not None
......
{% extends "privacy_notice/add_edit.html" %}
{% block page_header %}New privacy notice{% endblock page_header %}
{% block title %}{{ block.super }} - Add new privacy notice{% endblock %}
{% block form-title %}Enter privacy notice details{% endblock %}
{% block save-button %}Add{% endblock %}
\ No newline at end of file
{% extends "_base.html" %}
{% load static %}
{% load filters %}
{% block styles %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}"/>
<style type="text/css">
.help_text{
margin-left: 5px;
}
</style>
{% endblock styles %}
{% block ui_active_tab %}'subjects'{% endblock ui_active_tab %}
{% block page_description %}{% endblock page_description %}
{% block breadcrumb %}
{% include "privacy_notice/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">{% block form-title %}Enter privacy notice details{% endblock %}</h3>
</div>
<form method="post" action="" class="form-horizontal" enctype="multipart/form-data">
{% csrf_token %}
<div class="box-body">
{% 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="col-sm-6">
<button type="submit" class="btn btn-block btn-success">{% block save-button %}
Add{% endblock %}</button>
</div>
<div class="col-sm-6">
<a href="{% url 'web.views.privacy_notices' %}"
class="btn btn-block btn-default">Cancel</a>
</div>
</div><!-- /.box-footer -->
</form>
</div>
</div>
</div>
{% endblock %}
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script>
{% endblock scripts %}
\ No newline at end of file
<li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li class="active"><a href="{% url 'web.views.privacy_notices' %}">Privacy Notices</a></li>
\ No newline at end of file
{% extends "_base.html" %}
{% load static %}
{% load filters %}
{% block styles %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}"/>
{% endblock styles %}
{% block ui_active_tab %}'subjects'{% endblock ui_active_tab %}
{% block page_header %}Delete privacy notice{% endblock page_header %}
{% block page_description %}{% endblock page_description %}
{% block title %}{{ block.super }} - Delete privacy notice{% endblock %}
{% block breadcrumb %}
{% include "privacy_notice/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Confirm deletion</h3>
</div>
<form action="" method="post" class="form-horizontal">{% csrf_token %}
<div class="box-body">
<p>Are you sure you want to delete privacy notice "{{ object.document.url | basename }}" from Study "{{object.study}}"?</p>
</div><!-- /.box-body -->
<div class="box-footer">
<div class="col-sm-6">
<button type="submit" class="btn btn-block btn-danger">Delete</button>
</div>
<div class="col-sm-6">
<a href="{% url 'web.views.privacy_notices' %}"
class="btn btn-block btn-default">Cancel</a>
</div>
</div><!-- /.box-footer -->
</form>
</div>
</div>
</div>
{% endblock %}
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script>
{% endblock scripts %}
{% extends "privacy_notice/add_edit.html" %}
{% block page_header %}Edit privacy notice "{{ privacy_notice.name }}"{% endblock page_header %}
{% block title %}{{ block.super }} - Edit privacy notice "{{ privacy_notice.name }}"{% endblock %}
{% block form-title %}Enter privacy notice details{% endblock %}
{% block save-button %}Save{% endblock %}
{% extends "_base.html" %}
{% load static %}
{% load filters %}
{% block styles %}
{{ block.super }}
<!-- DataTables -->
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}">
{% endblock styles %}
{% block ui_active_tab %}'privacy_notices'{% endblock ui_active_tab %}
{% block page_header %}Privacy Notices{% endblock page_header %}
{% block page_description %}{% endblock page_description %}
{% block breadcrumb %}
{% include "privacy_notice/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Privacy Notices</h3>
</div>
<div class="box-body">
<div>
<a class="btn btn-app" href="{% url 'web.views.privacy_notice_add' %}">
<i class="fa fa-plus"></i> Add new privacy notice
</a>
</div>
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th>No.</th>
<th>Creation Date</th>
<th>Last Updated</th>
<th>Study</th>
<th>Download</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
{% for privacy_notice in privacy_notices %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ privacy_notice.created_at }}</td>
<td>{{ privacy_notice.updated_at }}</td>
<td>{{ privacy_notice.study }}</td>
<td><a href="{{ privacy_notice.document.url }}"><i class="fa fa-download"></i></a>&nbsp; &nbsp;{{privacy_notice.document.url | basename}}</td>
<td><a href="{% url 'web.views.privacy_notice_edit' privacy_notice.id %}"><i
class="fa fa-edit"></i></a></td>
<td><a href="{% url 'web.views.privacy_notice_delete' privacy_notice.id %}"><i
class="fa fa-trash text-danger"></i></a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script>
<script>
$(function () {
$('#table').DataTable({
"paging": true,
"lengthChange": false,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false
});
});
</script>
{% endblock scripts %}
......@@ -66,6 +66,12 @@
{% endfor %}
</div>
<div>
<a class="btn btn-app" href="{% url 'web.views.mail_template_add' %}">
<i class="fa fa-plus"></i> Add new privacy notice
</a>
</div>
</div><!-- /.box-body -->
<div class="box-header with-border">
......
......@@ -2,7 +2,7 @@
from django import template
from django.forms import CheckboxSelectMultiple, CheckboxInput
from django.utils.safestring import mark_safe
import datetime
import datetime, os
from web.models import ConfigurationItem
from web.models.constants import VISIT_SHOW_VISIT_NUMBER_FROM_ZERO
from distutils.util import strtobool
......@@ -59,4 +59,8 @@ def display_visit_number(visit_number):
if strtobool(visit_from_zero):
return (visit_number - 1)
else:
return visit_number
\ No newline at end of file
return visit_number
@register.filter(name='basename')
def basename(path):
return os.path.basename(path)
\ No newline at end of file
......@@ -161,6 +161,17 @@ urlpatterns = [
url(r'^equipment_and_rooms/rooms/delete/(?P<room_id>\d+)$', views.rooms.rooms_delete,
name='web.views.equipment_and_rooms.rooms_delete'),
####################
# PRIVACY NOTICE #
####################
url(r'^privacy_notices$', views.privacy_notice.PrivacyNoticeListView.as_view(), name='web.views.privacy_notices'),
url(r'^privacy_notices/add$', views.privacy_notice.privacy_notice_add, name='web.views.privacy_notice_add'),
url(r'^privacy_notices/(?P<pk>\d+)/edit$', views.privacy_notice.privacy_notice_edit, name='web.views.privacy_notice_edit'),
url(r'^privacy_notices/(?P<pk>\d+)/delete$', views.privacy_notice.PrivacyNoticeDeleteView.as_view(), name='web.views.privacy_notice_delete'),
####################
# MAIL #
####################
......
......@@ -105,4 +105,5 @@ from . import uploaded_files
from . import study
from . import password
from . import appointment_type
from . import provenance
\ No newline at end of file
from . import provenance
from . import privacy_notice
\ No newline at end of file
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