aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--server/templates/server/doc_list.html8
-rw-r--r--server/templates/server/doc_type.html31
-rw-r--r--server/templates/server/index.html12
-rw-r--r--server/templates/server/user_list.html31
-rw-r--r--server/views.py21
5 files changed, 80 insertions, 23 deletions
diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html
index e5be168..fb201d5 100644
--- a/server/templates/server/doc_list.html
+++ b/server/templates/server/doc_list.html
@@ -124,7 +124,7 @@
<li>
<div class="collapsible-header">
<label>
- <input name={{doc.0.id}} type="checkbox" class="filled-in"/>
+ <input name={{doc.0.id}} type="checkbox" class="filled-in allselect"/>
<span></span>
</label>
{% if doc.0.status == "wait" %}
@@ -165,6 +165,8 @@
<i class="material-icons">send</i>{{doc.0.compilation_date}}
</div>
</li>
+ </ul>
+ <ul class="collapsible">
{% if doc.0.document_type.personal_data %}
<li>
<div class="collapsible-header">
@@ -517,11 +519,11 @@ function send(id) {
$('#select-all').click(function(event) {
if(this.checked) {
// Iterate each checkbox
- $(':checkbox').each(function() {
+ $('.allselect').each(function() {
this.checked = true;
});
} else {
- $(':checkbox').each(function() {
+ $('.allselect').each(function() {
this.checked = false;
});
}
diff --git a/server/templates/server/doc_type.html b/server/templates/server/doc_type.html
index e95cef1..82adf83 100644
--- a/server/templates/server/doc_type.html
+++ b/server/templates/server/doc_type.html
@@ -44,7 +44,6 @@
<div class="input-field">
<input autocomplete="off" id="search" type="search" onkeyup="filterResults()" required>
<label class="label-icon" for="search"><i class="material-icons">search</i></label>
- <i class="material-icons">close</i>
</div>
</form>
</li>
@@ -57,6 +56,7 @@
<ul id='dropdown1' class='dropdown-content'>
<li><a Onclick="send('clear')"><i class="material-icons">clear</i>Pulisci</a></li>
<li><a href="#modal1" data-target="modal1" class="modal-trigger"><i class="material-icons">filter_list</i>Filtri</a></li>
+ <li><a href="#modal2" data-target="modal2" class="modal-trigger"><i class="material-icons">search</i>Cerca</a></li>
</ul>
{% endblock %}
@@ -118,19 +118,22 @@
</label>
</div>
</div>
- <div class="row hide-on-large-only">
- <div class="col s12">
- <div class="input-field">
- <input autocomplete="off" id="searchs" type="text" onkeyup="filterResultsSmall()" required>
- <label for="searchs"><i class="material-icons">search</i></label>
- </div>
- </div>
- </div>
</div>
<div class="modal-footer">
<a href="#!" onclick="send('filter')" class="modal-close waves-effect waves-green btn-flat">Applica</a>
</div>
</div>
+<div id="modal2" class="modal">
+ <div class="modal-content">
+ <div class="input-field">
+ <input autocomplete="off" id="searchs" type="text" onkeyup="filterResultsSmall()" required>
+ <label for="searchs"><i class="material-icons">search</i></label>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <a href="#!" class="modal-close waves-effect waves-green btn-flat">Chiudi</a>
+ </div>
+</div>
<input type="hidden" name="action" id="action">
<ul class="collapsible">
@@ -138,7 +141,7 @@
<li>
<div class="collapsible-header list">
<label>
- <input name={{doctype.0.id}} type="checkbox" class="filled-in"/>
+ <input name={{doctype.0.id}} type="checkbox" class="filled-in allselect"/>
<span></span>
</label>
{% if not doctype.0.enabled %}
@@ -179,6 +182,9 @@
</div>
</li>
{% endif %}
+ </ul>
+ {% if doctype.0.custom_data or doctype.0.custom_message %}
+ <ul class="collapsible">
{% if doctype.0.custom_data %}
<li>
<div class="collapsible-header">
@@ -208,6 +214,7 @@
</li>
{% endif %}
</ul>
+ {% endif %}
</span></div>
</li>
{% endfor %}
@@ -241,11 +248,11 @@ function send(id) {
$('#select-all').click(function(event) {
if(this.checked) {
// Iterate each checkbox
- $(':checkbox').each(function() {
+ $('.allselect').each(function() {
this.checked = true;
});
} else {
- $(':checkbox').each(function() {
+ $('.allselect').each(function() {
this.checked = false;
});
}
diff --git a/server/templates/server/index.html b/server/templates/server/index.html
index 2676c3a..a049f4f 100644
--- a/server/templates/server/index.html
+++ b/server/templates/server/index.html
@@ -60,9 +60,21 @@
</ul>
</div>
<div class="card-action">
+ <div class="hide-on-small-only">
<a class="waves-effect waves-light btn red lighten-1" href="{% url 'doctype' %}">Lista tipo doc</a>
<a class="waves-effect waves-light btn red lighten-1" href="{% url 'doclist' %}">Lista documenti</a>
<a class="waves-effect waves-light btn red lighten-1" href="{% url 'docapprove' %}">Approva documento</a>
+ </div>
+
+ <div class="hide-on-med-and-up">
+ <a class="col s12 waves-effect waves-light btn red lighten-1" href="{% url 'doctype' %}">Lista tipo doc</a>
+ <br>
+ <br>
+ <a class="col s12 waves-effect waves-light btn red lighten-1" href="{% url 'doclist' %}">Lista documenti</a>
+ <br>
+ <br>
+ <a class="col s12 waves-effect waves-light btn red lighten-1" href="{% url 'docapprove' %}">Approva documento</a>
+ </div>
</div>
</div>
</div>
diff --git a/server/templates/server/user_list.html b/server/templates/server/user_list.html
index 8ee2008..1010bd4 100644
--- a/server/templates/server/user_list.html
+++ b/server/templates/server/user_list.html
@@ -30,7 +30,6 @@
<div class="input-field">
<input autocomplete="off" id="search" type="search" onkeyup="filterResults()" required>
<label class="label-icon" for="search"><i class="material-icons">search</i></label>
- <i class="material-icons">close</i>
</div>
</form>
</div>
@@ -51,6 +50,30 @@
{{user.0.first_name}} {{user.0.last_name}}
</div>
<div class="collapsible-body"><span>
+ {% if not user.0.is_staff %}
+ <div id="modal{{user.0.id}}" class="modal">
+ <div class="modal-content">
+ <h4>Attenzione</h4>
+ <p>
+ Sei sicuro di volerlere deapprovare l'utente {{user.0.first_name}} {{user.0.last_name}}?<br>
+ Una volta deapprovato l'utente non potrà più creare documenti e per essere riapprovato dovrà essere usato il codice di approvazione.
+ </p>
+ </div>
+ <div class="modal-footer">
+ <a style="color:red" href="#!" class="modal-close waves-effect waves-green btn-flat">Annulla</a>
+ <a onclick="send('d{{user.0.id}}')" class="modal-close waves-effect waves-green btn-flat">Deapprova</a>
+ </div>
+ </div>
+ <a class="waves-effect waves-light btn red lighten-1 modal-trigger" href="#modal{{user.0.id}}"><i class="material-icons left">remove_circle_outline</i>Deapprova utente</a>
+ <br><br>
+ {% endif %}
+ <ul class="collapsible">
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">confirmation_number</i>U{{user.1.code}}
+ </div>
+ </li>
+ </ul>
<ul class="collapsible">
<li>
<div class="collapsible-header">
@@ -292,9 +315,9 @@
{% endblock %}
{% block script %}
-document.addEventListener('DOMContentLoaded', function() {
- var elems = document.querySelectorAll('.collapsible');
- var instances = M.Collapsible.init(elems, {});
+$(document).ready(function(){
+ $('.modal').modal();
+ $('.collapsible').collapsible();
});
function send(id) {
diff --git a/server/views.py b/server/views.py
index e4fea63..e4b70ff 100644
--- a/server/views.py
+++ b/server/views.py
@@ -7,6 +7,7 @@ from django.db.models.deletion import ProtectedError
from django.template.loader import get_template
from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
+from django.contrib.contenttypes.models import ContentType
import dateparser
from datetime import datetime
@@ -80,18 +81,16 @@ def uapprove(request):
data[i] = data[i] + " - Invalido"
else:
user = UserCode.objects.filter(code=data[i][1:])[0].user
+ user.user_permissions.add(permission)
if len(user.groups.values_list('name', flat=True)) == 0:
user.groups.add(group)
- user.user_permissions.add(permission)
data[i] = data[i] + " - Ok"
else:
if user.groups.values_list('name', flat=True)[0] == parent_group:
- user.user_permissions.add(permission)
data[i] = data[i] + " - Ok"
else:
user.groups.clear()
user.groups.add(group)
- user.user_permissions.add(permission)
data[i] = data[i] + " - Ok, cambio branca"
context = {
@@ -163,9 +162,19 @@ def ulist(request):
result.seek(0)
return FileResponse(result, as_attachment=True, filename=document.user.username+"_"+document.document_type.name+".pdf")
+ elif request.POST["action"][0] == 'd':
+ user = User.objects.get(id=request.POST["action"][1:])
+ if user.groups.all()[0] == group:
+ content_type = ContentType.objects.get_for_model(Document)
+ permission = Permission.objects.get(content_type=content_type, codename="approved")
+ user.user_permissions.remove(permission)
+
users = User.objects.filter(groups__name=parent_group).order_by("first_name")
out = []
for user in users:
+ if not user.has_perm("client.approved") and not user.is_staff:
+ continue
+
usercode = UserCode.objects.filter(user=user)[0]
documents = Document.objects.filter(Q(user=user) & ~Q(status='archive') & Q(group__name=parent_group))
vac_file = ""
@@ -345,8 +354,12 @@ def doccreate(request):
name = request.POST["name"]
custom_group = request.POST["custom_group"]
+ if len(DocumentType.objects.filter(name=name)) > 0:
+ context["error"] = "true"
+ context["error_text"] = "Questo nome esiste già. Prego usarne un altro."
+ return render(request, 'server/doc_create.html', context)
+
if custom_group != "":
- print("here")
if custom_group not in request.user.groups.values_list('name', flat=True):
context["error"] = "true"
context["error_text"] = "Non puoi creare un tipo assegnato ad un gruppo di cui non fai parte"