2022-07-30 13:58:57 +02:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
# Create your models here.
|
|
|
|
from django.utils import timezone
|
|
|
|
|
|
|
|
|
|
|
|
class TobaccoCategory(models.Model):
|
|
|
|
name = models.CharField(max_length=200, unique=True, blank=False, null=False)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"{self.name} ({self.id})"
|
|
|
|
|
|
|
|
|
|
|
|
class Tobacco(models.Model):
|
|
|
|
name = models.CharField(max_length=200, unique=True, blank=False, null=False)
|
|
|
|
description = models.TextField(blank=True, null=False)
|
|
|
|
category = models.ForeignKey("TobaccoCategory", on_delete=models.CASCADE, blank=False, null=False)
|
2022-08-17 17:13:40 +02:00
|
|
|
in_stock = models.BooleanField(default=True)
|
2022-07-30 13:58:57 +02:00
|
|
|
picture = models.ImageField(upload_to="tobacco_images/", null=False, blank=True)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class EventDate(models.Model):
|
|
|
|
event = models.ForeignKey(to="ClubhausEvent", on_delete=models.CASCADE)
|
|
|
|
date = models.DateTimeField(unique=True, default=timezone.now)
|
|
|
|
|
|
|
|
def __str__(self):
|
2022-07-31 23:17:09 +02:00
|
|
|
return f"{self.event.name} - {self.date.date().isoformat()}"
|
2022-07-30 13:58:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ClubhausEvent(models.Model):
|
|
|
|
name = models.CharField(max_length=200, blank=True)
|
|
|
|
date = models.DateTimeField(blank=True, null=True)
|
2022-07-31 23:17:09 +02:00
|
|
|
active = models.BooleanField(default=False)
|
2022-08-17 17:13:40 +02:00
|
|
|
voting_locked = models.BooleanField(default=False)
|
2022-07-30 13:58:57 +02:00
|
|
|
location = models.TextField(blank=True)
|
|
|
|
beverages = models.TextField(blank=True)
|
|
|
|
food = models.TextField(blank=True)
|
2023-07-24 20:26:54 +02:00
|
|
|
background_picture = models.ForeignKey(to="EventBackground", on_delete=models.DO_NOTHING, blank=True, null=True)
|
2022-07-30 13:58:57 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"{self.name}"
|
2022-07-31 23:17:09 +02:00
|
|
|
|
|
|
|
|
2023-07-24 20:26:54 +02:00
|
|
|
class EventBackground(models.Model):
|
|
|
|
name = models.CharField(max_length=200, blank=True)
|
|
|
|
picture = models.ImageField(upload_to="event_backgrounds/", null=False, blank=True, )
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"{self.name} ({self.id})"
|
|
|
|
|
|
|
|
|
2022-09-04 00:37:02 +02:00
|
|
|
class EventDateVote(models.Model):
|
2022-08-03 02:07:44 +02:00
|
|
|
voter = models.ForeignKey(to="VotingUser", on_delete=models.CASCADE)
|
2022-07-31 23:17:09 +02:00
|
|
|
date = models.ForeignKey(to="EventDate", to_field="date", on_delete=models.CASCADE)
|
2022-08-06 01:09:51 +02:00
|
|
|
available = models.BooleanField()
|
2022-08-03 02:07:44 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
constraints = [
|
|
|
|
models.UniqueConstraint(fields=("voter", "date"), name="unique_voter_day")
|
|
|
|
]
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"{self.voter.name}({self.voter.id}) - {self.date.date.isoformat()}"
|
|
|
|
|
|
|
|
|
|
|
|
class VotingUser(models.Model):
|
|
|
|
name = models.CharField(max_length=200, blank=False)
|
|
|
|
modify_key = models.CharField(max_length=200, blank=False)
|
2022-07-31 23:17:09 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
constraints = [
|
2022-08-03 02:07:44 +02:00
|
|
|
models.UniqueConstraint(fields=("name", "modify_key"), name="unique_name_modify_key")
|
2022-07-31 23:17:09 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
def __str__(self):
|
2022-08-06 01:09:51 +02:00
|
|
|
return f"{self.name} ({self.id})"
|
2022-09-04 00:37:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Setting(models.Model):
|
|
|
|
active = models.BooleanField(default=True)
|
|
|
|
name = models.CharField(max_length=200, default="Default Settings", blank=False)
|
|
|
|
intro_text = models.TextField(blank=True)
|
|
|
|
intro_text_classes = models.CharField(max_length=500, default="text-center fs-5", blank=True,
|
|
|
|
help_text="Extra CSS classes for the div for the intro text like text size")
|
2023-06-29 21:16:04 +02:00
|
|
|
spotify_playlist_url = models.CharField(max_length=500, blank=True,
|
|
|
|
help_text="The link to the Spotify playlist")
|
2022-09-04 00:37:02 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
constraints = [
|
|
|
|
models.UniqueConstraint(fields=("name",), name="unique_name")
|
|
|
|
]
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"{self.id} - {self.name}"
|