Update event.py

This commit is contained in:
Himanshu 2019-07-27 15:45:55 +05:30 committed by GitHub
parent ac87ebc3ae
commit b3d2d10c22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,7 +28,7 @@ class Event(Document):
if self.starts_on and self.ends_on:
self.validate_from_to_dates("starts_on", "ends_on")
if self.repeat_on == "Daily" and getdate(self.starts_on) != getdate(self.ends_on):
if self.repeat_on == "Daily" and self.ends_on and getdate(self.starts_on) != getdate(self.ends_on):
frappe.throw(_("Daily Events should finish on the Same Day."))
def on_update(self):
@ -194,6 +194,7 @@ def get_events(start, end, user=None, for_reminder=False, filters=None):
AND `tabDocShare`.user=%(user)s
)
)
AND `tabEvent`.status='Open'
ORDER BY `tabEvent`.starts_on""".format(
filter_condition=get_filters_cond('Event', filters, []),
reminder_condition="AND coalesce(`tabEvent`.send_reminder, 0)=1" if for_reminder else ""
@ -317,4 +318,4 @@ def set_status_of_events():
if (event.ends_on and getdate(event.ends_on) < getdate(nowdate())) \
or (event.repeat_till and getdate(event.repeat_till) < getdate(nowdate())):
frappe.db.set_value("Event", event.name, "status", "Closed")
frappe.db.set_value("Event", event.name, "status", "Closed")