From 286161b0912007c6f3859868a006e9818752a4aa Mon Sep 17 00:00:00 2001 From: Dominic DiTaranto Date: Mon, 28 Oct 2024 11:36:09 -0400 Subject: init commit --- web/models.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 web/models.py (limited to 'web/models.py') diff --git a/web/models.py b/web/models.py new file mode 100644 index 0000000..f303552 --- /dev/null +++ b/web/models.py @@ -0,0 +1,38 @@ +from django.contrib import admin +from django.db import models +from django.contrib.auth.models import User + + + +class BaseModel(models.Model): + created_at = models.DateTimeField(blank=True, null=True, auto_now_add=True) + updated_at = models.DateTimeField(blank=True, null=True, auto_now=True) + active = models.BooleanField(default=True) + + class Meta: + abstract = True + + +class Event(BaseModel): + id = models.AutoField(primary_key=True) + name = models.TextField(blank=False, null=False) + start_date = models.DateTimeField(blank=False, null=False) + end_date = models.DateTimeField(blank=False, null=False) + participants = models.IntegerField(blank=False) + + class Meta: + db_table = 'events' + + +class EventAdmin(admin.ModelAdmin): + list_display = ('name', 'start_date', 'end_date', 'active') + + +class Availability(BaseModel): + id = models.AutoField(primary_key=True) + event_id = models.ForeignKey(Event, on_delete=models.CASCADE) + user = models.ForeignKey(User, on_delete=models.CASCADE) + time_table = models.JSONField() + + class Meta: + db_table = 'availabilities' -- cgit v1.2.3-70-g09d2