aboutsummaryrefslogtreecommitdiffstats
path: root/client/views.py
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2020-06-18 23:17:08 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2020-06-18 23:17:08 +0200
commitfbb4637a77dc5982b4e694dd31a0aa7d11cec17c (patch)
tree2b277a09a8dacff187211cacfad7da5b5a3dda9b /client/views.py
downloadscout-subs-fbb4637a77dc5982b4e694dd31a0aa7d11cec17c.tar.gz
scout-subs-fbb4637a77dc5982b4e694dd31a0aa7d11cec17c.zip
initial commit
Diffstat (limited to 'client/views.py')
-rw-r--r--client/views.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/client/views.py b/client/views.py
new file mode 100644
index 0000000..5a8f808
--- /dev/null
+++ b/client/views.py
@@ -0,0 +1,32 @@
+from random import randint
+
+from django.shortcuts import render
+
+from .models import UserCode
+
+# Create your views here.
+
+
+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')):
+ users = UserCode.objects.filter(user=request.user)
+ code = None
+ if (len(users) == 0):
+ while (True):
+ code = randint(100000, 999999)
+ if len(UserCode.objects.filter(code=code)) == 0:
+ 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/approve.html', context)
+ else:
+ return render(request, 'client/index.html', context)