diff --git a/.gitignore b/.gitignore
index 7c1e2fa..afe85b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,7 +61,6 @@ local_settings.py
db.sqlite3
db.sqlite3-journal
staticfiles
-static
*.xlsx
*.csv
*.xls
@@ -165,8 +164,4 @@ cython_debug/
#.idea/
-#dockerfiles
-*.yml
-*.yaml
-Dockerfile
-*.sh
+
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..5eb2890
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,35 @@
+# For more information, please refer to https://aka.ms/vscode-docker-python
+FROM python:3.8.16
+
+# Install cron
+RUN apt-get update && apt-get install -y cron
+
+# Keeps Python from generating .pyc files in the container
+ENV PYTHONDONTWRITEBYTECODE=1
+
+# Turns off buffering for easier container logging
+ENV PYTHONUNBUFFERED=1
+
+# Install pip requirements
+COPY requirements.txt .
+RUN python -m pip install -r requirements.txt
+
+WORKDIR /app
+COPY . /app
+
+# Copy cron job file
+COPY cronjob /etc/cron.d/cronjob
+
+# Give execution rights on the cron job
+RUN chmod 0644 /etc/cron.d/cronjob
+
+# Create the log file to be able to run tail
+RUN touch /var/log/cron.log
+
+# Creates a non-root user with an explicit UID and adds permission to access the /app folder
+# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
+# RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
+USER root
+
+# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
+CMD ["sh", "run.sh"]
\ No newline at end of file
diff --git a/apps/nightpass/management/__init__.py b/apps/nightpass/management/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/apps/nightpass/management/commands/__init__.py b/apps/nightpass/management/commands/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/apps/nightpass/management/commands/reset_campus_resources.py b/apps/nightpass/management/commands/reset_campus_resources.py
new file mode 100644
index 0000000..af48b72
--- /dev/null
+++ b/apps/nightpass/management/commands/reset_campus_resources.py
@@ -0,0 +1,10 @@
+from django.core.management.base import BaseCommand
+from ...models import CampusResource
+
+class Command(BaseCommand):
+ help = 'Reset all campus resources'
+
+ def handle(self, *args, **options):
+ self.stdout.write(self.style.SUCCESS('Running your cron job...'))
+ CampusResource.objects.all().update(slots_booked=0, booking_complete=False, is_booking = False)
+ self.stdout.write(self.style.SUCCESS('Cron job completed successfully'))
\ No newline at end of file
diff --git a/apps/nightpass/management/commands/stop_booking.py b/apps/nightpass/management/commands/stop_booking.py
new file mode 100644
index 0000000..e7927d3
--- /dev/null
+++ b/apps/nightpass/management/commands/stop_booking.py
@@ -0,0 +1,10 @@
+from django.core.management.base import BaseCommand
+from ...models import CampusResource
+
+class Command(BaseCommand):
+ help = 'Stop booking for all campus resources'
+
+ def handle(self, *args, **options):
+ self.stdout.write(self.style.SUCCESS('Running your cron job...'))
+ CampusResource.objects.all().update(is_booking=False, booking_complete=True)
+ self.stdout.write(self.style.SUCCESS('Cron job completed successfully'))
\ No newline at end of file
diff --git a/apps/nightpass/migrations/0002_alter_campusresource_slots_booked.py b/apps/nightpass/migrations/0002_alter_campusresource_slots_booked.py
new file mode 100644
index 0000000..76168fc
--- /dev/null
+++ b/apps/nightpass/migrations/0002_alter_campusresource_slots_booked.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.7 on 2023-12-03 06:14
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('nightpass', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='campusresource',
+ name='slots_booked',
+ field=models.IntegerField(default=0, editable=False),
+ ),
+ ]
diff --git a/apps/nightpass/models.py b/apps/nightpass/models.py
index 324d83f..ed42976 100644
--- a/apps/nightpass/models.py
+++ b/apps/nightpass/models.py
@@ -1,6 +1,8 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.db import models
+from django.db.models.signals import post_save
+from django.dispatch import receiver
class Hostel(models.Model):
@@ -21,12 +23,9 @@ class CampusResource(models.Model):
is_booking = models.BooleanField(default=False)
is_display = models.BooleanField(default=False)
booking_complete = models.BooleanField(default=False)
- slots_booked = models.IntegerField(default=0)
+ slots_booked = models.IntegerField(default=0, editable=False)
type = models.CharField(max_length=100, choices=[('hostel', 'Hostel'), ('location', 'Location'), ('gate', 'Gate')], null=True, blank=True)
def __str__(self):
- return self.name
-
-
-
+ return self.name
\ No newline at end of file
diff --git a/apps/nightpass/static/styles.css b/apps/nightpass/static/styles.css
new file mode 100644
index 0000000..f2ea7b0
--- /dev/null
+++ b/apps/nightpass/static/styles.css
@@ -0,0 +1,258 @@
+body {
+ font-family: Arial, sans-serif;
+ background-color: #f5f5f5;
+ margin: 0;
+ padding: 0;
+ line-height: 1.6;
+}
+
+.header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ background-color: #eb1b23;
+ color: #fff;
+ text-align: center;
+ padding: 2px; /* Reduced header padding */
+}
+
+.header-logo {
+ width: 100px; /* Set the width of your college logo */
+ height: auto; /* Maintain aspect ratio */
+}
+
+.logout-button {
+ background-color: #fff;
+ color: #eb1b23;
+ border: none;
+ padding: 5px 10px;
+ border-radius: 5px;
+ cursor: pointer;
+ transition: background-color 0.2s;
+ margin-right: 20px;
+}
+
+.logout-button:hover {
+ background-color: #ccc;
+}
+
+.container {
+ display: flex;
+ flex-wrap: nowrap;
+ justify-content: center;
+ align-items: center;
+}
+
+
+.profile-card, .resource-card {
+ background-color: #fff;
+ border-radius: 10px;
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
+ margin: 20px;
+ width: 300px;
+ text-align: center;
+ padding: 20px;
+ transition: transform 0.2s;
+}
+
+.profile-card:hover, .resource-card:hover {
+ transform: scale(1.05);
+}
+
+.profile-img {
+ width: 100px;
+ border-radius: 50%;
+ object-fit: cover;
+ margin-bottom: 20px;
+}
+
+.qr-code {
+ width: 100px;
+ height: 100px;
+ margin-bottom: 20px;
+}
+
+.profile-details {
+ font-size: 18px;
+ margin-bottom: 20px;
+ text-align: left;
+}
+
+.profile-details p {
+ margin-bottom: 10px;
+}
+
+.safe {
+ color: green;
+}
+
+.unsafe {
+ color: red;
+}
+
+.book-button {
+ background-color: #eb1b23;
+ color: #fff;
+ border: none;
+ padding: 10px 20px;
+ border-radius: 10px;
+ cursor: pointer;
+ transition: background-color 0.2s;
+}
+
+.booked {
+ background-color: grey;
+}
+
+.book-button:hover {
+ background-color: #ff3336;
+}
+
+.modal {
+ display: none;
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0, 0, 0, 0.5);
+}
+
+.modal-content {
+ background-color: #fff;
+ width: 80%;
+ max-width: 400px;
+ margin: 20% auto;
+ padding: 20px;
+ border-radius: 5px;
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
+ text-align: center;
+ position: relative;
+ display: flex;
+}
+
+.modal-image {
+ flex: 1;
+}
+
+.modal-image img {
+ width: 100%;
+ height: auto;
+ object-fit: cover;
+}
+
+.modal-details {
+ flex: 2;
+ padding: 10px;
+ text-align: left;
+}
+
+/* Close button for the modal */
+.close {
+ position: absolute;
+ top: 10px;
+ right: 10px;
+ cursor: pointer;
+}
+
+.modal-button {
+ background-color: #eb1b23;
+ color: #fff;
+ border: none;
+ padding: 10px 20px;
+ border-radius: 10px;
+ cursor: pointer;
+ transition: background-color 0.2s;
+}
+
+.modal-button:hover {
+ background-color: #ff3336;
+}
+
+select {
+ width: 100%;
+ padding: 10px;
+ margin: 10px 0;
+}
+.resource-card {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: space-between;
+}
+.resource-card img {
+ width: 100px;
+ height: 100px;
+ object-fit: cover;
+ border-radius: 5px;
+ margin-right: 5px;
+}
+.resource-details {
+ flex: 1;
+ padding: 10px;
+ text-align: left;
+}
+.resource-details h2 {
+ margin: 0;
+}
+.resource-details p {
+ margin: 0;
+}
+.location-cards
+{
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ align-items: center;
+}
+
+.table-section {
+ margin-top: 10px;
+ overflow-x: auto;
+ /* Add horizontal scroll for small screens */
+}
+
+.activity-table {
+ width: 100%;
+ max-width: 100%; /* Set a maximum width for the table */
+ border-collapse: collapse;
+ margin-top: 20px;
+ white-space: nowrap; /* Prevent text wrapping */
+ overflow: hidden;
+}
+
+.activity-table th, .activity-table td {
+ border: 1px solid #ddd;
+ padding: 8px;
+ text-align: left;
+ overflow: hidden;
+ text-overflow: ellipsis; /* Display ellipsis for overflowed text */
+ white-space: wrap;
+}
+
+.activity-table th {
+ background-color: #eb1b23;
+ color: #fff;
+}
+
+
+
+@media (max-width: 768px) {
+ .profile-card, .resource-card {
+ width: 90%;
+ }
+ .container {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ align-items: center;
+}
+
+ .activity-table {
+ font-size: 14px;
+ }
+
+ .activity-table th, .activity-table td {
+ padding: 5px;
+ }
+}
diff --git a/apps/nightpass/templates/change_list.html b/apps/nightpass/templates/change_list.html
new file mode 100644
index 0000000..f5617c3
--- /dev/null
+++ b/apps/nightpass/templates/change_list.html
@@ -0,0 +1,8 @@
+{% extends "admin/change_list.html" %}
+
+{% block object-tools %}
+ {{ block.super }}
+
+{% endblock %}
diff --git a/apps/nightpass/templates/defaulter_email.html b/apps/nightpass/templates/defaulter_email.html
new file mode 100644
index 0000000..9aebd84
--- /dev/null
+++ b/apps/nightpass/templates/defaulter_email.html
@@ -0,0 +1,105 @@
+
+
+
+
+
+ Default Warning
+
+
+
+
+
Thapar NightPass: Incident Logged
+
+ Dear {{ user_pass.user.student.name }},
+
+
+ This is to inform you that an incident has been recorded for your recent actions. Please review and address this matter promptly. Further incidents may lead to revocation of the NightPass facility .
+
+
+ Incident Remark: {{ defaulter_remarks}}
+
+
+
+
+ Date
+ {{ user_pass.date }}
+
+
+ Location
+ {{ user_pass.campus_resource.name }}
+
+
+ Hostel Check Out
+ {{ user_pass.hostel_checkout_time }}
+
+
+ {{ user_pass.campus_resource.name }} Check In
+ {{ user_pass.check_in_time }}
+
+
+ {{ user_pass.campus_resource.name }} Check Out
+ {{ user_pass.check_out_time }}
+
+
+ Hostel Check In
+ {{ user_pass.hostel_checkin_time }}
+
+
+
+ If you have any questions or concerns, please contact the Office of the Dean of Student Affairs.
+
+
+ DoSA Office
+ TIET, Patiala
+
+
+
+
diff --git a/apps/nightpass/templates/lmao.html b/apps/nightpass/templates/lmao.html
index 49fcef3..f189660 100644
--- a/apps/nightpass/templates/lmao.html
+++ b/apps/nightpass/templates/lmao.html
@@ -8,223 +8,7 @@
-
+