2020-12-31 21:17:46 +00:00
|
|
|
from django.db import models
|
2024-06-02 18:27:02 +00:00
|
|
|
from django.core.validators import MinValueValidator, MaxValueValidator
|
2021-01-08 17:32:25 +00:00
|
|
|
|
|
|
|
from multiselectfield import MultiSelectField
|
|
|
|
|
|
|
|
class WeekdayChoices(models.IntegerChoices):
|
|
|
|
MONDAY = 0, "Monday"
|
|
|
|
TUESDAY = 1, "Tuesday"
|
|
|
|
WEDNESDAY = 2, "Wednesday"
|
|
|
|
THURSDAY = 3, "Thursday"
|
|
|
|
FRIDAY = 4, "Friday"
|
|
|
|
SATURDAY = 5, "Saturday"
|
|
|
|
SUNDAY = 6, "Sunday"
|
2020-12-31 21:17:46 +00:00
|
|
|
|
|
|
|
class PercentageField(models.FloatField):
|
2021-01-08 17:32:25 +00:00
|
|
|
default_validators = [MaxValueValidator(100), MinValueValidator(0)]
|
|
|
|
|
|
|
|
class WeekdayField(MultiSelectField):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
self.choices = WeekdayChoices.choices
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
class DayOfMonthField(models.PositiveIntegerField):
|
|
|
|
default_validators = [MinValueValidator(1), MaxValueValidator(31)]
|