fix event end default
This commit is contained in:
@@ -302,14 +302,16 @@ class Event(Post):
|
|||||||
verbose_name_plural = "Events"
|
verbose_name_plural = "Events"
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if self.event_end is None or self.event_start is None:
|
if not self.event_start:
|
||||||
raise ValidationError(_("Das Datum des Events fehlt."))
|
raise ValidationError(_("Das Datum des Events fehlt."))
|
||||||
if self.event_end < self.event_start:
|
if self.event_end and self.event_end < self.event_start:
|
||||||
raise ValidationError(_("Das Ende des Events liegt vor dem Beginn."))
|
raise ValidationError(_("Das Ende des Events liegt vor dem Beginn."))
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.post_type:
|
if not self.post_type:
|
||||||
self.post_type = "E"
|
self.post_type = "E"
|
||||||
|
if not self.event_end:
|
||||||
|
self.event_end = self.event_start + timedelta(hours=2)
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user