fix: validate dates only if starts_on and ends_on

This commit is contained in:
Himanshu Warekar 2019-07-26 20:48:45 +05:30
parent 421e4eebeb
commit cabb3f314b

View file

@ -22,7 +22,8 @@ class Event(Document):
if not self.starts_on:
self.starts_on = now_datetime()
self.validate_from_to_dates("starts_on", "ends_on")
if self.starts_on and self.ends_on:
self.validate_from_to_dates("starts_on", "ends_on")
# if start == end this scenario doesn't make sense i.e. it starts and ends at the same second!
self.ends_on = None if self.starts_on == self.ends_on else self.ends_on