Skip to content

Commit

Permalink
Merge pull request #51 from ria2003/my-new-branch
Browse files Browse the repository at this point in the history
Hostel Allocation System
  • Loading branch information
ianshulx authored Jan 24, 2025
2 parents 0734adb + e7c1348 commit be3c448
Show file tree
Hide file tree
Showing 40 changed files with 1,450 additions and 0 deletions.
Empty file.
16 changes: 16 additions & 0 deletions HostelAllocation/HostelAllocation/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for HostelAllocation project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'HostelAllocation.settings')

application = get_asgi_application()
104 changes: 104 additions & 0 deletions HostelAllocation/HostelAllocation/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
"""
Django settings for HostelAllocation project.
Generated by 'django-admin startproject' using Django 5.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""

from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

SECRET_KEY = 'django-insecure-==_5grwpnkip%-=y(opao5%#y56_(eb*1he(t3g32h)#bou(!d'

DEBUG = True

ALLOWED_HOSTS = []

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'hostel'
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'HostelAllocation.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'HostelAllocation.wsgi.application'


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


STATIC_URL = '/static/'

STATICFILES_DIRS = [
BASE_DIR / 'hostel' / 'static'
]


DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
28 changes: 28 additions & 0 deletions HostelAllocation/HostelAllocation/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
URL configuration for HostelAllocation project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView

urlpatterns = [
path('admin/', admin.site.urls),
path('hostel/', include('hostel.urls')),
path('', RedirectView.as_view(url='/hostel/login/', permanent=False)),
]



16 changes: 16 additions & 0 deletions HostelAllocation/HostelAllocation/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for HostelAllocation project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'HostelAllocation.settings')

application = get_wsgi_application()
Empty file.
3 changes: 3 additions & 0 deletions HostelAllocation/hostel/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions HostelAllocation/hostel/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class HostelConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'hostel'
Empty file.
Empty file.
64 changes: 64 additions & 0 deletions HostelAllocation/hostel/management/commands/populate_students.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from hostel.models import Student

class Command(BaseCommand):
help = "Delete existing student records and populate new students with real names and CET marks"

def handle(self, *args, **kwargs):
Student.objects.all().delete()

User.objects.exclude(username='rector').delete()

students_data = [
{"name": "Aarav", "student_id": "S1", "category": "open", "cet_marks": 85},
{"name": "Vihaan", "student_id": "S2", "category": "open", "cet_marks": 78},
{"name": "Arjun", "student_id": "S3", "category": "open", "cet_marks": 92},
{"name": "Sai", "student_id": "S4", "category": "open", "cet_marks": 65},
{"name": "Ishaan", "student_id": "S5", "category": "open", "cet_marks": 88},
{"name": "Aditi", "student_id": "S6", "category": "open", "cet_marks": 90},
{"name": "Kavya", "student_id": "S7", "category": "open", "cet_marks": 79},
{"name": "Arnav", "student_id": "S8", "category": "open", "cet_marks": 81},
{"name": "Riya", "student_id": "S9", "category": "open", "cet_marks": 74},
{"name": "Vansh", "student_id": "S10", "category": "open", "cet_marks": 77},
{"name": "Krishna", "student_id": "S11", "category": "open", "cet_marks": 82},
{"name": "Niharika", "student_id": "S12", "category": "open", "cet_marks": 84},
{"name": "Yash", "student_id": "S13", "category": "open", "cet_marks": 69},
{"name": "Ananya", "student_id": "S14", "category": "open", "cet_marks": 80},
{"name": "Aditya", "student_id": "S15", "category": "open", "cet_marks": 76},
{"name": "Priya", "student_id": "S16", "category": "reserved", "cet_marks": 86},
{"name": "Rahul", "student_id": "S17", "category": "reserved", "cet_marks": 75},
{"name": "Sneha", "student_id": "S18", "category": "reserved", "cet_marks": 89},
{"name": "Neha", "student_id": "S19", "category": "reserved", "cet_marks": 64},
{"name": "Rohan", "student_id": "S20", "category": "reserved", "cet_marks": 72},
{"name": "Maya", "student_id": "S21", "category": "reserved", "cet_marks": 71},
{"name": "Isha", "student_id": "S22", "category": "reserved", "cet_marks": 82},
{"name": "Shivam", "student_id": "S23", "category": "reserved", "cet_marks": 65},
{"name": "Aarvi", "student_id": "S24", "category": "reserved", "cet_marks": 78},
{"name": "Karan", "student_id": "S25", "category": "reserved", "cet_marks": 74},
{"name": "Deepa", "student_id": "S26", "category": "reserved", "cet_marks": 70},
{"name": "Vikram", "student_id": "S27", "category": "reserved", "cet_marks": 69},
{"name": "Meera", "student_id": "S28", "category": "reserved", "cet_marks": 72},
{"name": "Ravi", "student_id": "S29", "category": "reserved", "cet_marks": 68},
{"name": "Pooja", "student_id": "S30", "category": "reserved", "cet_marks": 73},
]

for data in students_data:
user = User.objects.create(username=data["name"].lower())
user.set_password("student@vjti")
user.save()

Student.objects.create(
user=user,
student_id=data["student_id"],
name=data["name"],
category=data["category"],
cet_marks=data["cet_marks"],
)

rector_user, created = User.objects.get_or_create(username="rector")
if created:
rector_user.set_password("rectorpass")
rector_user.save()

self.stdout.write(self.style.SUCCESS("Successfully deleted existing records and populated new students with CET marks, and created a rector account."))
37 changes: 37 additions & 0 deletions HostelAllocation/hostel/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 5.1.2 on 2024-11-03 12:39

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Student',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('student_id', models.CharField(max_length=10, unique=True)),
('category', models.CharField(choices=[('open', 'Open'), ('reserved', 'Reserved')], max_length=10)),
('cet_marks', models.IntegerField()),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Allocation',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('allocated_seat', models.BooleanField(default=False)),
('allocated_date', models.DateField(auto_now_add=True)),
('student', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='hostel.student')),
],
),
]
Empty file.
17 changes: 17 additions & 0 deletions HostelAllocation/hostel/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db import models
from django.contrib.auth.models import User

class Student(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
name = models.CharField(max_length=100)
student_id = models.CharField(max_length=10, unique=True)
category = models.CharField(max_length=10, choices=[('open', 'Open'), ('reserved', 'Reserved')])
cet_marks = models.IntegerField()

def __str__(self):
return f"{self.name} ({self.student_id})"

class Allocation(models.Model):
student = models.OneToOneField(Student, on_delete=models.CASCADE)
allocated_seat = models.BooleanField(default=False)
allocated_date = models.DateField(auto_now_add=True)
97 changes: 97 additions & 0 deletions HostelAllocation/hostel/static/css/allocate_seats.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
display: flex;
}

header {
background-color: #4CAF50;
color: white;
padding: 15px 20px;
text-align: center;
flex: 0 0 100%;
}

.sidebar {
background-color: #333;
color: white;
width: 200px;
height: 100vh;
padding: 15px;
position: fixed;
}

.sidebar ul {
list-style: none;
padding: 0;
}

.sidebar ul li {
margin: 10px 0;
}

.sidebar ul li a {
color: white;
text-decoration: none;
font-weight: bold;
}

.sidebar ul li a:hover {
text-decoration: underline;
}

main {
padding: 20px;
margin-left: 220px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
max-width: 800px;
}

h1, h2 {
color: #333;
}

form {
margin-bottom: 20px;
}

button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-right: 10px;
}

button:hover {
background-color: #45a049;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}

table, th, td {
border: 1px solid #ddd;
}

th, td {
padding: 12px;
text-align: left;
}

tr:nth-child(even) {
background-color: #f2f2f2;
}

tr:hover {
background-color: #ddd;
}
Loading

0 comments on commit be3c448

Please sign in to comment.