diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index a5ed392..9759da7 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index e061640..9e26940 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 5a69659..f73949b 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 2a36fd6..f2e321d 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 8c38f3f..6a2fb67 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,3 +1,21 @@ from django.contrib import admin +from .models import School, Event, Registration -# Register your models here. +@admin.register(School) +class SchoolAdmin(admin.ModelAdmin): + list_display = ('name', 'slug', 'created_at') + prepopulated_fields = {'slug': ('name',)} + search_fields = ('name',) + +@admin.register(Event) +class EventAdmin(admin.ModelAdmin): + list_display = ('title', 'school', 'event_type', 'start_date', 'is_published') + list_filter = ('school', 'event_type', 'is_published') + search_fields = ('title', 'description', 'location') + date_hierarchy = 'start_date' + +@admin.register(Registration) +class RegistrationAdmin(admin.ModelAdmin): + list_display = ('user', 'event', 'registered_at', 'attended') + list_filter = ('event', 'attended') + search_fields = ('user__username', 'event__title') \ No newline at end of file diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py new file mode 100644 index 0000000..5f7d492 --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,57 @@ +# Generated by Django 5.2.7 on 2026-01-31 10:14 + +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='School', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('slug', models.SlugField(blank=True, unique=True)), + ('description', models.TextField(blank=True)), + ('logo_url', models.URLField(blank=True, help_text='URL to the school logo', null=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ], + ), + migrations.CreateModel( + name='Event', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=255)), + ('description', models.TextField()), + ('event_type', models.CharField(choices=[('assembly', 'Assembly'), ('field_trip', 'Field Trip'), ('parent_teacher', 'Parent-Teacher Night'), ('sports', 'Sports Event'), ('performance', 'Performance/Arts'), ('other', 'Other')], default='other', max_length=50)), + ('start_date', models.DateTimeField()), + ('end_date', models.DateTimeField()), + ('location', models.CharField(max_length=255)), + ('capacity', models.PositiveIntegerField(default=100)), + ('is_published', models.BooleanField(default=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='events', to='core.school')), + ], + ), + migrations.CreateModel( + name='Registration', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('registered_at', models.DateTimeField(auto_now_add=True)), + ('attended', models.BooleanField(default=False)), + ('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='registrations', to='core.event')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'unique_together': {('event', 'user')}, + }, + ), + ] diff --git a/core/migrations/__pycache__/0001_initial.cpython-311.pyc b/core/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000..f20e64e Binary files /dev/null and b/core/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 71a8362..af1c1ba 100644 --- a/core/models.py +++ b/core/models.py @@ -1,3 +1,53 @@ from django.db import models +from django.conf import settings +from django.utils.text import slugify -# Create your models here. +class School(models.Model): + name = models.CharField(max_length=255) + slug = models.SlugField(unique=True, blank=True) + description = models.TextField(blank=True) + logo_url = models.URLField(blank=True, null=True, help_text="URL to the school logo") + created_at = models.DateTimeField(auto_now_add=True) + + def save(self, *args, **kwargs): + if not self.slug: + self.slug = slugify(self.name) + super().save(*args, **kwargs) + + def __str__(self): + return self.name + +class Event(models.Model): + EVENT_TYPES = [ + ('assembly', 'Assembly'), + ('field_trip', 'Field Trip'), + ('parent_teacher', 'Parent-Teacher Night'), + ('sports', 'Sports Event'), + ('performance', 'Performance/Arts'), + ('other', 'Other'), + ] + school = models.ForeignKey(School, on_delete=models.CASCADE, related_name='events') + title = models.CharField(max_length=255) + description = models.TextField() + event_type = models.CharField(max_length=50, choices=EVENT_TYPES, default='other') + start_date = models.DateTimeField() + end_date = models.DateTimeField() + location = models.CharField(max_length=255) + capacity = models.PositiveIntegerField(default=100) + is_published = models.BooleanField(default=True) + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return f"{self.title} ({self.school.name})" + +class Registration(models.Model): + event = models.ForeignKey(Event, on_delete=models.CASCADE, related_name='registrations') + user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) + registered_at = models.DateTimeField(auto_now_add=True) + attended = models.BooleanField(default=False) + + class Meta: + unique_together = ('event', 'user') + + def __str__(self): + return f"{self.user.username} - {self.event.title}" \ No newline at end of file diff --git a/core/templates/base.html b/core/templates/base.html index 1e7e5fb..ffab868 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -3,23 +3,78 @@
-