From d5f2bde318a1e4d824bb9d08f42b1849e3d3790a Mon Sep 17 00:00:00 2001 From: raghav_dhir Date: Sat, 22 Aug 2020 23:34:02 +0530 Subject: [PATCH 1/3] added security views --- swd/gate_security/views.py | 31 +++++++++++++++++++++++++++++-- swd/templates/gate_security.html | 14 ++++++++++---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/swd/gate_security/views.py b/swd/gate_security/views.py index 0cd0e71e..08df628a 100644 --- a/swd/gate_security/views.py +++ b/swd/gate_security/views.py @@ -1,8 +1,35 @@ from django.shortcuts import render +from .models import SecurityLeave +from main.models import * + # Create your views here. def gate_security(request): - - return render(request, "gate_security.html") + leaves = Leave.objects.filter(approved=True) + daypasss = DayPass.objects.filter(approved=True) + context = {} + found_leave = False + if request.POST: + username = request.POST.get('username') + for leave in leaves: + if username in leave.student.bitsId: + student = leave.student + found_leave = True + context = { + 'student': student, + 'leave': leave, + 'found_leave': found_leave + } + for daypass in daypasss: + if username in daypass.student.bitsId: + student = daypass.student + found_daypass = True + context = { + 'student': student, + 'daypass': daypass, + 'found_daypass': found_daypass, + 'found_leave': found_leave + } + return render(request, "gate_security.html", context) diff --git a/swd/templates/gate_security.html b/swd/templates/gate_security.html index fdcfe618..d1397257 100644 --- a/swd/templates/gate_security.html +++ b/swd/templates/gate_security.html @@ -46,7 +46,7 @@
- + {% if student %}

Student Details


@@ -60,18 +60,24 @@
- {{ student.name }} Dummy name
- {{ student.bitsId }} Dummy ID
- Dummy Phone Number + {{ student.name }}
+ {{ student.bitsId }}
+ {{ student.phone }}
+ {% if found_leave %}
Dummy active leaves + {% endif %}
+ {% if found_daypass %} Dummy active daypasses + {% endif %}

+ Look for other student
+ {% endif %} From ab39fcd44ccdd5cca82ce4ce09e963d28ac6a566 Mon Sep 17 00:00:00 2001 From: raghav_dhir Date: Sun, 23 Aug 2020 02:49:42 +0530 Subject: [PATCH 2/3] Improved dummy text and model import --- swd/gate_security/views.py | 3 +-- swd/templates/gate_security.html | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/swd/gate_security/views.py b/swd/gate_security/views.py index 08df628a..7780958a 100644 --- a/swd/gate_security/views.py +++ b/swd/gate_security/views.py @@ -1,6 +1,5 @@ from django.shortcuts import render -from .models import SecurityLeave -from main.models import * +from main.models import Leave, DayPass # Create your views here. diff --git a/swd/templates/gate_security.html b/swd/templates/gate_security.html index d1397257..089d7d32 100644 --- a/swd/templates/gate_security.html +++ b/swd/templates/gate_security.html @@ -66,11 +66,11 @@
{% if found_leave %} -
Dummy active leaves +
Click to activate Leave {% endif %}
{% if found_daypass %} - Dummy active daypasses + Click to activate DayPass {% endif %}
From 6ca5a48547e1efd884284c212c90470a8d6eaf2e Mon Sep 17 00:00:00 2001 From: raghav_dhir Date: Wed, 26 Aug 2020 20:27:08 +0530 Subject: [PATCH 3/3] Activate Buttons --- swd/gate_security/views.py | 6 ++++++ swd/main/models.py | 2 ++ swd/templates/gate_security.html | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/swd/gate_security/views.py b/swd/gate_security/views.py index 7780958a..6eb007a2 100644 --- a/swd/gate_security/views.py +++ b/swd/gate_security/views.py @@ -15,6 +15,9 @@ def gate_security(request): if username in leave.student.bitsId: student = leave.student found_leave = True + if '1' in 'activate1': + leave.activated = True + leave.save() context = { 'student': student, 'leave': leave, @@ -24,6 +27,9 @@ def gate_security(request): if username in daypass.student.bitsId: student = daypass.student found_daypass = True + if '2' in 'activate2': + daypass.activated = True + daypass.save() context = { 'student': student, 'daypass': daypass, diff --git a/swd/main/models.py b/swd/main/models.py index d42d460f..88fea849 100644 --- a/swd/main/models.py +++ b/swd/main/models.py @@ -271,6 +271,7 @@ class Leave(models.Model): disapproved = models.BooleanField(default=0, blank=True) inprocess = models.BooleanField(default=1, blank=True) comment = models.TextField(default='', blank=True) + activated = models.BooleanField(default='False', blank=True) def __str__(self): return self.student.bitsId + ' '+ self.student.name + ' ' + str(self.id) @@ -293,6 +294,7 @@ def document_path(instance, filename): inprocess = models.BooleanField(default=1, blank=True) comment = models.TextField() document = models.FileField(upload_to=document_path, null=True, blank=True) + activated = models.BooleanField(default='False', blank=True) def __str__(self): return self.student.bitsId + ' (' + self.student.name + ')' diff --git a/swd/templates/gate_security.html b/swd/templates/gate_security.html index 089d7d32..be401780 100644 --- a/swd/templates/gate_security.html +++ b/swd/templates/gate_security.html @@ -66,11 +66,11 @@
{% if found_leave %} -
Click to activate Leave +
Click to activate Leave {% endif %}
{% if found_daypass %} - Click to activate DayPass + Click to activate DayPass {% endif %}
@@ -83,6 +83,7 @@
+