comparison MPIWGProjects.py @ 250:2e507e256726

added filtering by category (including substring) to project calendar display.
author casties
date Fri, 25 Apr 2014 15:30:43 +0200
parents f07dc0d2c60c
children 7288e7729960
comparison
equal deleted inserted replaced
249:f07dc0d2c60c 250:2e507e256726
660 def getProjectCalendar(self): 660 def getProjectCalendar(self):
661 """Return the project calendar object (MPIWGIcsManager)""" 661 """Return the project calendar object (MPIWGIcsManager)"""
662 return self.get('calendar', None) 662 return self.get('calendar', None)
663 663
664 664
665 def editProjectCalendar(self, url=None, only_upcoming=None, show_num=None, RESPONSE=None): 665 def editProjectCalendar(self, url=None, only_upcoming=None, show_num=None, cat_match=None, RESPONSE=None):
666 """Change the project calendar.""" 666 """Change the project calendar."""
667 cal = self.get('calendar', None) 667 cal = self.get('calendar', None)
668 if url: 668 if url:
669 if cal is None: 669 if cal is None:
670 # create calendar 670 # create calendar
681 681
682 # show only upcoming 682 # show only upcoming
683 cal.setFlag('only_upcoming', (only_upcoming == 'yes')) 683 cal.setFlag('only_upcoming', (only_upcoming == 'yes'))
684 # number of events 684 # number of events
685 cal.setFlag('show_num', getInt(show_num, 5)) 685 cal.setFlag('show_num', getInt(show_num, 5))
686 # match (project number) in event category
687 if cat_match:
688 cal.setFlag('cat_match', unicode(cat_match))
689 else:
690 cal.setFlag('cat_match', None)
686 691
687 elif cal is not None: 692 elif cal is not None:
688 # no url - remove calendar 693 # no url - remove calendar
689 del self['calendar'] 694 del self['calendar']
690 695
692 self.redirect(RESPONSE, 'editCalendarForm') 697 self.redirect(RESPONSE, 'editCalendarForm')
693 698
694 699
695 700
696 701
697 def getProjectNumberMatcher(self, s): 702 def getProjectNumberMatcher(self, num, getter=None):
698 """Return a function that matches a project number. 703 """Return a function that matches a project number pattern.
699 704
700 Matches exactly except when s ends with '*'. 705 Matches exactly except when num ends with '*'. Uses function getter on arguments.
701 """ 706 """
702 if s is None: 707 if num is None:
703 return None 708 return None
704 709
705 if s.endswith('*'): 710 if num.endswith('*'):
706 rs = re.sub(r'\.', r'\.', s[:-1]) + r'\b' 711 rs = re.sub(r'\.', r'\.', num[:-1]) + r'\b'
707 return lambda x : re.match(rs, x) 712 if getter is None:
708 713 return lambda x : re.match(rs, x)
709 else: 714 else:
710 return lambda x : s == x 715 return lambda x : re.match(rs, getter(x))
716
717 else:
718 if getter is None:
719 return lambda x : num == x
720 else:
721 return lambda x : num == getter(x)
711 722
712 723
713 def _moveObjectPlace(self, objectList, objectId, direction): 724 def _moveObjectPlace(self, objectList, objectId, direction):
714 """Move object with objectId from objectList in direction 725 """Move object with objectId from objectList in direction
715 by changing its place attribute.""" 726 by changing its place attribute."""