From 40e6c29b4c485b8736e1b7b68cb4f3426ad18a00 Mon Sep 17 00:00:00 2001 From: Artur Borecki Date: Fri, 13 Mar 2026 13:50:36 +0100 Subject: [PATCH] feat(home/models.py): add `EventPage` model --- home/models.py | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/home/models.py b/home/models.py index 1cdb596..978a3bb 100644 --- a/home/models.py +++ b/home/models.py @@ -1,12 +1,17 @@ -from django.contrib.auth.models import Group -from django.forms import CheckboxSelectMultiple +from django import forms +from django.contrib.auth.models import Group, User from django.db import models +from django.forms import CheckboxSelectMultiple from wagtail.admin.panels import FieldPanel -from wagtail.fields import RichTextField +from wagtail.fields import RichTextField, StreamField from wagtail.models import Page from wagtail.models.copying import ParentalManyToManyField +# class EmptyPage(Page): +# pass + + class HomePage(Page): body = RichTextField(blank=True) @@ -65,3 +70,34 @@ class CourseModulePage(Page): return self.title content_panels = Page.content_panels + ["body"] + + +class EventPage(Page): + image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + ) + start = models.DateTimeField() + end = models.DateTimeField() + + # TODO: use google maps here + location = models.CharField(max_length=255, blank=True) + + description = RichTextField(blank=True) + hosts = ParentalManyToManyField( + User, + related_name="hosted_events", + help_text="Select users who will be listed as hosts of this event.", + ) + + content_panels = Page.content_panels + [ + FieldPanel("image"), + FieldPanel("start"), + FieldPanel("end"), + FieldPanel("location"), + FieldPanel("hosts", widget=CheckboxSelectMultiple), + FieldPanel("description"), + ]