aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2022-08-06 21:46:44 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2022-08-06 21:46:44 +0200
commit15a57cbb39634b42bec54d9c88d20611e0780b31 (patch)
treeaf2f5e7a146c070c5bd1688cd84cbbbabb28d728 /server
parentfix incorect parsing of approval code (diff)
downloadscout-subs-15a57cbb39634b42bec54d9c88d20611e0780b31.tar.gz
scout-subs-15a57cbb39634b42bec54d9c88d20611e0780b31.zip
fix heading prefix and add custom param preview
Diffstat (limited to '')
-rw-r--r--server/templates/server/doc_create.html7
-rw-r--r--server/templates/server/doc_creation_preview.html121
-rw-r--r--server/urls.py1
-rw-r--r--server/views.py25
4 files changed, 154 insertions, 0 deletions
diff --git a/server/templates/server/doc_create.html b/server/templates/server/doc_create.html
index 43b98e9..908d1eb 100644
--- a/server/templates/server/doc_create.html
+++ b/server/templates/server/doc_create.html
@@ -149,6 +149,7 @@
<div class="input-field col s12">
<textarea name="custom" id="param" class="materialize-textarea"></textarea>
<label for="param">Lista parametri personalizzati, uno per riga</label>
+ <a onclick="preview()" class="waves-effect waves-light btn {{color}}">Visualizza anteprima</a>
</div>
</div>
<div class="row">
@@ -196,4 +197,10 @@ $(document).ready(function(){
{% endif %}
$('.modal').modal();
});
+
+function preview() {
+ var param = document.getElementById("param").value;
+ var param_base64 = btoa(param);
+ window.open("{%url 'custom_parameters_preview' %}?param=" + param_base64);
+}
{% endblock %} \ No newline at end of file
diff --git a/server/templates/server/doc_creation_preview.html b/server/templates/server/doc_creation_preview.html
new file mode 100644
index 0000000..811b9ad
--- /dev/null
+++ b/server/templates/server/doc_creation_preview.html
@@ -0,0 +1,121 @@
+{% extends 'registration/base_client.html' %}
+
+{% block title %}Preview iscrizione{% endblock %}
+
+{% block breadcrumb %}
+ <a href="#!" class="breadcrumb hide-on-med-and-down">Preview Iscrizione</a>
+{% endblock %}
+
+{% load app_filter %}
+
+{% block content %}
+<div class="row">
+ <div class="col l8 offset-l2 s12">
+ <div class="card-panel">
+ <div class="row">
+ <div class="input-field col s12">
+ <select>
+ <option disabled selected>Iscrizione dimostrativa</option>
+ </select>
+ <label>Iscrizione</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <div class="card {{color}}">
+ <div class="card-content">
+ <p style="color:white"><b>
+ Il documento conterr&agrave; le informazioni personali, prego verificare che siano corrette e aggiornate
+ </b></p>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <div class="card {{color}}">
+ <div class="card-content">
+ <p style="color:white"><b>
+ Il documento conterr&agrave; le informazioni mediche, prego verificare che siano corrette e aggiornate
+ </b></p>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <div class="card {{color}}">
+ <div class="card-content" style="color:white">
+ <p><b>
+ Testo personalizzato d'esempio. <br>
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed accumsan auctor lobortis. Etiam eu felis ac elit semper vestibulum. Praesent pharetra ex quam. Ut sed magna nec eros viverra blandit nec eget nisl. Cras maximus efficitur urna, eget semper dui commodo a. Fusce eros sem, condimentum eu dignissim eget, pharetra vulputate odio.
+ </b></p>
+ </div>
+ </div>
+ </div>
+ </div>
+ {% for key in keys %}
+ {% if key.key_extra|is_heading %}
+ <div class="row">
+ <div class="input-field col s12">
+ <h6>{{key.key_extra|parse_heading}}</h6>
+ </div>
+ </div>
+ {% elif key.key_extra|is_multiple_choice %}
+ <div class="row">
+ <div class="col s12">
+ {% with arr=key.key_extra|parse_multiple_choice %}
+ {{arr.0}}
+ {% for val in arr.1 %}
+ <p><label>
+ <input class="with-gap" name="{{key.id}}" value="{{val}}" type="radio"/>
+ <span>{{val}}</span>
+ </label></p>
+ {% endfor %}
+ {% endwith %}
+ </div>
+ </div>
+ {% elif key.key_extra|is_checkbox %}
+ checkbox
+ {% else %}
+ <div class="row">
+ <div class="input-field col s12">
+ <input value="" name="{{key.id}}" id="{{key.id}}" type="text">
+ <label for="{{key.id}}">{{key.key}}</label>
+ </div>
+ </div>
+ {% endif %}
+ {% endfor %}
+ <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}}">
+ <i class="material-icons left">navigate_before</i>Indietro
+ </a>
+ <a class="btn waves-effect waves-light {{color}}">Crea
+ <i class="material-icons right">create</i>
+ </a>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+{% endblock %}
+
+{% block script %}
+$(document).ready(function(){
+ $('select').formSelect();
+});
+{% endblock %} \ No newline at end of file
diff --git a/server/urls.py b/server/urls.py
index 5ff9eba..42bc0c8 100644
--- a/server/urls.py
+++ b/server/urls.py
@@ -15,6 +15,7 @@ urlpatterns = [
path('docapprove', views.docapprove, name='docapprove'),
path('docupload', views.upload_doc, name='docupload'),
path('docpreview', views.docpreview, name='docpreview'),
+ path('custom_parameters_preview', views.custom_parameters_preview, name='custom_parameters_preview'),
path('progress', views.get_progress, name='progress'),
path('request', views.data_request, name='request'),
path('media/<int:id>/<str:t>/<str:flag>', views.media_request, name='media'),
diff --git a/server/views.py b/server/views.py
index 7643bee..35fb232 100644
--- a/server/views.py
+++ b/server/views.py
@@ -610,6 +610,31 @@ def doctype(request):
}
return render(request, 'server/doc_type.html', context)
+@user_passes_test(isStaff)
+def custom_parameters_preview(request):
+ context = {}
+ if "param" not in request.GET:
+ return render(request, 'server/doc_creation_preview.html', context)
+
+ params = request.GET["param"]
+ params = base64.b64decode(params).decode("utf-8")
+ params = params.splitlines()
+ keys = []
+ for i in range(len(params)):
+ dic = {}
+ val = params[i]
+ if val.startswith("!"):
+ if len(val) < 3:
+ val = val
+
+ val = val[3:].split(",")[0]
+ dic["key"] = val
+ dic["key_extra"] = params[i]
+ dic["id"] = i
+ keys.append(dic)
+
+ context["keys"] = keys
+ return render(request, 'server/doc_creation_preview.html', context)
@user_passes_test(isStaff)
def doccreate(request):