-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
27 lines (24 loc) · 1.37 KB
/
models.py
File metadata and controls
27 lines (24 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from core.models import BaseAbstractModel
from django.core.exceptions import ValidationError
from django.db import models
from user.models import Organization
class Event(BaseAbstractModel):
organization = models.ForeignKey(Organization, on_delete=models.PROTECT, related_name="events")
name = models.CharField(max_length=256, null=True, blank=True)
banner_image = models.TextField(null=True, blank=True)
slogan = models.CharField(max_length=1000, null=True, blank=True)
description = models.CharField(max_length=1000, null=True, blank=True)
event_start_at = models.DateTimeField(null=True, blank=True)
event_end_at = models.DateTimeField(null=True, blank=True)
banner_display_start_at = models.DateTimeField(null=True, blank=True)
banner_display_end_at = models.DateTimeField(null=True, blank=True)
def clean(self) -> None:
super().clean()
if self.event_start_at and self.event_end_at and self.event_start_at > self.event_end_at:
raise ValidationError("event의 종료 날짜는 시작 날짜보다 이전일 수 없습니다.")
if (
self.banner_display_start_at
and self.banner_display_end_at
and self.banner_display_start_at > self.banner_display_end_at
):
raise ValidationError("banner 전시 종료 날짜는 시작 날짜보다 이전일 수 없습니다.")