From 1fd05ff0a5cf92f6f84229efc4069f9246dbfc89 Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Sat, 27 Jul 2019 11:21:29 +0530 Subject: [PATCH] fix: codacy --- frappe/desk/doctype/event/event.py | 6 +++--- frappe/desk/doctype/event/event_list.js | 2 +- frappe/patches/v12_0/rename_events_repeat_on.py | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/frappe/desk/doctype/event/event.py b/frappe/desk/doctype/event/event.py index 7873a0a6fd..b1306b432e 100644 --- a/frappe/desk/doctype/event/event.py +++ b/frappe/desk/doctype/event/event.py @@ -22,12 +22,12 @@ class Event(Document): if not self.starts_on: self.starts_on = now_datetime() - 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 + 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): frappe.throw(_("Daily Events should finish on the Same Day.")) diff --git a/frappe/desk/doctype/event/event_list.js b/frappe/desk/doctype/event/event_list.js index b71d88e6d2..5d73d9dd1a 100644 --- a/frappe/desk/doctype/event/event_list.js +++ b/frappe/desk/doctype/event/event_list.js @@ -1,6 +1,6 @@ frappe.listview_settings['Event'] = { add_fields: ["starts_on", "ends_on"], - onload: function(listview) { + onload: function() { frappe.route_options = { "status": "Open" }; diff --git a/frappe/patches/v12_0/rename_events_repeat_on.py b/frappe/patches/v12_0/rename_events_repeat_on.py index b78bf33f19..789610e14d 100644 --- a/frappe/patches/v12_0/rename_events_repeat_on.py +++ b/frappe/patches/v12_0/rename_events_repeat_on.py @@ -19,9 +19,7 @@ def execute(): frappe.db.set_value("Event", daily_event.name, "repeat_on", "Weekly") for weekly_event in weekly_events: - """ - Set WeekDay based on the starts_on so that event can repeat Weekly - """ + # Set WeekDay based on the starts_on so that event can repeat Weekly frappe.db.set_value("Event", weekly_event.name, "repeat_on", "Weekly") frappe.db.set_value("Event", weekly_event.name, weekdays[get_datetime(weekly_event.starts_on).weekday()], 1)