summaryrefslogtreecommitdiff
path: root/web/models.py
diff options
context:
space:
mode:
authorDominic DiTaranto <domdit@gmail.com>2024-10-28 11:36:09 -0400
committerDominic DiTaranto <domdit@gmail.com>2024-10-28 11:36:09 -0400
commit286161b0912007c6f3859868a006e9818752a4aa (patch)
treed016592f7fa38b93f15e818586a9d294d80b6f3c /web/models.py
init commit
Diffstat (limited to 'web/models.py')
-rw-r--r--web/models.py38
1 files changed, 38 insertions, 0 deletions
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'