# HG changeset patch # User casties # Date 1398432643 -7200 # Node ID 2e507e25672653ca59798820e7a81d18a11995b0 # Parent f07dc0d2c60c4a903234f18b138acec2ac8e1c02 added filtering by category (including substring) to project calendar display. diff -r f07dc0d2c60c -r 2e507e256726 MPIWGProjects.py --- a/MPIWGProjects.py Wed Apr 23 16:53:10 2014 +0200 +++ b/MPIWGProjects.py Fri Apr 25 15:30:43 2014 +0200 @@ -662,7 +662,7 @@ return self.get('calendar', None) - def editProjectCalendar(self, url=None, only_upcoming=None, show_num=None, RESPONSE=None): + def editProjectCalendar(self, url=None, only_upcoming=None, show_num=None, cat_match=None, RESPONSE=None): """Change the project calendar.""" cal = self.get('calendar', None) if url: @@ -683,6 +683,11 @@ cal.setFlag('only_upcoming', (only_upcoming == 'yes')) # number of events cal.setFlag('show_num', getInt(show_num, 5)) + # match (project number) in event category + if cat_match: + cal.setFlag('cat_match', unicode(cat_match)) + else: + cal.setFlag('cat_match', None) elif cal is not None: # no url - remove calendar @@ -694,20 +699,26 @@ - def getProjectNumberMatcher(self, s): - """Return a function that matches a project number. + def getProjectNumberMatcher(self, num, getter=None): + """Return a function that matches a project number pattern. - Matches exactly except when s ends with '*'. + Matches exactly except when num ends with '*'. Uses function getter on arguments. """ - if s is None: + if num is None: return None - if s.endswith('*'): - rs = re.sub(r'\.', r'\.', s[:-1]) + r'\b' - return lambda x : re.match(rs, x) + if num.endswith('*'): + rs = re.sub(r'\.', r'\.', num[:-1]) + r'\b' + if getter is None: + return lambda x : re.match(rs, x) + else: + return lambda x : re.match(rs, getter(x)) else: - return lambda x : s == x + if getter is None: + return lambda x : num == x + else: + return lambda x : num == getter(x) def _moveObjectPlace(self, objectList, objectId, direction): diff -r f07dc0d2c60c -r 2e507e256726 zpt/project/edit_calendar.zpt --- a/zpt/project/edit_calendar.zpt Wed Apr 23 16:53:10 2014 +0200 +++ b/zpt/project/edit_calendar.zpt Fri Apr 25 15:30:43 2014 +0200 @@ -25,6 +25,12 @@

Number of events to show:

+

+ Show only events matching category:
+ If all events have the project number as their category "3.1" would show only events of project 3.1 while "3*" would + show all events of project 3 and all of its subprojects.
+ Leave empty to show all events in the calendar. +

diff -r f07dc0d2c60c -r 2e507e256726 zpt/project/project_index_html.zpt --- a/zpt/project/project_index_html.zpt Wed Apr 23 16:53:10 2014 +0200 +++ b/zpt/project/project_index_html.zpt Fri Apr 25 15:30:43 2014 +0200 @@ -180,8 +180,9 @@

Upcoming events

Events