diff options
-rw-r--r-- | client/templatetags/app_filter.py | 2 | ||||
-rw-r--r-- | server/templates/server/doc_create.html | 7 | ||||
-rw-r--r-- | server/templates/server/doc_creation_preview.html | 121 | ||||
-rw-r--r-- | server/urls.py | 1 | ||||
-rw-r--r-- | server/views.py | 25 | ||||
-rw-r--r-- | version.txt | 2 |
6 files changed, 156 insertions, 2 deletions
diff --git a/client/templatetags/app_filter.py b/client/templatetags/app_filter.py index 1da2aba..aa93cf2 100644 --- a/client/templatetags/app_filter.py +++ b/client/templatetags/app_filter.py @@ -48,7 +48,7 @@ def is_checkbox(str): @register.filter(name="is_heading") def is_heading(str): - return str.startswith("!h") + return str.startswith("!t") @register.filter(name="parse_multiple_choice") def parse_multiple_choice(str): 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à 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à 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):
diff --git a/version.txt b/version.txt index 83dd6d8..9ea1174 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.5 -rev=36 +rev=37 |