1.1 --- a/imip_manager.py Thu Nov 27 16:29:21 2014 +0100
1.2 +++ b/imip_manager.py Mon Dec 08 19:12:13 2014 +0100
1.3 @@ -9,7 +9,7 @@
1.4 get_item, get_uri, get_utc_datetime, get_values, \
1.5 parse_object, to_part, to_timezone
1.6 from imiptools.mail import Messenger
1.7 -from imiptools.period import have_conflict
1.8 +from imiptools.period import have_conflict, get_slots, get_spans
1.9 from vCalendar import to_node
1.10 import markup
1.11 import imip_store
1.12 @@ -171,6 +171,8 @@
1.13 requests = self.store.get_requests(self.user)
1.14
1.15 if requests:
1.16 + self.page.p("Pending requests:")
1.17 +
1.18 self.page.ul()
1.19
1.20 for request in requests:
1.21 @@ -280,6 +282,59 @@
1.22
1.23 return True
1.24
1.25 + def show_calendar(self):
1.26 +
1.27 + "Show the calendar for the current user."
1.28 +
1.29 + self.new_page(title="Calendar")
1.30 +
1.31 + freebusy = self.store.get_freebusy(self.user)
1.32 + page = self.page
1.33 +
1.34 + if not freebusy:
1.35 + page.p("No events scheduled.")
1.36 + return
1.37 +
1.38 + # Day view: start at the earliest known day and produce days until the
1.39 + # latest known day, perhaps with expandable sections of empty days.
1.40 +
1.41 + # Month view: start at the earliest known month and produce months until
1.42 + # the latest known month, perhaps with expandable sections of empty
1.43 + # months.
1.44 +
1.45 + # Details of users to invite to new events could be superimposed on the
1.46 + # calendar.
1.47 +
1.48 + # Requests could be listed and linked to their tentative positions in
1.49 + # the calendar.
1.50 +
1.51 + slots = get_slots(freebusy)
1.52 + spans = get_spans(slots)
1.53 +
1.54 + page.table(border=1, cellspacing=0, cellpadding=5)
1.55 +
1.56 + for point, active in slots:
1.57 + page.tr()
1.58 + page.th(class_="timeslot")
1.59 + page.add(point)
1.60 + page.th.close()
1.61 +
1.62 + for t in active:
1.63 + if t:
1.64 + start, end, uid, transp = t
1.65 + span = spans[uid]
1.66 + if point == start:
1.67 + page.td(class_="event", rowspan=span)
1.68 + page.add(uid)
1.69 + page.td.close()
1.70 + else:
1.71 + page.td(class_="empty")
1.72 + page.td.close()
1.73 +
1.74 + page.tr.close()
1.75 +
1.76 + page.table.close()
1.77 +
1.78 def select_action(self):
1.79
1.80 "Select the desired action and show the result."
1.81 @@ -287,6 +342,8 @@
1.82 path_info = self.env.get_path_info().rstrip("/")
1.83 if not path_info:
1.84 self.show_requests()
1.85 + elif path_info.rsplit("/", 1)[-1] == "calendar":
1.86 + self.show_calendar()
1.87 elif self.show_request(path_info):
1.88 pass
1.89 else: