diff options
Diffstat (limited to 'web/models.py')
-rw-r--r-- | web/models.py | 38 |
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' |