# HG changeset patch # User casties # Date 1398264790 -7200 # Node ID f07dc0d2c60c4a903234f18b138acec2ac8e1c02 # Parent a14e462fca1c063a8315a66d8ecbc926eb3158f4 add project calendar (ticket #137). diff -r a14e462fca1c -r f07dc0d2c60c MPIWGProjects.py --- a/MPIWGProjects.py Tue Mar 18 10:18:35 2014 +0100 +++ b/MPIWGProjects.py Wed Apr 23 16:53:10 2014 +0200 @@ -24,6 +24,7 @@ from SrvTxtUtils import getInt, unicodify, utf8ify, serialize, refreshingImageFileIndexHtml, shortenString, getPlaintext from Products.ZDBInterface.ZDBInterfaceFolder import ZDBInterfaceFolder +from Products.MPIWGManager import MPIWGIcsManager import xmlhelper # Methoden zur Verwaltung der projekt xml from HashTree import HashTree @@ -401,6 +402,8 @@ editAddAdditionalPublications = PageTemplateFile('zpt/project/pubman/add_publications', globals()) security.declareProtected('View management screens', 'edit') edit = editDescription + security.declareProtected('View management screens', 'editCalendarForm') + editCalendarForm = PageTemplateFile('zpt/project/edit_calendar', globals()) # management templates security.declareProtected('View management screens', 'loadNewFileForm') loadNewFileForm = PageTemplateFile('zpt/project/manage_newfile', globals()) @@ -421,9 +424,9 @@ if argv: for arg in definedFields: try: - setattr(self, arg, argv[arg]) + setattr(self, arg, argv[arg]) except: - setattr(self, arg, "") + setattr(self, arg, "") else: for arg in definedFields: setattr(self, arg, '') @@ -653,6 +656,59 @@ else: return t + + def getProjectCalendar(self): + """Return the project calendar object (MPIWGIcsManager)""" + return self.get('calendar', None) + + + def editProjectCalendar(self, url=None, only_upcoming=None, show_num=None, RESPONSE=None): + """Change the project calendar.""" + cal = self.get('calendar', None) + if url: + if cal is None: + # create calendar + cal = MPIWGIcsManager.MPIWGIcsManager('calendar', 'Project Calendar', url, defaultProps=MPIWGIcsManager.calendar_props) + self['calendar'] = cal + + else: + # calendar exists + if cal.url != url: + # remove and re-create + del self['calendar'] + cal = MPIWGIcsManager.MPIWGIcsManager('calendar', 'Project Calendar', url, defaultProps=MPIWGIcsManager.calendar_props) + self['calendar'] = cal + + # show only upcoming + cal.setFlag('only_upcoming', (only_upcoming == 'yes')) + # number of events + cal.setFlag('show_num', getInt(show_num, 5)) + + elif cal is not None: + # no url - remove calendar + del self['calendar'] + + if RESPONSE is not None: + self.redirect(RESPONSE, 'editCalendarForm') + + + + + def getProjectNumberMatcher(self, s): + """Return a function that matches a project number. + + Matches exactly except when s ends with '*'. + """ + if s is None: + return None + + if s.endswith('*'): + rs = re.sub(r'\.', r'\.', s[:-1]) + r'\b' + return lambda x : re.match(rs, x) + + else: + return lambda x : s == x + def _moveObjectPlace(self, objectList, objectId, direction): """Move object with objectId from objectList in direction diff -r a14e462fca1c -r f07dc0d2c60c MPIWGStaff.py --- a/MPIWGStaff.py Tue Mar 18 10:18:35 2014 +0100 +++ b/MPIWGStaff.py Wed Apr 23 16:53:10 2014 +0200 @@ -38,13 +38,6 @@ manage_addMPIWGStaffForm = MPIWGStaff_old.manage_addMPIWGStaffForm manage_addMPIWGStaff = MPIWGStaff_old.manage_addMPIWGStaff -# MPIWGManager properties for ICS-calendars -# (ID_EN, ID_DE, VALUE_EN, VALUE_DE, WEIGHT, ID) -calendar_props = [('Description', 'Beschreibung', None, None, 0, 'description'), - ('Location', 'Ort', None, None, 0, 'location'), - ('URL', 'URL', None, None, 0, 'url'), - ('Time', 'Zeit', None, None, 0, 'time')] - class MPIWGStaffFolder(ZDBInterfaceFolder): """Folder of staff objects""" @@ -603,7 +596,7 @@ cal = self.getTalksCal() if cal is None: # create new calendar - cal = MPIWGIcsManager(cal_id, '', url, defaultProps=calendar_props) + cal = MPIWGIcsManager(cal_id, '', url, defaultProps=MPIWGIcsManager.calendar_props) self.folder.get('calendars')[cal_id] = cal else: @@ -611,7 +604,7 @@ if cal.url != url: # remove and re-create del self.folder.get('calendars')[cal_id] - cal = MPIWGIcsManager(cal_id, '', url, defaultProps=calendar_props) + cal = MPIWGIcsManager(cal_id, '', url, defaultProps=MPIWGIcsManager.calendar_props) self.folder.get('calendars')[cal_id] = cal # show only upcoming diff -r a14e462fca1c -r f07dc0d2c60c zpt/project/edit_calendar.zpt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zpt/project/edit_calendar.zpt Wed Apr 23 16:53:10 2014 +0200 @@ -0,0 +1,35 @@ + + + + + + + +
+

Project calendar

+

+ Calendar URL: +

+

+ URL has to link to publicly accessible calendar in iCalendar format.
(e.g. + https://sogo.mpiwg-berlin.mpg.de/SOGo/dav/public/mpiwg-calendar/Calendar/A5B-52288800-1-2F304600.ics) +

+

Remove the calendar URL to switch off calendar display.

+

Calendar display properties can be changed after the calendar has been created.

+

+ + Show only upcoming events in the calendar: + +

+

+ Number of events to show: +

+

+ +

+
+ +
+ + diff -r a14e462fca1c -r f07dc0d2c60c zpt/project/edit_template.zpt --- a/zpt/project/edit_template.zpt Tue Mar 18 10:18:35 2014 +0100 +++ b/zpt/project/edit_template.zpt Wed Apr 23 16:53:10 2014 +0200 @@ -24,6 +24,8 @@ tal:attributes="href string:$root/manageRelatedProjects">Related projects Info blocks + Calendar Tags + + +

OLD! Related digital sources

@@ -192,6 +212,7 @@ Funding
+

Keywords