Skip to content

Commit

Permalink
Merge from Pancham1603/production
Browse files Browse the repository at this point in the history
all production features and updates added
  • Loading branch information
Pancham1603 authored Dec 9, 2023
2 parents 2f6869f + 6e5ab52 commit b3c6c44
Show file tree
Hide file tree
Showing 38 changed files with 1,806 additions and 453 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ local_settings.py
db.sqlite3
db.sqlite3-journal
staticfiles
static
*.xlsx
*.csv
*.xls
Expand Down Expand Up @@ -165,8 +164,4 @@ cython_debug/
#.idea/


#dockerfiles
*.yml
*.yaml
Dockerfile
*.sh

35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions apps/nightpass/management/commands/reset_campus_resources.py
Original file line number Diff line number Diff line change
@@ -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'))
10 changes: 10 additions & 0 deletions apps/nightpass/management/commands/stop_booking.py
Original file line number Diff line number Diff line change
@@ -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'))
Original file line number Diff line number Diff line change
@@ -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),
),
]
9 changes: 4 additions & 5 deletions apps/nightpass/models.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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
258 changes: 258 additions & 0 deletions apps/nightpass/static/styles.css
Original file line number Diff line number Diff line change
@@ -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;
}
}
8 changes: 8 additions & 0 deletions apps/nightpass/templates/change_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "admin/change_list.html" %}

{% block object-tools %}
{{ block.super }}
<div class="actions">
<a href="{% url 'admin:your_app_name_your_model_name_custom_action' %}" class="button">Refresh Slot Count</a>
</div>
{% endblock %}
Loading

0 comments on commit b3c6c44

Please sign in to comment.