aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2022-03-23 19:24:09 +0100
committerAndrea Lepori <alepori@student.ethz.ch>2022-03-23 19:24:21 +0100
commit7dfc0383561cb9f13282e7779b919f5b17859f86 (patch)
treed2f3ed554dfd259025845c7f93e02254e1a8beb3 /client
parentinitial support of user switcher (diff)
parentin case of error redirect to home page (diff)
downloadscout-subs-7dfc0383561cb9f13282e7779b919f5b17859f86.tar.gz
scout-subs-7dfc0383561cb9f13282e7779b919f5b17859f86.zip
Merge branch 'master' into dev
Diffstat (limited to 'client')
-rw-r--r--client/migrations/0014_auto_20220111_1503.py38
-rw-r--r--client/models.py10
-rw-r--r--client/templates/client/approve_doc_pdf.html5
-rw-r--r--client/templates/client/doc_create.html18
-rw-r--r--client/templates/client/doc_edit.html14
-rw-r--r--client/templates/client/index.html2
-rw-r--r--client/views.py16
7 files changed, 81 insertions, 22 deletions
diff --git a/client/migrations/0014_auto_20220111_1503.py b/client/migrations/0014_auto_20220111_1503.py
new file mode 100644
index 0000000..99c7c18
--- /dev/null
+++ b/client/migrations/0014_auto_20220111_1503.py
@@ -0,0 +1,38 @@
+# Generated by Django 3.1.4 on 2022-01-11 14:03
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('client', '0013_keys_key_extra'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='documenttype',
+ name='custom_message_text',
+ field=models.CharField(default='', max_length=2048),
+ ),
+ migrations.AlterField(
+ model_name='keys',
+ name='key',
+ field=models.CharField(db_index=True, max_length=2048),
+ ),
+ migrations.AlterField(
+ model_name='keys',
+ name='key_extra',
+ field=models.CharField(default='', max_length=2048),
+ ),
+ migrations.AlterField(
+ model_name='keyval',
+ name='key',
+ field=models.CharField(db_index=True, max_length=2048),
+ ),
+ migrations.AlterField(
+ model_name='keyval',
+ name='value',
+ field=models.CharField(db_index=True, max_length=2048),
+ ),
+ ]
diff --git a/client/models.py b/client/models.py
index cd3cf88..e01fe1f 100644
--- a/client/models.py
+++ b/client/models.py
@@ -15,7 +15,7 @@ class DocumentType(models.Model):
medical_data = models.BooleanField(default=False)
custom_data = models.BooleanField(default=False)
custom_message = models.BooleanField(default=False)
- custom_message_text = models.CharField(default="", max_length=250)
+ custom_message_text = models.CharField(default="", max_length=2048)
staff_only = models.BooleanField(default=False)
max_instances = models.IntegerField(default=0)
name = models.CharField(default="", max_length=250)
@@ -88,15 +88,15 @@ class Document(models.Model):
class KeyVal(models.Model):
container = models.ForeignKey(
Document, db_index=True, on_delete=models.CASCADE)
- key = models.CharField(max_length=240, db_index=True)
- value = models.CharField(max_length=240, db_index=True)
+ key = models.CharField(max_length=2048, db_index=True)
+ value = models.CharField(max_length=2048, db_index=True)
class Keys(models.Model):
container = models.ForeignKey(
DocumentType, db_index=True, on_delete=models.CASCADE)
- key = models.CharField(max_length=240, db_index=True)
- key_extra = models.CharField(max_length=1024, default="")
+ key = models.CharField(max_length=2048, db_index=True)
+ key_extra = models.CharField(max_length=2048, default="")
class UserCode(models.Model):
diff --git a/client/templates/client/approve_doc_pdf.html b/client/templates/client/approve_doc_pdf.html
index 3ed4d86..db1478e 100644
--- a/client/templates/client/approve_doc_pdf.html
+++ b/client/templates/client/approve_doc_pdf.html
@@ -29,15 +29,12 @@
<br>
<br>
Inoltre accetto e prendo nota della seguente clausula aggiuntiva: <br>
- {{doc.document_type.custom_message_text}}
+ {{doc.document_type.custom_message_text | linebreaksbr}}
{% endif %}
</p>
</div>
</div>
<br><br><br><br>
- <br><br><br><br>
- <br><br><br><br>
- <br><br><br><br>
<div class="row">
<div class="col s4 offset-s1">
<div class="input-field">
diff --git a/client/templates/client/doc_create.html b/client/templates/client/doc_create.html
index ce5f39d..71bdbbe 100644
--- a/client/templates/client/doc_create.html
+++ b/client/templates/client/doc_create.html
@@ -98,9 +98,9 @@
<div class="row">
<div class="col s12">
<div class="card {{color}}">
- <div class="card-content">
- <p style="color:white"><b>
- {{custom_message_text}}
+ <div class="card-content" style="color:white">
+ <p><b>
+ {{custom_message_text | linebreaksbr}}
</b></p>
</div>
</div>
@@ -135,6 +135,18 @@
{% endif %}
<div class="row">
<div class="col s12">
+ <div class="card red">
+ <div class="card-content">
+ <p style="color:white"><b>
+ Attenzione: il documento non sarĂ  valido fino a quando non viene approvato. Selezionare
+ il documento dalla pagina principale per approvarlo.
+ </b></p>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
<br>
<a class="btn waves-effect waves-light {{color}}" onclick="window.history.back();" >
<i class="material-icons left">navigate_before</i>Indietro
diff --git a/client/templates/client/doc_edit.html b/client/templates/client/doc_edit.html
index a9cc056..40deb26 100644
--- a/client/templates/client/doc_edit.html
+++ b/client/templates/client/doc_edit.html
@@ -56,7 +56,7 @@
<div class="card {{color}}">
<div class="card-content">
<p style="color:white"><b>
- {{custom_message_text}}
+ {{custom_message_text | linebreaksbr}}
</b></p>
</div>
</div>
@@ -98,6 +98,18 @@
{% endif %}
<div class="row">
<div class="col s12">
+ <div class="card red">
+ <div class="card-content">
+ <p style="color:white"><b>
+ Attenzione: il documento non sarĂ  valido fino a quando non viene approvato. Selezionare
+ il documento dalla pagina principale per approvarlo.
+ </b></p>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
<br>
<a class="btn waves-effect waves-light {{color}}" onclick="window.history.back();" >
<i class="material-icons left">navigate_before</i>Indietro
diff --git a/client/templates/client/index.html b/client/templates/client/index.html
index e31ce34..1885dd1 100644
--- a/client/templates/client/index.html
+++ b/client/templates/client/index.html
@@ -76,7 +76,7 @@
<br>
<br>
Inoltre accetto e prendo nota della seguente clausula aggiuntiva: <br>
- {{doc.document_type.custom_message_text}}
+ {{doc.document_type.custom_message_text | linebreaksbr}}
{% endif %}
<br>
<br>
diff --git a/client/views.py b/client/views.py
index 04ebaf9..086c1ba 100644
--- a/client/views.py
+++ b/client/views.py
@@ -61,10 +61,10 @@ def index(request):
# check if document is valid to modify
if document.user != request.user:
- return
+ return HttpResponseRedirect("/")
if document.status == "ok" or document.status == "archive":
- return
+ return HttpResponseRedirect("/")
# execute action
if request.POST["action"][0] == 'f':
@@ -184,22 +184,22 @@ def create(request):
if document_type.max_instances != 0:
if len(Document.objects.filter(document_type=document_type)) - len(Document.objects.filter(document_type=document_type, status="archive")) >= document_type.max_instances:
# there aren't user is cheating
- return
+ return HttpResponseRedirect("/")
# check if user has permission to use that type
if document_type.staff_only and not request.user.is_staff and "capi" not in request.user.groups.values_list('name', flat = True):
# user is cheating abort
- return
+ return HttpResponseRedirect("/")
if not document_type.custom_group and document_type.group.name not in request.user.groups.values_list('name', flat=True):
# user is cheating abort
- return
+ return HttpResponseRedirect("/")
# get list of docs with that type
current_docs = Document.objects.filter(user=request.user).filter(document_type=document_type)
if len(current_docs) > 0:
# if there is already a document with that type abort (user is cheating)
- return
+ return HttpResponseRedirect("/")
# set default values
code = 0
@@ -267,12 +267,12 @@ def edit_wrapper(request, context):
# check if user has permission
if document.user != request.user:
- return
+ return HttpResponseRedirect("/")
# check if document is editable
if document.status != "wait" and document.status != "autosign":
# user is cheating
- return
+ return HttpResponseRedirect("/")
# update compilation date
document.compilation_date = pytz.timezone('Europe/Zurich').localize(datetime.now())