aboutsummaryrefslogtreecommitdiffstats
path: root/client/views.py
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2020-06-19 15:05:59 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2020-06-19 15:05:59 +0200
commit619e0e0f5263875b753334483d9b896194e9a61d (patch)
tree861b970de54b77ad715aa9d4177eaaad384c198a /client/views.py
parentinitial commit (diff)
downloadscout-subs-619e0e0f5263875b753334483d9b896194e9a61d.tar.gz
scout-subs-619e0e0f5263875b753334483d9b896194e9a61d.zip
More data for users
Diffstat (limited to '')
-rw-r--r--client/views.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/client/views.py b/client/views.py
index 5a8f808..96eb977 100644
--- a/client/views.py
+++ b/client/views.py
@@ -9,12 +9,7 @@ from .models import UserCode
def index(request):
context = {}
- return render(request, 'client/index.html', context)
-
-
-def approve(request):
- context = {}
- if not (request.user.is_staff or request.user.has_perm('approved')):
+ if (request.user.is_authenticated):
users = UserCode.objects.filter(user=request.user)
code = None
if (len(users) == 0):
@@ -24,9 +19,17 @@ def approve(request):
break
userCode = UserCode(user=request.user, code=code)
userCode.save()
- else:
- code = UserCode.objects.filter(user=request.user)[0].code
- context = {'code': 'U' + str(code), }
+ return render(request, 'client/index.html', context)
+
+
+def approve(request):
+ context = {}
+ if not (request.user.is_staff or request.user.has_perm('approved')):
+ usercode = UserCode.objects.filter(user=request.user)[0]
+ okay = False
+ if request.user.first_name != "" and request.user.last_name != "" and request.user.email != "" and len(request.user.groups.values_list('name', flat=True)) != 0:
+ okay = True
+ context = {'code': 'U' + str(usercode.code), 'okay': okay}
return render(request, 'client/approve.html', context)
else:
return render(request, 'client/index.html', context)