1.1 --- a/imipweb/calendar.py Mon Oct 19 23:38:37 2015 +0200
1.2 +++ b/imipweb/calendar.py Tue Oct 20 15:55:28 2015 +0200
1.3 @@ -172,6 +172,29 @@
1.4 self.redirect(self.link_to(uid, args=self.get_time_navigation_args()))
1.5 return True
1.6
1.7 + def update_participants(self):
1.8 +
1.9 + "Update the participants used for scheduling purposes."
1.10 +
1.11 + args = self.env.get_args()
1.12 + participants = args.get("participants", [])
1.13 +
1.14 + try:
1.15 + for name, value in args.items():
1.16 + if name.startswith("remove-participant-"):
1.17 + i = int(name[len("remove-participant-"):])
1.18 + del participants[i]
1.19 + break
1.20 + except ValueError:
1.21 + pass
1.22 +
1.23 + # Trim empty participants.
1.24 +
1.25 + while participants and not participants[-1].strip():
1.26 + participants.pop()
1.27 +
1.28 + return participants
1.29 +
1.30 # Page fragment methods.
1.31
1.32 def show_requests_on_page(self):
1.33 @@ -206,27 +229,11 @@
1.34
1.35 page.div.close()
1.36
1.37 - def show_participants_on_page(self):
1.38 + def show_participants_on_page(self, participants):
1.39
1.40 "Show participants for scheduling purposes."
1.41
1.42 page = self.page
1.43 - args = self.env.get_args()
1.44 - participants = args.get("participants", [])
1.45 -
1.46 - try:
1.47 - for name, value in args.items():
1.48 - if name.startswith("remove-participant-"):
1.49 - i = int(name[len("remove-participant-"):])
1.50 - del participants[i]
1.51 - break
1.52 - except ValueError:
1.53 - pass
1.54 -
1.55 - # Trim empty participants.
1.56 -
1.57 - while participants and not participants[-1].strip():
1.58 - participants.pop()
1.59
1.60 # Show any specified participants together with controls to remove and
1.61 # add participants.
1.62 @@ -248,7 +255,29 @@
1.63
1.64 page.div.close()
1.65
1.66 - return participants
1.67 + def show_calendar_controls(self):
1.68 +
1.69 + """
1.70 + Show controls for hiding empty days and busy slots in the calendar.
1.71 +
1.72 + The positioning of the controls, paragraph and table are important here:
1.73 + the CSS file describes the relationship between them and the calendar
1.74 + tables.
1.75 + """
1.76 +
1.77 + page = self.page
1.78 +
1.79 + page.input(name="showdays", type="checkbox", value="show", id="showdays", accesskey="D")
1.80 + page.input(name="hidebusy", type="checkbox", value="hide", id="hidebusy", accesskey="B")
1.81 +
1.82 + page.p(class_="controls")
1.83 + page.span("Select days or periods for a new event.")
1.84 + page.label("Hide busy time periods", for_="hidebusy", class_="hidebusy enable")
1.85 + page.label("Show busy time periods", for_="hidebusy", class_="hidebusy disable")
1.86 + page.label("Show empty days", for_="showdays", class_="showdays disable")
1.87 + page.label("Hide empty days", for_="showdays", class_="showdays enable")
1.88 + page.input(name="reset", type="submit", value="Clear selections", id="reset")
1.89 + page.p.close()
1.90
1.91 def show_time_navigation(self, view_start, view_end, view_period=None):
1.92
1.93 @@ -260,7 +289,7 @@
1.94 page = self.page
1.95 view_period = view_period or timedelta(7)
1.96
1.97 - page.p()
1.98 + page.p(id_="time-navigation")
1.99
1.100 if view_start:
1.101 if view_end:
1.102 @@ -337,12 +366,14 @@
1.103 page.p("No events scheduled.")
1.104 return
1.105
1.106 + participants = self.update_participants()
1.107 +
1.108 # Form controls are used in various places on the calendar page.
1.109
1.110 page.form(method="POST")
1.111
1.112 self.show_requests_on_page()
1.113 - participants = self.show_participants_on_page()
1.114 + self.show_participants_on_page(participants)
1.115
1.116 # Obtain the user's timezone.
1.117
1.118 @@ -471,20 +502,9 @@
1.119
1.120 add_empty_days(days, tzid, view_start, view_end)
1.121
1.122 - # Show controls for hiding empty days and busy slots.
1.123 - # The positioning of the control, paragraph and table are important here.
1.124 -
1.125 - page.input(name="showdays", type="checkbox", value="show", id="showdays", accesskey="D")
1.126 - page.input(name="hidebusy", type="checkbox", value="hide", id="hidebusy", accesskey="B")
1.127 + # Show controls to change the calendar appearance.
1.128
1.129 - page.p(class_="controls")
1.130 - page.span("Select days or periods for a new event.")
1.131 - page.label("Hide busy time periods", for_="hidebusy", class_="hidebusy enable")
1.132 - page.label("Show busy time periods", for_="hidebusy", class_="hidebusy disable")
1.133 - page.label("Show empty days", for_="showdays", class_="showdays disable")
1.134 - page.label("Hide empty days", for_="showdays", class_="showdays enable")
1.135 - page.input(name="reset", type="submit", value="Clear selections", id="reset")
1.136 - page.p.close()
1.137 + self.show_calendar_controls()
1.138
1.139 # Show the calendar itself.
1.140