# HG changeset patch # User Paul Boddie # Date 1443186366 -7200 # Node ID bb7a35b934252ff0e9f1668c0c4a7954e7a5048f # Parent f2fa0b8bbcaffec6daebbefe18e8635ea0b0e4c3 Added the display of counter-proposals for an event. Changed get_counters to return just the responding attendees instead of a mapping of attendees to counter-proposals. diff -r f2fa0b8bbcaf -r bb7a35b93425 htdocs/styles.css --- a/htdocs/styles.css Thu Sep 24 23:41:47 2015 +0200 +++ b/htdocs/styles.css Fri Sep 25 15:06:06 2015 +0200 @@ -2,6 +2,7 @@ table.calendar, table.conflicts, +table.counters, table.recurrence, table.object { border: 2px solid #000; diff -r f2fa0b8bbcaf -r bb7a35b93425 imip_store.py --- a/imip_store.py Thu Sep 24 23:41:47 2015 +0200 +++ b/imip_store.py Fri Sep 25 15:06:06 2015 +0200 @@ -769,22 +769,15 @@ def get_counters(self, user, uid, recurrenceid=None): """ - For the given 'user', return a mapping of counter-proposals from other - users to nodes representing those proposals for the given 'uid' and - optional 'recurrenceid'. + For the given 'user', return a list of users from whom counter-proposals + have been received for the given 'uid' and optional 'recurrenceid'. """ filename = self.get_event_filename(user, uid, recurrenceid, "counters") if not filename: return False - counters = {} - - for other in listdir(filename): - counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other) - counters[other] = self._get_object(user, counter_filename) - - return counters + return [name for name in listdir(filename) if isfile(join(filename, name))] def get_counter(self, user, other, uid, recurrenceid=None): diff -r f2fa0b8bbcaf -r bb7a35b93425 imiptools/client.py --- a/imiptools/client.py Thu Sep 24 23:41:47 2015 +0200 +++ b/imiptools/client.py Fri Sep 25 15:06:06 2015 +0200 @@ -267,16 +267,16 @@ # Store operations. - def get_stored_object(self, uid, recurrenceid, section=None): + def get_stored_object(self, uid, recurrenceid, section=None, username=None): """ Return the stored object for the current user, with the given 'uid' and - 'recurrenceid' from the given 'section' (if specified), or from the - standard object collection otherwise. + 'recurrenceid' from the given 'section' and for the given 'username' (if + specified), or from the standard object collection otherwise. """ if section == "counters": - fragment = self.store.get_counter(self.user, uid, recurrenceid) + fragment = self.store.get_counter(self.user, username, uid, recurrenceid) else: fragment = self.store.get_event(self.user, uid, recurrenceid) return fragment and Object(fragment) diff -r f2fa0b8bbcaf -r bb7a35b93425 imipweb/event.py --- a/imipweb/event.py Thu Sep 24 23:41:47 2015 +0200 +++ b/imipweb/event.py Fri Sep 25 15:06:06 2015 +0200 @@ -287,6 +287,7 @@ page.table.close() self.show_recurrences(errors) + self.show_counters() self.show_conflicting_events() self.show_request_controls() @@ -477,6 +478,57 @@ page.div.close() + def show_counters(self): + + "Show any counter-proposals for the current object." + + page = self.page + attendees = self._get_counters(self.uid, self.recurrenceid) + tzid = self.get_tzid() + + if not attendees: + return + + page.p("The following counter-proposals have been received for this event:") + + page.table(cellspacing=5, cellpadding=5, class_="counters") + page.thead() + page.tr() + page.th("Attendee", rowspan=2) + page.th("Periods", colspan=2) + page.tr.close() + page.tr() + page.th("Start") + page.th("End") + page.tr.close() + page.thead.close() + page.tbody() + + for attendee in attendees: + obj = self.get_stored_object(self.uid, self.recurrenceid, "counters", attendee) + periods = self.get_periods(obj) + + page.tr(rowspan=len(periods)) + page.td(attendee) + + first = True + for p in periods: + if not first: + page.tr() + else: + first = False + + start = self.format_datetime(to_timezone(p.get_start(), tzid), "long") + end = self.format_datetime(to_timezone(p.get_end(), tzid), "long") + + page.td(start) + page.td(end) + + page.tr.close() + + page.tbody.close() + page.table.close() + def show_conflicting_events(self): "Show conflicting events for the current object." diff -r f2fa0b8bbcaf -r bb7a35b93425 imipweb/resource.py --- a/imipweb/resource.py Thu Sep 24 23:41:47 2015 +0200 +++ b/imipweb/resource.py Fri Sep 25 15:06:06 2015 +0200 @@ -146,6 +146,9 @@ def _have_request(self, uid, recurrenceid=None, type=None, strict=False): return self.store.have_request(self._get_requests(), uid, recurrenceid, type, strict) + def _get_counters(self, uid, recurrenceid=None): + return self.store.get_counters(self.user, uid, recurrenceid) + def _get_request_summary(self): "Return a list of periods comprising the request summary."