Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production merge with hostel status view and improvements #2

Merged
merged 40 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e74f808
Update checkInput interval to 300 milliseconds
Pancham1603 Dec 11, 2023
381e858
added global settings using new app (change timers from admin)
Pancham1603 Dec 11, 2023
022e374
added migrations for global_settings
Pancham1603 Dec 11, 2023
2fb6689
added gender based slots ratio + admin
Pancham1603 Dec 11, 2023
cce3957
Add 'name' field to NightPassAdmin list_display and add 'gender' to l…
Pancham1603 Dec 11, 2023
3acdb7f
Add migration for enabling gender ratio settings
Pancham1603 Dec 11, 2023
7411b65
Add Settings object initialization
Pancham1603 Dec 11, 2023
e21540d
Update import statement for Settings in views.py and check_defaulters.py
Pancham1603 Dec 11, 2023
e4db59d
Update import statement for global_settings module
Pancham1603 Dec 11, 2023
5e8713f
minor bug fix test
Pancham1603 Dec 11, 2023
4c7ae77
minor bug fix test
Pancham1603 Dec 11, 2023
62e07a0
minor bug fix
Pancham1603 Dec 11, 2023
eb5ab96
updating settings at every relevant req
Pancham1603 Dec 11, 2023
a67282b
disabled cancellation aftrer hostel checkout
Pancham1603 Dec 11, 2023
aa8bbb4
Update profile details in info.js
Pancham1603 Dec 12, 2023
fe3ec3d
fixed clear timeout bug
Pancham1603 Dec 12, 2023
1127fa3
bug fixes and SQL explorer
Pancham1603 Dec 12, 2023
76a5ca5
updated requirements
Pancham1603 Dec 12, 2023
f719deb
updated requirements
Pancham1603 Dec 12, 2023
361aa7c
updated requirements
Pancham1603 Dec 12, 2023
68edcb3
Remove unnecessary comments and commands in Dockerfile
Pancham1603 Dec 12, 2023
d12e9b3
removed django-rangefilter
Pancham1603 Dec 12, 2023
7e2a62c
changed date range filter
Pancham1603 Dec 12, 2023
28b9ec1
Update daterange filters to daterangefilter
Pancham1603 Dec 12, 2023
7e21540
Update date range filter package
Pancham1603 Dec 12, 2023
0db2b0c
minor bug fix
Pancham1603 Dec 12, 2023
21f271e
added a basic landing page
Pancham1603 Dec 12, 2023
41e2ae1
Update login button in index.html
Pancham1603 Dec 12, 2023
2923748
Update login form action URL
Pancham1603 Dec 12, 2023
09236d6
added max_allowed_violations
Pancham1603 Dec 13, 2023
731580a
added pwa
Pancham1603 Dec 13, 2023
cdbebd3
Add progressive web app meta tags to HTML templates
Pancham1603 Dec 13, 2023
ef35ba1
removed pwa
Pancham1603 Dec 13, 2023
27d8e06
Remove progressive web app meta tags from lmao.html and info.html
Pancham1603 Dec 13, 2023
5cf418e
Fix violation count comparison in generate_pass function
Pancham1603 Dec 13, 2023
324ae11
added name
Pancham1603 Dec 20, 2023
88d5b37
added basic hostel admin view
Pancham1603 Dec 24, 2023
28259b6
Refactor student container and table layout
Pancham1603 Dec 24, 2023
94b6ca4
modified table
Pancham1603 Dec 25, 2023
1d3613b
modified hostel table
Pancham1603 Dec 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM python:3.8.16

# Install cron
RUN apt-get update && apt-get install -y cron
# RUN apt-get update && apt-get install -y cron

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
Expand All @@ -17,14 +17,14 @@ RUN python -m pip install -r requirements.txt
WORKDIR /app
COPY . /app

# Copy cron job file
COPY cronjob /etc/cron.d/cronjob
# # Copy cron job file
# COPY cronjob /etc/cron.d/cronjob

# Give execution rights on the cron job
RUN chmod 0644 /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
# # 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
Expand Down
Empty file.
5 changes: 5 additions & 0 deletions apps/global_settings/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import Settings

# Register your models here.
admin.site.register(Settings)
6 changes: 6 additions & 0 deletions apps/global_settings/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class GlobalSettingsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.global_settings'
25 changes: 25 additions & 0 deletions apps/global_settings/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.7 on 2023-12-11 22:17

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Settings',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('enable_hostel_timers', models.BooleanField(default=False)),
('frontend_checkin_timer', models.IntegerField(blank=True, default=0, null=True)),
('backend_checkin_timer', models.IntegerField(blank=True, default=0, null=True)),
('last_entry_without_hostel_checkout', models.TimeField(blank=True, null=True)),
('valid_entry_without_hostel_checkout', models.TimeField(blank=True, null=True)),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.7 on 2023-12-11 22:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('global_settings', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='settings',
name='enable_gender_ratio',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='settings',
name='female_ratio',
field=models.FloatField(blank=True, default=0.5, null=True),
),
migrations.AddField(
model_name='settings',
name='male_ratio',
field=models.FloatField(blank=True, default=0.5, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.7 on 2023-12-13 01:37

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('global_settings', '0002_settings_enable_gender_ratio_settings_female_ratio_and_more'),
]

operations = [
migrations.AlterModelOptions(
name='settings',
options={'verbose_name_plural': 'Settings'},
),
migrations.AddField(
model_name='settings',
name='max_violation_count',
field=models.IntegerField(blank=True, default=3, null=True),
),
]
Empty file.
19 changes: 19 additions & 0 deletions apps/global_settings/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.db import models

class Settings(models.Model):

enable_hostel_timers = models.BooleanField(default=False)
frontend_checkin_timer = models.IntegerField(blank=True, null=True, default=0)
backend_checkin_timer = models.IntegerField(blank=True, null=True, default=0)

last_entry_without_hostel_checkout = models.TimeField(blank=True, null=True)
valid_entry_without_hostel_checkout = models.TimeField(blank=True, null=True)

enable_gender_ratio = models.BooleanField(default=False)
male_ratio = models.FloatField(blank=True, null=True, default=0.5)
female_ratio = models.FloatField(blank=True, null=True, default=0.5)

max_violation_count = models.IntegerField(blank=True, null=True, default=3)

class Meta:
verbose_name_plural = 'Settings'
3 changes: 3 additions & 0 deletions apps/global_settings/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions apps/global_settings/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.7 on 2023-12-11 22:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('nightpass', '0002_alter_campusresource_slots_booked'),
]

operations = [
migrations.AddField(
model_name='hostel',
name='backend_checkin_timer',
field=models.IntegerField(blank=True, default=0, null=True),
),
migrations.AddField(
model_name='hostel',
name='frontend_checkin_timer',
field=models.IntegerField(blank=True, default=0, null=True),
),
]
3 changes: 3 additions & 0 deletions apps/nightpass/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class Hostel(models.Model):
contact_number = models.CharField(max_length=15)
email = models.EmailField(max_length=100)

frontend_checkin_timer = models.IntegerField(blank=True, null=True, default=0)
backend_checkin_timer = models.IntegerField(blank=True, null=True, default=0)

def __str__(self):
return self.name

Expand Down
26 changes: 26 additions & 0 deletions apps/nightpass/static/serviceworker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var staticCacheName = 'thapar-nightpass';

self.addEventListener('install', function(event) {
event.waitUntil(
caches.open(staticCacheName).then(function(cache) {
return cache.addAll([
'',
]);
})
);
});

self.addEventListener('fetch', function(event) {
var requestUrl = new URL(event.request.url);
if (requestUrl.origin === location.origin) {
if ((requestUrl.pathname === '/')) {
event.respondWith(caches.match(''));
return;
}
}
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});
56 changes: 55 additions & 1 deletion apps/nightpass/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,61 @@ select {
color: #fff;
}

footer {
background-color: #696b6d;
color: #fff;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}

.custom-table {
width: 100%;
border-collapse: collapse;
}

.custom-table th,
.custom-table td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}

.custom-table th {
background-color: #eb1b23;
color: #fff;
font-weight: bold;
}

.red {
background-color: #d92550;
}

.green {
background-color: #3ac47d;
}

.yellow {
background-color: #f7b924;
}

.badge {
color: white;
padding: 5px 10px;
border-radius: 5px;
}

.table-container {
max-width: 800px; /* Adjust the maximum width as needed */
margin: 10px auto; /* Center the container horizontally */
padding: 20px; /* Add some padding for spacing */
overflow-x: auto; /* Add horizontal scrolling for small screens */
background-color: #fff;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);

}

@media (max-width: 768px) {
.profile-card, .resource-card {
Expand All @@ -246,7 +300,7 @@ select {
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
}

.activity-table {
font-size: 14px;
Expand Down
Binary file added apps/nightpass/static/thapar_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions apps/nightpass/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Thapar NightPass</title>
<script src="https://cdn.jsdelivr.net/npm/jsbarcode@3.11.6/dist/barcodes/JsBarcode.code128.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<link rel="stylesheet" href="../static/styles.css">
</head>
<body>

<div class="header">
<img class="header-logo" src="https://i.imgur.com/gnAYCgT.png" alt="College Logo">
<h1>Thapar NightPass</h1>
<button class="logout-button" onclick="window.location.href = '/logout';">Logout</button>
</div>
{% block content %}
{% endblock %}

<footer>
Made with ♥ by <a href="https://www.linkedin.com/in/pancham1603/" target="_blank" style="text-decoration: underline; color: white;">Pancham Agarwal</a>
</footer>


<script>
toastr.options = {
"closeButton": false,
"newestOnTop": true,
"progressBar": false,
"positionClass": "toast-top-right",
"preventDuplicates": true,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "3000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
</script>

{% if messages %}
{% for message in messages %}
<script>
toastr.info("{{ message }}")
</script>
{% endfor %}
{% endif %}
</body>
</html>
41 changes: 41 additions & 0 deletions apps/nightpass/templates/caretaker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% extends 'base.html' %}

{% block content %}
<div class="table-container">
<div class="table-responsive">
<table class="custom-table">
<thead>
<tr>
<th>Name</th>
<th>Room No</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{% for pass in hostel_passes %}
<tr>
<td>{{ pass.user.student.name }}</td>
<td>{{ pass.user.student.room_number }}</td>
{% if pass.user.student.is_checked_in %}
<td><span class="badge green">Checked In</span></td>
{% else %}
{% if pass %}
{% if pass.check_in and not pass.check_out %}
<td><span class="badge yellow">{{ pass.campus_resource }}</span></td>
{% else %}
<td><span class="badge red">Outside</span></td>
{% endif %}
{% else %}
<td><span class="badge red">Outside</span></td>
{% endif %}
{% endif %}
<td><a href="tel:{{ pass.user.student.contact_number }}"><button>Call</button></td>
</tr>
{% endfor %}
</tbody>
</table>

</div>
</div>
{% endblock %}
Loading
Loading