1.1 --- a/imipweb/calendar.py Tue Oct 20 17:42:58 2015 +0200
1.2 +++ b/imipweb/calendar.py Tue Oct 20 17:44:45 2015 +0200
1.3 @@ -21,7 +21,7 @@
1.4
1.5 from datetime import datetime, timedelta
1.6 from imiptools.data import get_address, get_uri, uri_parts
1.7 -from imiptools.dates import format_datetime, get_datetime, \
1.8 +from imiptools.dates import format_datetime, get_date, get_datetime, \
1.9 get_datetime_item, get_end_of_day, get_start_of_day, \
1.10 get_start_of_next_day, get_timestamp, ends_on_same_day, \
1.11 to_timezone
1.12 @@ -270,7 +270,7 @@
1.13 page.input(name="showdays", type="checkbox", value="show", id="showdays", accesskey="D")
1.14 page.input(name="hidebusy", type="checkbox", value="hide", id="hidebusy", accesskey="B")
1.15
1.16 - page.p(class_="controls")
1.17 + page.p(id_="calendar-controls", class_="controls")
1.18 page.span("Select days or periods for a new event.")
1.19 page.label("Hide busy time periods", for_="hidebusy", class_="hidebusy enable")
1.20 page.label("Show busy time periods", for_="hidebusy", class_="hidebusy disable")
1.21 @@ -348,45 +348,17 @@
1.22 link_args["end"] = format_datetime(view_end)
1.23 return link_args
1.24
1.25 - # Full page output methods.
1.26 -
1.27 - def show(self):
1.28 -
1.29 - "Show the calendar for the current user."
1.30 -
1.31 - self.new_page(title="Calendar")
1.32 - page = self.page
1.33 -
1.34 - if self.handle_newevent():
1.35 - return
1.36 + def get_period_group_details(self, freebusy, participants, view_period):
1.37
1.38 - freebusy = self.store.get_freebusy(self.user)
1.39 -
1.40 - if not freebusy:
1.41 - page.p("No events scheduled.")
1.42 - return
1.43 -
1.44 - participants = self.update_participants()
1.45 -
1.46 - # Form controls are used in various places on the calendar page.
1.47 -
1.48 - page.form(method="POST")
1.49 -
1.50 - self.show_requests_on_page()
1.51 - self.show_participants_on_page(participants)
1.52 + """
1.53 + Return details of periods in the given 'freebusy' collection and for the
1.54 + collections of the given 'participants'.
1.55 + """
1.56
1.57 # Obtain the user's timezone.
1.58
1.59 tzid = self.get_tzid()
1.60
1.61 - # Day view: start at the earliest known day and produce days until the
1.62 - # latest known day, with expandable sections of empty days.
1.63 -
1.64 - view_start, view_end = self.get_time_navigation()
1.65 - view_period = (view_start or view_end) and Period(view_start, view_end, self.get_tzid())
1.66 -
1.67 - self.show_time_navigation(view_start, view_end)
1.68 -
1.69 # Requests are listed and linked to their tentative positions in the
1.70 # calendar. Other participants are also shown.
1.71
1.72 @@ -498,13 +470,59 @@
1.73 partitioned_group_types.append(group_type)
1.74 partitioned_group_sources.append(group_source)
1.75
1.76 + return days, partitioned_groups, partitioned_group_types, partitioned_group_sources, group_columns
1.77 +
1.78 + # Full page output methods.
1.79 +
1.80 + def show(self):
1.81 +
1.82 + "Show the calendar for the current user."
1.83 +
1.84 + self.new_page(title="Calendar")
1.85 + page = self.page
1.86 +
1.87 + if self.handle_newevent():
1.88 + return
1.89 +
1.90 + freebusy = self.store.get_freebusy(self.user)
1.91 +
1.92 + if not freebusy:
1.93 + page.p("No events scheduled.")
1.94 + return
1.95 +
1.96 + participants = self.update_participants()
1.97 +
1.98 + # Form controls are used in various places on the calendar page.
1.99 +
1.100 + page.form(method="POST")
1.101 +
1.102 + self.show_requests_on_page()
1.103 + self.show_participants_on_page(participants)
1.104 +
1.105 + # Day view: start at the earliest known day and produce days until the
1.106 + # latest known day, with expandable sections of empty days.
1.107 +
1.108 + view_start, view_end = self.get_time_navigation()
1.109 +
1.110 + # Without any explicit limits, impose a reasonable view period.
1.111 +
1.112 + if not (view_start or view_end):
1.113 + view_start = get_date()
1.114 + view_end = get_date(timedelta(8))
1.115 +
1.116 + view_period = (view_start or view_end) and Period(view_start, view_end, self.get_tzid())
1.117 +
1.118 + (days, partitioned_groups, partitioned_group_types, partitioned_group_sources, group_columns) = \
1.119 + self.get_period_group_details(freebusy, participants, view_period)
1.120 +
1.121 # Add empty days.
1.122
1.123 - add_empty_days(days, tzid, view_start, view_end)
1.124 + add_empty_days(days, self.get_tzid(), view_start, view_end)
1.125
1.126 # Show controls to change the calendar appearance.
1.127
1.128 self.show_calendar_controls()
1.129 + self.show_time_navigation(view_start, view_end)
1.130
1.131 # Show the calendar itself.
1.132