# HG changeset patch # User Paul Boddie # Date 1445349328 -7200 # Node ID fccb686cff464846e0f9a37e75c324f43a66d0e0 # Parent d772a27098e7d3be5ef94775691f85825c2a2bfe Changed the layout at the top of the calendar page. Separated scheduling participant updating from presentation. diff -r d772a27098e7 -r fccb686cff46 htdocs/styles.css --- a/htdocs/styles.css Mon Oct 19 23:38:37 2015 +0200 +++ b/htdocs/styles.css Tue Oct 20 15:55:28 2015 +0200 @@ -1,3 +1,23 @@ +body, +#participants, +#pending-requests { + background-color: #fff; +} + +#participants { + float: right; +} + +#pending-requests { + float: left; +} + +#calendar-controls, +#time-navigation, +div.calendar { + clear: both; +} + /* Table styling. */ table.calendar { diff -r d772a27098e7 -r fccb686cff46 imipweb/calendar.py --- a/imipweb/calendar.py Mon Oct 19 23:38:37 2015 +0200 +++ b/imipweb/calendar.py Tue Oct 20 15:55:28 2015 +0200 @@ -172,6 +172,29 @@ self.redirect(self.link_to(uid, args=self.get_time_navigation_args())) return True + def update_participants(self): + + "Update the participants used for scheduling purposes." + + args = self.env.get_args() + participants = args.get("participants", []) + + try: + for name, value in args.items(): + if name.startswith("remove-participant-"): + i = int(name[len("remove-participant-"):]) + del participants[i] + break + except ValueError: + pass + + # Trim empty participants. + + while participants and not participants[-1].strip(): + participants.pop() + + return participants + # Page fragment methods. def show_requests_on_page(self): @@ -206,27 +229,11 @@ page.div.close() - def show_participants_on_page(self): + def show_participants_on_page(self, participants): "Show participants for scheduling purposes." page = self.page - args = self.env.get_args() - participants = args.get("participants", []) - - try: - for name, value in args.items(): - if name.startswith("remove-participant-"): - i = int(name[len("remove-participant-"):]) - del participants[i] - break - except ValueError: - pass - - # Trim empty participants. - - while participants and not participants[-1].strip(): - participants.pop() # Show any specified participants together with controls to remove and # add participants. @@ -248,7 +255,29 @@ page.div.close() - return participants + def show_calendar_controls(self): + + """ + Show controls for hiding empty days and busy slots in the calendar. + + The positioning of the controls, paragraph and table are important here: + the CSS file describes the relationship between them and the calendar + tables. + """ + + page = self.page + + page.input(name="showdays", type="checkbox", value="show", id="showdays", accesskey="D") + page.input(name="hidebusy", type="checkbox", value="hide", id="hidebusy", accesskey="B") + + page.p(class_="controls") + page.span("Select days or periods for a new event.") + page.label("Hide busy time periods", for_="hidebusy", class_="hidebusy enable") + page.label("Show busy time periods", for_="hidebusy", class_="hidebusy disable") + page.label("Show empty days", for_="showdays", class_="showdays disable") + page.label("Hide empty days", for_="showdays", class_="showdays enable") + page.input(name="reset", type="submit", value="Clear selections", id="reset") + page.p.close() def show_time_navigation(self, view_start, view_end, view_period=None): @@ -260,7 +289,7 @@ page = self.page view_period = view_period or timedelta(7) - page.p() + page.p(id_="time-navigation") if view_start: if view_end: @@ -337,12 +366,14 @@ page.p("No events scheduled.") return + participants = self.update_participants() + # Form controls are used in various places on the calendar page. page.form(method="POST") self.show_requests_on_page() - participants = self.show_participants_on_page() + self.show_participants_on_page(participants) # Obtain the user's timezone. @@ -471,20 +502,9 @@ add_empty_days(days, tzid, view_start, view_end) - # Show controls for hiding empty days and busy slots. - # The positioning of the control, paragraph and table are important here. - - page.input(name="showdays", type="checkbox", value="show", id="showdays", accesskey="D") - page.input(name="hidebusy", type="checkbox", value="hide", id="hidebusy", accesskey="B") + # Show controls to change the calendar appearance. - page.p(class_="controls") - page.span("Select days or periods for a new event.") - page.label("Hide busy time periods", for_="hidebusy", class_="hidebusy enable") - page.label("Show busy time periods", for_="hidebusy", class_="hidebusy disable") - page.label("Show empty days", for_="showdays", class_="showdays disable") - page.label("Hide empty days", for_="showdays", class_="showdays enable") - page.input(name="reset", type="submit", value="Clear selections", id="reset") - page.p.close() + self.show_calendar_controls() # Show the calendar itself.