# HG changeset patch # User Paul Boddie # Date 1431524453 -7200 # Node ID 328fc630a70638452b0012ee3af78e11ea872cc1 # Parent 82483130bd024787e5fc7093e787e4e93a4a1513 Moved editable recurrence generation into a separate method. diff -r 82483130bd02 -r 328fc630a706 imipweb/event.py --- a/imipweb/event.py Wed May 13 14:59:30 2015 +0200 +++ b/imipweb/event.py Wed May 13 15:40:53 2015 +0200 @@ -728,33 +728,8 @@ if self.is_organiser(obj) and recurrences: - for index, p in enumerate(recurrences): - - # Isolate the controls from neighbouring tables. - - page.div() - - self.show_object_datetime_controls(p, index) - - page.table(cellspacing=5, cellpadding=5, class_="recurrence") - page.caption(p.origin == "RRULE" and "Occurrence from rule" or "Occurrence") - page.tbody() - - page.tr() - error = errors and ("dtstart", index) in errors and " error" or "" - page.th("Start", class_="objectheading start%s" % error) - self.show_recurrence_controls(obj, index, p, recurrenceid, recurrenceids, True) - page.tr.close() - page.tr() - error = errors and ("dtend", index) in errors and " error" or "" - page.th("End", class_="objectheading end%s" % error) - self.show_recurrence_controls(obj, index, p, recurrenceid, recurrenceids, False) - page.tr.close() - - page.tbody.close() - page.table.close() - - page.div.close() + for index, period in enumerate(recurrences): + self.show_recurrence(obj, index, period, recurrenceid, recurrenceids, errors) # Otherwise, use a compact single table. @@ -769,15 +744,56 @@ page.thead.close() page.tbody() - for index, p in enumerate(recurrences): + for index, period in enumerate(recurrences): page.tr() - self.show_recurrence_label(p, recurrenceid, recurrenceids, True) - self.show_recurrence_label(p, recurrenceid, recurrenceids, False) + self.show_recurrence_label(period, recurrenceid, recurrenceids, True) + self.show_recurrence_label(period, recurrenceid, recurrenceids, False) page.tr.close() page.tbody.close() page.table.close() + def show_recurrence(self, obj, index, period, recurrenceid, recurrenceids, errors=None): + + """ + Show recurrence controls for a recurrence provided by 'obj' with the + given 'index' position in the list of periods, the given 'period' + details, where a 'recurrenceid' indicates any specific recurrence, and + where 'recurrenceids' indicates all known additional recurrences for the + object. + + If 'errors' is given, show a suitable message for the different errors + provided. + """ + + page = self.page + + # Isolate the controls from neighbouring tables. + + page.div() + + self.show_object_datetime_controls(period, index) + + page.table(cellspacing=5, cellpadding=5, class_="recurrence") + page.caption(period.origin == "RRULE" and "Occurrence from rule" or "Occurrence") + page.tbody() + + page.tr() + error = errors and ("dtstart", index) in errors and " error" or "" + page.th("Start", class_="objectheading start%s" % error) + self.show_recurrence_controls(obj, index, period, recurrenceid, recurrenceids, True) + page.tr.close() + page.tr() + error = errors and ("dtend", index) in errors and " error" or "" + page.th("End", class_="objectheading end%s" % error) + self.show_recurrence_controls(obj, index, period, recurrenceid, recurrenceids, False) + page.tr.close() + + page.tbody.close() + page.table.close() + + page.div.close() + def show_conflicting_events(self, uid, obj): """