diff options
Diffstat (limited to '')
-rw-r--r-- | server/templates/server/index.html | 2 | ||||
-rw-r--r-- | server/views.py | 18 | ||||
-rw-r--r-- | version.txt | 2 |
3 files changed, 14 insertions, 8 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)
diff --git a/version.txt b/version.txt index 414f793..05d2f8e 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.3 -rev=6 +rev=7 |