aboutsummaryrefslogtreecommitdiffstats
path: root/client/views.py
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2021-07-23 18:07:47 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2021-07-23 18:07:59 +0200
commitc5789583a04c435acb460bae050f9387e67527cb (patch)
treeeaa73777353a9669be5c57269cee67e1e35bdf07 /client/views.py
parentexport csv of users or document types (diff)
parentadd notification if user of group capi views document (diff)
downloadscout-subs-c5789583a04c435acb460bae050f9387e67527cb.tar.gz
scout-subs-c5789583a04c435acb460bae050f9387e67527cb.zip
Merge branch 'dev'0.3
Diffstat (limited to '')
-rw-r--r--client/views.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/client/views.py b/client/views.py
index 6f8efb3..73a252a 100644
--- a/client/views.py
+++ b/client/views.py
@@ -1,6 +1,6 @@
from random import randint
from django.contrib.auth.models import Group, Permission, User
-from client.models import UserCode, Keys, DocumentType, Document, PersonalData, KeyVal, MedicalData
+from client.models import GroupSettings, UserCode, Keys, DocumentType, Document, PersonalData, KeyVal, MedicalData
from django.db.models import Q
from django.http import HttpResponseRedirect, FileResponse, HttpResponse
from django.contrib.auth.decorators import login_required
@@ -17,6 +17,7 @@ import pytz
def index(request):
context = {}
+ group_view = False
# check if user is logged
if (request.user.is_authenticated):
if not (request.user.is_staff or request.user.has_perm("client.approved")):
@@ -39,6 +40,19 @@ def index(request):
user_code = "U" + str(usercode.code)
context = {"user_code": user_code}
else:
+ # get user group
+ group = request.user.groups.values_list('name', flat=True)[0]
+
+ # get group settings
+ settings = GroupSettings.objects.filter(group__name=group)
+
+ # check if settings exists
+ if len(settings) == 0:
+ group_view = False
+ else:
+ # set settings value
+ group_view = settings[0].view_documents
+
# user action
if request.method == "POST":
# get document id
@@ -123,6 +137,7 @@ def index(request):
context = {
"docs": out,
"empty": len(out) == 0,
+ "group_view": group_view,
}
return render(request, 'client/index.html', context)