-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02ab6bb
commit 3d44c44
Showing
5 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>StudySphere</title> | ||
</head> | ||
<body> | ||
<h1>Welcome to StudySphere</h1> | ||
<h2>Subjects:</h2> | ||
<ul> | ||
{% for subject in subjects %} | ||
<li>{{ subject.name }} (Priority: {{ subject.priority }})</li> | ||
{% endfor %} | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from django.shortcuts import render | ||
from django.http import HttpResponse | ||
|
||
from .models import Subject | ||
# Create your views here. | ||
|
||
def welcome(request): | ||
return HttpResponse("<h1>Welcome to StudySphere!</h1>") | ||
subjects = Subject.objects.all() | ||
return render(request, 'planner/welcome.html', {'subjects': subjects}) |