2.1 --- a/imipweb/calendar.py Sun Sep 27 17:53:46 2015 +0200
2.2 +++ b/imipweb/calendar.py Sun Sep 27 23:38:51 2015 +0200
2.3 @@ -53,6 +53,7 @@
2.4
2.5 slots = args.get("slot", [])
2.6 participants = args.get("participants", [])
2.7 + summary = args.get("summary", [None])[0]
2.8
2.9 if not slots:
2.10 return
2.11 @@ -120,7 +121,7 @@
2.12 end_value, end_attr = get_datetime_item(end, tzid)
2.13
2.14 rwrite(("UID", {}, uid))
2.15 - rwrite(("SUMMARY", {}, "New event at %s" % utcnow))
2.16 + rwrite(("SUMMARY", {}, summary or ("New event at %s" % utcnow)))
2.17 rwrite(("DTSTAMP", {}, utcnow))
2.18 rwrite(("DTSTART", start_attr, start_value))
2.19 rwrite(("DTEND", end_attr, end_value))
2.20 @@ -379,18 +380,7 @@
2.21
2.22 add_empty_days(days, tzid)
2.23
2.24 - # Show the controls permitting day selection as well as the controls
2.25 - # configuring the new event display.
2.26 -
2.27 - self.show_calendar_day_controls(days)
2.28 - self.show_calendar_interval_controls(days)
2.29 -
2.30 - # Show a button for scheduling a new event.
2.31 -
2.32 - page.p(class_="controls")
2.33 - page.input(name="newevent", type="submit", value="New event", id="newevent", class_="newevent-with-periods", accesskey="N")
2.34 - page.span("Select days or periods for a new event.", class_="newevent-no-periods")
2.35 - page.p.close()
2.36 + page.p("Select days or periods for a new event.")
2.37
2.38 # Show controls for hiding empty days and busy slots.
2.39 # The positioning of the control, paragraph and table are important here.
2.40 @@ -417,16 +407,12 @@
2.41
2.42 # More page fragment methods.
2.43
2.44 - def show_calendar_day_controls(self, days):
2.45 + def show_calendar_day_controls(self, day):
2.46
2.47 - "Show controls for the given 'days' in the calendar."
2.48 + "Show controls for the given 'day' in the calendar."
2.49
2.50 page = self.page
2.51 - slots = self.env.get_args().get("slot", [])
2.52 -
2.53 - for day in days:
2.54 - value, identifier = self._day_value_and_identifier(day)
2.55 - self._slot_selector(value, identifier, slots)
2.56 + daystr, dayid = self._day_value_and_identifier(day)
2.57
2.58 # Generate a dynamic stylesheet to allow day selections to colour
2.59 # specific days.
2.60 @@ -435,13 +421,42 @@
2.61
2.62 page.style(type="text/css")
2.63
2.64 + page.add("""\
2.65 +input.newevent.selector#%s:checked ~ table#region-%s label.day,
2.66 +input.newevent.selector#%s:checked ~ table#region-%s label.timepoint {
2.67 + background-color: #5f4;
2.68 + text-decoration: underline;
2.69 +}
2.70 +""" % (dayid, dayid, dayid, dayid))
2.71 +
2.72 + page.style.close()
2.73 +
2.74 + # Generate controls to select days.
2.75 +
2.76 + slots = self.env.get_args().get("slot", [])
2.77 + value, identifier = self._day_value_and_identifier(day)
2.78 + self._slot_selector(value, identifier, slots)
2.79 +
2.80 + def show_calendar_interval_controls(self, day, intervals):
2.81 +
2.82 + "Show controls for the intervals provided by 'day' and 'intervals'."
2.83 +
2.84 + page = self.page
2.85 + daystr, dayid = self._day_value_and_identifier(day)
2.86 +
2.87 + # Generate a dynamic stylesheet to allow day selections to colour
2.88 + # specific days.
2.89 + # NOTE: The style details need to be coordinated with the static
2.90 + # NOTE: stylesheet.
2.91 +
2.92 l = []
2.93
2.94 - for day in days:
2.95 - daystr, dayid = self._day_value_and_identifier(day)
2.96 + for point, endpoint in intervals:
2.97 + timestr, timeid = self._slot_value_and_identifier(point, endpoint)
2.98 l.append("""\
2.99 -input.newevent.selector#%s:checked ~ table#region-%s label.day,
2.100 -input.newevent.selector#%s:checked ~ table#region-%s label.timepoint""" % (dayid, dayid, dayid, dayid))
2.101 +input.newevent.selector#%s:checked ~ table#region-%s th#region-%s""" % (timeid, dayid, timeid))
2.102 +
2.103 + page.style(type="text/css")
2.104
2.105 page.add(",\n".join(l))
2.106 page.add(""" {
2.107 @@ -452,42 +467,12 @@
2.108
2.109 page.style.close()
2.110
2.111 - def show_calendar_interval_controls(self, days):
2.112 -
2.113 - "Show controls for the intervals provided by 'days'."
2.114 -
2.115 - page = self.page
2.116 - slots = self.env.get_args().get("slot", [])
2.117 -
2.118 - for day, intervals in days.items():
2.119 - for point, endpoint in intervals:
2.120 - value, identifier = self._slot_value_and_identifier(point, endpoint)
2.121 - self._slot_selector(value, identifier, slots)
2.122 -
2.123 - # Generate a dynamic stylesheet to allow day selections to colour
2.124 - # specific days.
2.125 - # NOTE: The style details need to be coordinated with the static
2.126 - # NOTE: stylesheet.
2.127 + # Generate controls to select time periods.
2.128
2.129 - page.style(type="text/css")
2.130 -
2.131 - l = []
2.132 -
2.133 - for day, intervals in days.items():
2.134 - daystr, dayid = self._day_value_and_identifier(day)
2.135 - for point, endpoint in intervals:
2.136 - timestr, timeid = self._slot_value_and_identifier(point, endpoint)
2.137 - l.append("""\
2.138 -input.newevent.selector#%s:checked ~ table#region-%s th#region-%s""" % (timeid, dayid, timeid))
2.139 -
2.140 - page.add(",\n".join(l))
2.141 - page.add(""" {
2.142 - background-color: #5f4;
2.143 - text-decoration: underline;
2.144 -}
2.145 -""")
2.146 -
2.147 - page.style.close()
2.148 + slots = self.env.get_args().get("slot", [])
2.149 + for point, endpoint in intervals:
2.150 + value, identifier = self._slot_value_and_identifier(point, endpoint)
2.151 + self._slot_selector(value, identifier, slots)
2.152
2.153 def show_calendar_participant_headings(self, group_types, group_sources, group_columns):
2.154
2.155 @@ -556,6 +541,18 @@
2.156
2.157 daystr, dayid = self._day_value_and_identifier(day)
2.158
2.159 + # Put calendar tables within elements for quicker CSS selection.
2.160 +
2.161 + page.div(class_="calendar")
2.162 +
2.163 + # Show the controls permitting day selection as well as the controls
2.164 + # configuring the new event display.
2.165 +
2.166 + self.show_calendar_day_controls(day)
2.167 + self.show_calendar_interval_controls(day, intervals)
2.168 +
2.169 + # Show an actual table containing the day information.
2.170 +
2.171 page.table(cellspacing=5, cellpadding=5, class_="calendar %s" % (is_empty and " empty" or ""), id="region-%s" % dayid)
2.172
2.173 page.caption(class_="dayheading container separator")
2.174 @@ -570,6 +567,16 @@
2.175
2.176 page.table.close()
2.177
2.178 + # Show a button for scheduling a new event.
2.179 +
2.180 + page.p(class_="newevent-with-periods")
2.181 + page.label("Summary:")
2.182 + page.input(name="summary", type="text")
2.183 + page.input(name="newevent", type="submit", value="New event", accesskey="N")
2.184 + page.p.close()
2.185 +
2.186 + page.div.close()
2.187 +
2.188 def show_calendar_points(self, intervals, groups, group_types, group_columns):
2.189
2.190 """