1.1 --- a/imip_manager.py Tue Feb 03 00:02:18 2015 +0100
1.2 +++ b/imip_manager.py Tue Feb 03 00:33:45 2015 +0100
1.3 @@ -33,9 +33,9 @@
1.4 from imiptools.content import Handler
1.5 from imiptools.data import get_address, get_uri, make_freebusy, parse_object, \
1.6 Object, to_part
1.7 -from imiptools.dates import format_datetime, get_datetime, get_start_of_day, \
1.8 - get_end_of_day, get_timestamp, ends_on_same_day, \
1.9 - to_timezone
1.10 +from imiptools.dates import format_datetime, get_datetime, get_datetime_item, \
1.11 + get_start_of_day, get_start_of_next_day, get_timestamp, \
1.12 + ends_on_same_day, to_timezone
1.13 from imiptools.mail import Messenger
1.14 from imiptools.period import add_day_start_points, add_slots, convert_periods, \
1.15 get_freebusy_details, \
1.16 @@ -401,6 +401,12 @@
1.17 for i, (start, end) in enumerate(coalesced):
1.18 this_uid = "%s-%s" % (uid, i)
1.19
1.20 + start = get_datetime(start, {"TZID" : tzid})
1.21 + end = end and get_datetime(end, {"TZID" : tzid}) or get_start_of_next_day(start, tzid)
1.22 +
1.23 + start_value, start_attr = get_datetime_item(start)
1.24 + end_value, end_attr = get_datetime_item(end)
1.25 +
1.26 # Create a calendar object and store it as a request.
1.27
1.28 record = []
1.29 @@ -409,10 +415,8 @@
1.30 rwrite(("UID", {}, this_uid))
1.31 rwrite(("SUMMARY", {}, "New event at %s" % utcnow))
1.32 rwrite(("DTSTAMP", {}, utcnow))
1.33 - rwrite(("DTSTART", {"VALUE" : "DATE-TIME", "TZID" : tzid}, start))
1.34 - rwrite(("DTEND", {"VALUE" : "DATE-TIME", "TZID" : tzid}, end or
1.35 - format_datetime(get_end_of_day(get_datetime(start, {"TZID" : tzid})))
1.36 - ))
1.37 + rwrite(("DTSTART", start_attr, start_value))
1.38 + rwrite(("DTEND", end_attr, end_value))
1.39 rwrite(("ORGANIZER", {}, self.user))
1.40
1.41 for participant in participants:
1.42 @@ -969,7 +973,7 @@
1.43 page.thead()
1.44 page.tr()
1.45 page.th(class_="dayheading", colspan=all_columns+1)
1.46 - page.add(self.format_date(day, "full"))
1.47 + self._day_heading(day)
1.48 page.th.close()
1.49 page.tr.close()
1.50 page.thead.close()
1.51 @@ -1092,21 +1096,37 @@
1.52
1.53 page.tr.close()
1.54
1.55 + def _day_heading(self, day):
1.56 + page = self.page
1.57 + value, identifier = self._day_value_and_identifier(day)
1.58 + slots = self.env.get_args().get("slot", [])
1.59 + self._slot_selector(value, identifier, slots)
1.60 + page.label(self.format_date(day, "full"), class_="day", for_=identifier)
1.61 +
1.62 def _time_point(self, point, endpoint):
1.63 page = self.page
1.64 value, identifier = self._slot_value_and_identifier(point, endpoint)
1.65 slots = self.env.get_args().get("slot", [])
1.66 + self._slot_selector(value, identifier, slots)
1.67 + page.label(self.format_time(point, "long"), class_="timepoint", for_=identifier)
1.68 +
1.69 + def _slot_selector(self, value, identifier, slots):
1.70 + page = self.page
1.71 if value in slots:
1.72 page.input(name="slot", type="checkbox", value=value, id=identifier, class_="newevent", checked="checked")
1.73 else:
1.74 page.input(name="slot", type="checkbox", value=value, id=identifier, class_="newevent")
1.75 - page.label(self.format_time(point, "long"), class_="timepoint", for_=identifier)
1.76
1.77 def _empty_slot(self, point, endpoint):
1.78 page = self.page
1.79 value, identifier = self._slot_value_and_identifier(point, endpoint)
1.80 page.label("Select/deselect period", class_="newevent popup", for_=identifier)
1.81
1.82 + def _day_value_and_identifier(self, day):
1.83 + value = "%s-" % format_datetime(day)
1.84 + identifier = "day-%s" % value
1.85 + return value, identifier
1.86 +
1.87 def _slot_value_and_identifier(self, point, endpoint):
1.88 value = "%s-%s" % (format_datetime(point), endpoint and format_datetime(endpoint) or "")
1.89 identifier = "slot-%s" % value