39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
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'
|