# HG changeset patch # User Paul Boddie # Date 1423432357 -3600 # Node ID b96e527e13d4f88c7a4c74b07305bf11b3a66b35 # Parent e243f4e62c42a1ed15a1963b54994dc96fba9ff9 Changed the object editing process to propagate and show errors, and not to attempt to update events without an action being performed. diff -r e243f4e62c42 -r b96e527e13d4 htdocs/styles.css --- a/htdocs/styles.css Sun Feb 08 22:33:11 2015 +0100 +++ b/htdocs/styles.css Sun Feb 08 22:52:37 2015 +0100 @@ -67,6 +67,10 @@ color: #009; } +.error { + background-color: #faa; +} + /* Selection of slots/periods for new events. */ input.newevent.selector { diff -r e243f4e62c42 -r b96e527e13d4 imip_manager.py --- a/imip_manager.py Sun Feb 08 22:33:11 2015 +0100 +++ b/imip_manager.py Sun Feb 08 22:52:37 2015 +0100 @@ -469,12 +469,27 @@ def handle_request(self, uid, obj): - "Handle actions involving the given 'uid' and 'obj' object." + """ + Handle actions involving the given 'uid' and 'obj' object, returning an + error if one occurred, or None if the request was successfully handled. + """ # Handle a submitted form. args = self.env.get_args() - handled = True + + # Get the possible actions. + + reply = args.has_key("reply") + discard = args.has_key("discard") + invite = args.has_key("invite") + cancel = args.has_key("cancel") + save = args.has_key("save") + + have_action = reply or discard or invite or cancel or save + + if not have_action: + return ["action"] # Update the object. @@ -502,7 +517,7 @@ dtstart, attr = t update = self.set_datetime_in_object(dtstart, attr["TZID"], "DTSTART", obj) or update else: - return False + return ["dtstart"] # Handle specified end datetimes. @@ -517,27 +532,23 @@ dtend += timedelta(1) update = self.set_datetime_in_object(dtend, attr["TZID"], "DTEND", obj) or update else: - return False + return ["dtend"] - # Otherwise, treat the end date as the start date. Datetimes cannot - # be duplicated in such a way. + # Otherwise, treat the end date as the start date. Datetimes are + # handled by making the event occupy the rest of the day. else: + dtend = dtstart + timedelta(1) if isinstance(dtstart, datetime): - return False - dtend = dtstart + timedelta(1) + dtend = get_start_of_day(dtend, attr["TZID"]) update = self.set_datetime_in_object(dtend, attr["TZID"], "DTEND", obj) or update if dtstart >= dtend: - return False + return ["dtstart", "dtend"] # Process any action. - reply = args.has_key("reply") - discard = args.has_key("discard") - invite = args.has_key("invite") - cancel = args.has_key("cancel") - save = args.has_key("save") + handled = True if reply or invite or cancel: @@ -572,7 +583,7 @@ if handled: self.redirect(self.env.get_path()) - return handled + return None def handle_date_controls(self, name): @@ -679,11 +690,11 @@ ("DELEGATED", "Delegated"), ] - def show_object_on_page(self, uid, obj): + def show_object_on_page(self, uid, obj, error=None): """ Show the calendar object with the given 'uid' and representation 'obj' - on the current page. + on the current page. If 'error' is given, show a suitable message. """ page = self.page @@ -752,8 +763,9 @@ # Handle datetimes specially. if name in ["DTSTART", "DTEND"]: + field = name.lower() - page.th(label, class_="objectheading %s" % name.lower()) + page.th(label, class_="objectheading %s%s" % (field, error and field in error and " error" or "")) # Obtain the datetime. @@ -771,14 +783,14 @@ value = format_datetime(dt) if is_organiser: - page.td(class_="objectvalue %s" % name.lower()) + page.td(class_="objectvalue %s" % field) if name == "DTEND": page.div(class_="disabled") page.label("Specify end date", for_="dtend-enable", class_="enable") page.div.close() page.div(class_="enabled") - self._show_date_controls(name.lower(), value, attr, tzid) + self._show_date_controls(field, value, attr, tzid) if name == "DTEND": page.label("End on same day", for_="dtend-disable", class_="disable") page.div.close() @@ -960,13 +972,13 @@ if not obj: return False - handled = self.handle_request(uid, obj) + error = self.handle_request(uid, obj) - if handled: + if not error: return True self.new_page(title="Event") - self.show_object_on_page(uid, obj) + self.show_object_on_page(uid, obj, error) return True