1.1 --- a/imiptools/client.py Sat Sep 19 01:07:40 2015 +0200
1.2 +++ b/imiptools/client.py Sat Sep 19 01:08:17 2015 +0200
1.3 @@ -281,14 +281,18 @@
1.4
1.5 # Store operations.
1.6
1.7 - def get_stored_object(self, uid, recurrenceid):
1.8 + def get_stored_object(self, uid, recurrenceid, section=None):
1.9
1.10 """
1.11 Return the stored object for the current user, with the given 'uid' and
1.12 - 'recurrenceid'.
1.13 + 'recurrenceid' from the given 'section' (if specified), or from the
1.14 + standard object collection otherwise.
1.15 """
1.16
1.17 - fragment = self.store.get_event(self.user, uid, recurrenceid)
1.18 + if section == "counters":
1.19 + fragment = self.store.get_counter(self.user, uid, recurrenceid)
1.20 + else:
1.21 + fragment = self.store.get_event(self.user, uid, recurrenceid)
1.22 return fragment and Object(fragment)
1.23
1.24 # Free/busy operations.
2.1 --- a/imipweb/calendar.py Sat Sep 19 01:07:40 2015 +0200
2.2 +++ b/imipweb/calendar.py Sat Sep 19 01:08:17 2015 +0200
2.3 @@ -702,11 +702,22 @@
2.4 else:
2.5 page.td(class_=css, rowspan=span)
2.6
2.7 - # Only link to events if they are not being
2.8 - # updated by requests.
2.9 + # Only link to events if they are not being updated
2.10 + # by requests.
2.11 +
2.12 + if not p.summary or \
2.13 + group_type != "request" and self._have_request(p.uid, p.recurrenceid, None, True):
2.14 +
2.15 + page.span(p.summary or "(Participant is busy)")
2.16
2.17 - if not p.summary or self._have_request(p.uid, p.recurrenceid) and group_type != "request":
2.18 - page.span(p.summary or "(Participant is busy)")
2.19 + # Link to counter-proposals.
2.20 +
2.21 + elif group_type == "request" and self._have_request(p.uid, p.recurrenceid, "COUNTER", True):
2.22 + page.a(p.summary, href=self.link_to(p.uid, p.recurrenceid, "counter"))
2.23 +
2.24 + # Link to requests and events (including ones for
2.25 + # which counter-proposals exist).
2.26 +
2.27 else:
2.28 page.a(p.summary, href=self.link_to(p.uid, p.recurrenceid))
2.29
3.1 --- a/imipweb/event.py Sat Sep 19 01:07:40 2015 +0200
3.2 +++ b/imipweb/event.py Sat Sep 19 01:08:17 2015 +0200
3.3 @@ -1082,8 +1082,8 @@
3.4
3.5 "Show an object request using the given 'path_info' for the current user."
3.6
3.7 - uid, recurrenceid = self._get_identifiers(path_info)
3.8 - obj = self.get_stored_object(uid, recurrenceid)
3.9 + uid, recurrenceid, section = self.get_identifiers(path_info)
3.10 + obj = self.get_stored_object(uid, recurrenceid, section)
3.11
3.12 if not obj:
3.13 return False
4.1 --- a/imipweb/resource.py Sat Sep 19 01:07:40 2015 +0200
4.2 +++ b/imipweb/resource.py Sat Sep 19 01:08:17 2015 +0200
4.3 @@ -83,11 +83,19 @@
4.4 self.new_page(title="Redirect")
4.5 self.page.p("Redirecting to: %s" % url)
4.6
4.7 - def link_to(self, uid, recurrenceid=None):
4.8 + def link_to(self, uid, recurrenceid=None, section=None):
4.9 +
4.10 + """
4.11 + Return a link to an object with the given 'uid', 'recurrenceid' and
4.12 + 'section'. See get_identifiers for the decoding of such links.
4.13 + """
4.14 +
4.15 + path = [uid]
4.16 if recurrenceid:
4.17 - return self.env.new_url("/".join([uid, recurrenceid]))
4.18 - else:
4.19 - return self.env.new_url(uid)
4.20 + path.append(recurrenceid)
4.21 + if section:
4.22 + path.append(section)
4.23 + return self.env.new_url("/".join(path))
4.24
4.25 # Control naming helpers.
4.26
4.27 @@ -102,18 +110,38 @@
4.28
4.29 # Access to objects.
4.30
4.31 - def _get_identifiers(self, path_info):
4.32 + def get_identifiers(self, path_info):
4.33 +
4.34 + """
4.35 + Return identifiers provided by 'path_info', potentially encoded by
4.36 + 'link_to'.
4.37 + """
4.38 +
4.39 parts = path_info.lstrip("/").split("/")
4.40 +
4.41 + # UID only.
4.42 +
4.43 if len(parts) == 1:
4.44 - return parts[0], None
4.45 + return parts[0], None, None
4.46 +
4.47 + # UID and RECURRENCE-ID or UID and section.
4.48 +
4.49 + elif len(parts) == 2:
4.50 + if parts[1] == "counter":
4.51 + return parts[0], None, "counters"
4.52 + else:
4.53 + return parts[0], parts[1], parts[2] == "counter" and "counters" or None
4.54 +
4.55 + # UID, RECURRENCE-ID and section.
4.56 +
4.57 else:
4.58 - return parts[:2]
4.59 + return parts[:3]
4.60
4.61 - def _get_object(self, uid, recurrenceid=None):
4.62 - if self.objects.has_key((uid, recurrenceid)):
4.63 - return self.objects[(uid, recurrenceid)]
4.64 + def _get_object(self, uid, recurrenceid=None, section=None):
4.65 + if self.objects.has_key((uid, recurrenceid, section)):
4.66 + return self.objects[(uid, recurrenceid, section)]
4.67
4.68 - obj = self.objects[(uid, recurrenceid)] = self.get_stored_object(uid, recurrenceid)
4.69 + obj = self.objects[(uid, recurrenceid, section)] = self.get_stored_object(uid, recurrenceid, section)
4.70 return obj
4.71
4.72 def _get_recurrences(self, uid):
4.73 @@ -127,9 +155,8 @@
4.74 self.requests = self.store.get_requests(self.user)
4.75 return self.requests
4.76
4.77 - def _have_request(self, uid, recurrenceid=None):
4.78 - requests = self._get_requests()
4.79 - return self.store.have_request(requests, uid, recurrenceid)
4.80 + def _have_request(self, uid, recurrenceid=None, type=None, strict=False):
4.81 + return self.store.have_request(self._get_requests(), uid, recurrenceid, type, strict)
4.82
4.83 def _get_request_summary(self):
4.84