1.1 --- a/imipweb/calendar.py Sun Sep 27 17:53:46 2015 +0200
1.2 +++ b/imipweb/calendar.py Sun Sep 27 23:38:51 2015 +0200
1.3 @@ -53,6 +53,7 @@
1.4
1.5 slots = args.get("slot", [])
1.6 participants = args.get("participants", [])
1.7 + summary = args.get("summary", [None])[0]
1.8
1.9 if not slots:
1.10 return
1.11 @@ -120,7 +121,7 @@
1.12 end_value, end_attr = get_datetime_item(end, tzid)
1.13
1.14 rwrite(("UID", {}, uid))
1.15 - rwrite(("SUMMARY", {}, "New event at %s" % utcnow))
1.16 + rwrite(("SUMMARY", {}, summary or ("New event at %s" % utcnow)))
1.17 rwrite(("DTSTAMP", {}, utcnow))
1.18 rwrite(("DTSTART", start_attr, start_value))
1.19 rwrite(("DTEND", end_attr, end_value))
1.20 @@ -379,18 +380,7 @@
1.21
1.22 add_empty_days(days, tzid)
1.23
1.24 - # Show the controls permitting day selection as well as the controls
1.25 - # configuring the new event display.
1.26 -
1.27 - self.show_calendar_day_controls(days)
1.28 - self.show_calendar_interval_controls(days)
1.29 -
1.30 - # Show a button for scheduling a new event.
1.31 -
1.32 - page.p(class_="controls")
1.33 - page.input(name="newevent", type="submit", value="New event", id="newevent", class_="newevent-with-periods", accesskey="N")
1.34 - page.span("Select days or periods for a new event.", class_="newevent-no-periods")
1.35 - page.p.close()
1.36 + page.p("Select days or periods for a new event.")
1.37
1.38 # Show controls for hiding empty days and busy slots.
1.39 # The positioning of the control, paragraph and table are important here.
1.40 @@ -417,16 +407,12 @@
1.41
1.42 # More page fragment methods.
1.43
1.44 - def show_calendar_day_controls(self, days):
1.45 + def show_calendar_day_controls(self, day):
1.46
1.47 - "Show controls for the given 'days' in the calendar."
1.48 + "Show controls for the given 'day' in the calendar."
1.49
1.50 page = self.page
1.51 - slots = self.env.get_args().get("slot", [])
1.52 -
1.53 - for day in days:
1.54 - value, identifier = self._day_value_and_identifier(day)
1.55 - self._slot_selector(value, identifier, slots)
1.56 + daystr, dayid = self._day_value_and_identifier(day)
1.57
1.58 # Generate a dynamic stylesheet to allow day selections to colour
1.59 # specific days.
1.60 @@ -435,13 +421,42 @@
1.61
1.62 page.style(type="text/css")
1.63
1.64 + page.add("""\
1.65 +input.newevent.selector#%s:checked ~ table#region-%s label.day,
1.66 +input.newevent.selector#%s:checked ~ table#region-%s label.timepoint {
1.67 + background-color: #5f4;
1.68 + text-decoration: underline;
1.69 +}
1.70 +""" % (dayid, dayid, dayid, dayid))
1.71 +
1.72 + page.style.close()
1.73 +
1.74 + # Generate controls to select days.
1.75 +
1.76 + slots = self.env.get_args().get("slot", [])
1.77 + value, identifier = self._day_value_and_identifier(day)
1.78 + self._slot_selector(value, identifier, slots)
1.79 +
1.80 + def show_calendar_interval_controls(self, day, intervals):
1.81 +
1.82 + "Show controls for the intervals provided by 'day' and 'intervals'."
1.83 +
1.84 + page = self.page
1.85 + daystr, dayid = self._day_value_and_identifier(day)
1.86 +
1.87 + # Generate a dynamic stylesheet to allow day selections to colour
1.88 + # specific days.
1.89 + # NOTE: The style details need to be coordinated with the static
1.90 + # NOTE: stylesheet.
1.91 +
1.92 l = []
1.93
1.94 - for day in days:
1.95 - daystr, dayid = self._day_value_and_identifier(day)
1.96 + for point, endpoint in intervals:
1.97 + timestr, timeid = self._slot_value_and_identifier(point, endpoint)
1.98 l.append("""\
1.99 -input.newevent.selector#%s:checked ~ table#region-%s label.day,
1.100 -input.newevent.selector#%s:checked ~ table#region-%s label.timepoint""" % (dayid, dayid, dayid, dayid))
1.101 +input.newevent.selector#%s:checked ~ table#region-%s th#region-%s""" % (timeid, dayid, timeid))
1.102 +
1.103 + page.style(type="text/css")
1.104
1.105 page.add(",\n".join(l))
1.106 page.add(""" {
1.107 @@ -452,42 +467,12 @@
1.108
1.109 page.style.close()
1.110
1.111 - def show_calendar_interval_controls(self, days):
1.112 -
1.113 - "Show controls for the intervals provided by 'days'."
1.114 -
1.115 - page = self.page
1.116 - slots = self.env.get_args().get("slot", [])
1.117 -
1.118 - for day, intervals in days.items():
1.119 - for point, endpoint in intervals:
1.120 - value, identifier = self._slot_value_and_identifier(point, endpoint)
1.121 - self._slot_selector(value, identifier, slots)
1.122 -
1.123 - # Generate a dynamic stylesheet to allow day selections to colour
1.124 - # specific days.
1.125 - # NOTE: The style details need to be coordinated with the static
1.126 - # NOTE: stylesheet.
1.127 + # Generate controls to select time periods.
1.128
1.129 - page.style(type="text/css")
1.130 -
1.131 - l = []
1.132 -
1.133 - for day, intervals in days.items():
1.134 - daystr, dayid = self._day_value_and_identifier(day)
1.135 - for point, endpoint in intervals:
1.136 - timestr, timeid = self._slot_value_and_identifier(point, endpoint)
1.137 - l.append("""\
1.138 -input.newevent.selector#%s:checked ~ table#region-%s th#region-%s""" % (timeid, dayid, timeid))
1.139 -
1.140 - page.add(",\n".join(l))
1.141 - page.add(""" {
1.142 - background-color: #5f4;
1.143 - text-decoration: underline;
1.144 -}
1.145 -""")
1.146 -
1.147 - page.style.close()
1.148 + slots = self.env.get_args().get("slot", [])
1.149 + for point, endpoint in intervals:
1.150 + value, identifier = self._slot_value_and_identifier(point, endpoint)
1.151 + self._slot_selector(value, identifier, slots)
1.152
1.153 def show_calendar_participant_headings(self, group_types, group_sources, group_columns):
1.154
1.155 @@ -556,6 +541,18 @@
1.156
1.157 daystr, dayid = self._day_value_and_identifier(day)
1.158
1.159 + # Put calendar tables within elements for quicker CSS selection.
1.160 +
1.161 + page.div(class_="calendar")
1.162 +
1.163 + # Show the controls permitting day selection as well as the controls
1.164 + # configuring the new event display.
1.165 +
1.166 + self.show_calendar_day_controls(day)
1.167 + self.show_calendar_interval_controls(day, intervals)
1.168 +
1.169 + # Show an actual table containing the day information.
1.170 +
1.171 page.table(cellspacing=5, cellpadding=5, class_="calendar %s" % (is_empty and " empty" or ""), id="region-%s" % dayid)
1.172
1.173 page.caption(class_="dayheading container separator")
1.174 @@ -570,6 +567,16 @@
1.175
1.176 page.table.close()
1.177
1.178 + # Show a button for scheduling a new event.
1.179 +
1.180 + page.p(class_="newevent-with-periods")
1.181 + page.label("Summary:")
1.182 + page.input(name="summary", type="text")
1.183 + page.input(name="newevent", type="submit", value="New event", accesskey="N")
1.184 + page.p.close()
1.185 +
1.186 + page.div.close()
1.187 +
1.188 def show_calendar_points(self, intervals, groups, group_types, group_columns):
1.189
1.190 """