diff --git a/backend/planner/admin.py b/backend/planner/admin.py index 8c38f3f..3cee7a6 100644 --- a/backend/planner/admin.py +++ b/backend/planner/admin.py @@ -1,3 +1,20 @@ from django.contrib import admin +from .models import Exam, Subject, Unit -# Register your models here. +class UnitInline(admin.TabularInline): + model = Unit + extra = 1 # Show one extra blank field for new Unit entries + + +class SubjectAdmin(admin.ModelAdmin): + inlines = [UnitInline] # Allows adding Units directly within the Subject admin + list_display = ('name', 'priority', 'exam_date', 'exam') # Display relevant fields + + +class ExamAdmin(admin.ModelAdmin): + list_display = ('name', 'date') # Display relevant fields + + +admin.site.register(Exam, ExamAdmin) +admin.site.register(Subject, SubjectAdmin) +admin.site.register(Unit) diff --git a/backend/planner/migrations/0001_initial.py b/backend/planner/migrations/0001_initial.py new file mode 100644 index 0000000..cb5685b --- /dev/null +++ b/backend/planner/migrations/0001_initial.py @@ -0,0 +1,79 @@ +# Generated by Django 5.1.4 on 2024-12-30 06:25 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="Exam", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=100)), + ("date", models.DateField()), + ], + ), + migrations.CreateModel( + name="Subject", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=100)), + ("priority", models.IntegerField()), + ("exam_date", models.DateField()), + ( + "exam", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="subjects", + to="planner.exam", + ), + ), + ], + ), + migrations.CreateModel( + name="Unit", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=100)), + ("is_completed", models.BooleanField(default=False)), + ( + "subject", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="units", + to="planner.subject", + ), + ), + ], + ), + ] diff --git a/backend/planner/models.py b/backend/planner/models.py index 71a8362..17e7c10 100644 --- a/backend/planner/models.py +++ b/backend/planner/models.py @@ -1,3 +1,28 @@ from django.db import models # Create your models here. +class Exam(models.Model): + name = models.CharField(max_length=100) # Exam name (e.g., Midterms, Finals) + date = models.DateField() # Overall exam date + + def __str__(self): + return self.name + + +class Subject(models.Model): + exam = models.ForeignKey(Exam, on_delete=models.CASCADE, related_name='subjects') + name = models.CharField(max_length=100) # Subject name + priority = models.IntegerField() # Subject priority (e.g., 1 = High, 2 = Medium, etc.) + exam_date = models.DateField() # Subject-specific exam date + + def __str__(self): + return f"{self.name} (Priority: {self.priority})" + + +class Unit(models.Model): + subject = models.ForeignKey(Subject, on_delete=models.CASCADE, related_name='units') + name = models.CharField(max_length=100) # Unit name + is_completed = models.BooleanField(default=False) # Completion status for tracking progress + + def __str__(self): + return f"{self.name} ({'Completed' if self.is_completed else 'Pending'})" diff --git a/backend/planner/templates/planner/welcome.html b/backend/planner/templates/planner/welcome.html new file mode 100644 index 0000000..f6cd65b --- /dev/null +++ b/backend/planner/templates/planner/welcome.html @@ -0,0 +1,15 @@ + + +
+