diff options
author | Andrea Lepori <alepori@student.ethz.ch> | 2021-08-18 15:35:53 +0200 |
---|---|---|
committer | Andrea Lepori <alepori@student.ethz.ch> | 2021-08-18 15:36:45 +0200 |
commit | 90efbc392d911605fdfe81a5e2634b72fd76474c (patch) | |
tree | 7c42330de0a4c0e7e9f9b3b1fb4c74e58a45af32 /server | |
parent | set default key and use secure cookies (diff) | |
download | scout-subs-90efbc392d911605fdfe81a5e2634b72fd76474c.tar.gz scout-subs-90efbc392d911605fdfe81a5e2634b72fd76474c.zip |
correct primary group on doc export
Diffstat (limited to '')
-rw-r--r-- | server/templates/server/index.html | 2 | ||||
-rw-r--r-- | server/views.py | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/server/templates/server/index.html b/server/templates/server/index.html index d8a13f2..a6c25aa 100644 --- a/server/templates/server/index.html +++ b/server/templates/server/index.html @@ -56,6 +56,7 @@ {% endif %} <div class="card large"> <div class="card-content"> + {% if user.is_staff %} <form id="form" action="{% url 'server'%}" method="post"> {% csrf_token %} <div class="row"> @@ -73,6 +74,7 @@ </div> </div> </form> + {% endif %} <ul class="collection"> {% for doctype in docs %} <li class="collection-item"> diff --git a/server/views.py b/server/views.py index 6f35d9e..d598f93 100644 --- a/server/views.py +++ b/server/views.py @@ -67,7 +67,7 @@ def index(request): doc_view_check = 'checked="checked"'
# check if changing settings
- if request.method == "POST":
+ if request.method == "POST" and request.user.is_staff:
if "doc_view" in request.POST:
settings.view_documents = True
settings.save()
@@ -255,7 +255,7 @@ def ulist(request): # get template and build context
template = get_template('server/download_doc.html')
doc = [document, KeyVal.objects.filter(
- container=document), document.personal_data, document.medical_data, parent_group]
+ container=document), document.personal_data, document.medical_data, document.user.groups.values_list('name', flat=True)[0]]
context = {'doc': doc, 'vac': vac_file,
'health': health_file, 'sign_doc_file': sign_doc_file}
# render context
@@ -928,7 +928,7 @@ def doclist(request): # build with template and render
template = get_template('server/download_doc.html')
doc = [document, KeyVal.objects.filter(
- container=document), document.personal_data, document.medical_data, parent_group]
+ container=document), document.personal_data, document.medical_data, document.user.groups.values_list('name', flat=True)[0]]
context = {'doc': doc, 'vac': vac_file,
'health': health_file, 'sign_doc_file': sign_doc_file}
html = template.render(context)
@@ -1053,6 +1053,7 @@ def doclist(request): documents = documents.filter(q_obj)
out = []
+ users = []
for i in documents:
# filter for confirmed with attachment documents and approved
if signdoc:
@@ -1082,11 +1083,14 @@ def doclist(request): out.append([i, KeyVal.objects.filter(container=i), personal,
medical, doc_group, vac_file, health_file, sign_doc_file])
+ users.append(i.user)
# get types and users for chips autocompletation
- auto_types = DocumentType.objects.filter(
- Q(group_private=False) | Q(group=group))
- users = User.objects.filter(groups__name=parent_group)
+ if request.user.is_staff:
+ auto_types = DocumentType.objects.filter(
+ Q(group_private=False) | Q(group=group))
+ else:
+ auto_types = DocumentType.objects.filter(Q(group_private=False))
context = {
"types": auto_types,
@@ -1212,7 +1216,7 @@ def doclist_readonly(request): # build with template and render
template = get_template('server/download_doc.html')
doc = [document, KeyVal.objects.filter(
- container=document), document.personal_data, document.medical_data, parent_group]
+ container=document), document.personal_data, document.medical_data, document.user.groups.values_list('name', flat=True)[0]]
context = {'doc': doc, 'vac': vac_file,
'health': health_file, 'sign_doc_file': sign_doc_file}
html = template.render(context)
|