diff options
author | Andrea Lepori <aleporia@gmail.com> | 2023-04-08 13:30:40 +0200 |
---|---|---|
committer | Andrea Lepori <aleporia@gmail.com> | 2023-04-08 13:30:41 +0200 |
commit | 4f7b869d4d401b904fb7f7816960d0ba4fd9599e (patch) | |
tree | 8edaaba0fca0d1ee9966f2c09c659ceefde707c7 | |
parent | update copyright year and data protection (diff) | |
download | scout-subs-4f7b869d4d401b904fb7f7816960d0ba4fd9599e.tar.gz scout-subs-4f7b869d4d401b904fb7f7816960d0ba4fd9599e.zip |
fix group name check instead of obj
-rw-r--r-- | server/views.py | 18 | ||||
-rw-r--r-- | version.txt | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/server/views.py b/server/views.py index 0ba3f63..2be7966 100644 --- a/server/views.py +++ b/server/views.py @@ -233,13 +233,13 @@ def docapprove(request): messages.append(data[i] + " - Formato errato")
elif Document.objects.filter(code=data[i]).count() == 0:
messages.append(data[i] + " - Invalido")
- elif Document.objects.filter(code=data[i])[0].group.name not in groups:
+ elif Document.objects.filter(code=data[i])[0].group not in groups:
# check if user has permission to approve document
messages.append(data[i] + " - Invalido")
else:
document = Document.objects.filter(code=data[i])[0]
- if document.group.name not in groups:
+ if document.group not in groups:
return
if document.status != 'wait' and document.status != 'ok':
@@ -265,14 +265,14 @@ def docapprove(request): elif Document.objects.filter(code=data).count() == 0:
error_text = "Codice invalido"
error = True
- elif Document.objects.filter(code=data)[0].group.name not in groups:
+ elif Document.objects.filter(code=data)[0].group not in groups:
error_text = "Codice invalido"
error = True
else:
# get document
document = Document.objects.filter(code=data)[0]
- if document.group.name not in groups:
+ if document.group not in groups:
return
if document.status != 'wait' and document.status != 'ok':
@@ -342,7 +342,7 @@ def approve_direct(request): return
# check if user has permission to approve document
- if document.group.name not in groups:
+ if document.group not in groups:
return
document.status = "ok"
@@ -370,7 +370,7 @@ def approve_direct(request): return render(request, 'server/approve_doc_direct.html', {"error": "Questo documento non รจ in attesa di approvazione"})
# check if user has permission to approve document
- if document.group.name not in groups:
+ if document.group not in groups:
return render(request, 'server/approve_doc_direct.html', {"error": "Non hai il permesso di approvare questo documento"})
return render(request, 'server/approve_doc_direct.html', {"doc": document})
@@ -1637,7 +1637,7 @@ def docpreview(request): # get document
document = Document.objects.filter(code=code)[0]
- doc_group = document.group.name
+ doc_group = document.group
parent_group = document.user.groups.values_list('name', flat=True)[0]
# user has not permission to view document
@@ -1689,7 +1689,7 @@ def data_request(request): context["data"] = data
elif request.POST["request"] == "data_user":
perm = Permission.objects.get(codename="approved")
- users = User.objects.filter(groups__name=parent_group, user_permissions=perm)
+ users = User.objects.filter(groups=parent_group, user_permissions=perm)
# get time for filename
current_time = datetime.strftime(datetime.now(), "%H_%M__%d_%m_%y")
@@ -1737,7 +1737,7 @@ def data_request(request): elif request.POST["request"] == "data_user_medic":
perm = Permission.objects.get(codename="approved")
- users = User.objects.filter(groups__name=parent_group, user_permissions=perm)
+ users = User.objects.filter(groups=parent_group, user_permissions=perm)
# get time for filename
current_time = datetime.strftime(datetime.now(), "%H_%M__%d_%m_%y")
diff --git a/version.txt b/version.txt index 709ff2e..68a0f2d 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.6 -rev=19 +rev=20 |