# HG changeset patch # User dwinter # Date 1401183237 -7200 # Node ID c15138774864bcdd0a2a05462d00c3e836c0e2f3 # Parent 065c4284238fc49d2a8d023e9666799e0b9ec3ab# Parent e5b444dab055a3fb2e07f28da4abaff846a9f300 Merge with e5b444dab055a3fb2e07f28da4abaff846a9f300 diff -r 065c4284238f -r c15138774864 MPIWGProjects.py --- a/MPIWGProjects.py Tue May 27 11:33:16 2014 +0200 +++ b/MPIWGProjects.py Tue May 27 11:33:57 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,70 @@ 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, cat_match=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)) + # 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 + del self['calendar'] + + if RESPONSE is not None: + self.redirect(RESPONSE, 'editCalendarForm') + + + + + def getProjectNumberMatcher(self, num, getter=None): + """Return a function that matches a project number pattern. + + Matches exactly except when num ends with '*'. Uses function getter on arguments. + """ + if num is None: + return None + + 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: + if getter is None: + return lambda x : num == x + else: + return lambda x : num == getter(x) + def _moveObjectPlace(self, objectList, objectId, direction): """Move object with objectId from objectList in direction diff -r 065c4284238f -r c15138774864 MPIWGStaff.py --- a/MPIWGStaff.py Tue May 27 11:33:16 2014 +0200 +++ b/MPIWGStaff.py Tue May 27 11:33:57 2014 +0200 @@ -19,7 +19,7 @@ import datetime from Products.ZDBInterface.ZDBInterfaceFolder import ZDBInterfaceFolder -from Products.MPIWGManager.MPIWGIcsManager import MPIWGIcsManager +from Products.MPIWGManager import MPIWGIcsManager from SrvTxtUtils import getInt, unicodify, utf8ify, sqlName, getPlaintext import MPIWGHelper @@ -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""" @@ -613,7 +606,7 @@ cal = self.getTalksCal() if cal is None: # create new calendar - cal = MPIWGIcsManager(cal_id, '', url, defaultProps=calendar_props) + cal = MPIWGIcsManager.MPIWGIcsManager(cal_id, '', url, defaultProps=MPIWGIcsManager.calendar_props) self.folder.get('calendars')[cal_id] = cal else: @@ -621,7 +614,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.MPIWGIcsManager(cal_id, '', url, defaultProps=MPIWGIcsManager.calendar_props) self.folder.get('calendars')[cal_id] = cal # show only upcoming diff -r 065c4284238f -r c15138774864 zpt/project/edit_calendar.zpt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zpt/project/edit_calendar.zpt Tue May 27 11:33:57 2014 +0200 @@ -0,0 +1,41 @@ + + + + + + + +
+

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: +

+

+ 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 065c4284238f -r c15138774864 zpt/project/edit_template.zpt --- a/zpt/project/edit_template.zpt Tue May 27 11:33:16 2014 +0200 +++ b/zpt/project/edit_template.zpt Tue May 27 11:33:57 2014 +0200 @@ -24,6 +24,8 @@ tal:attributes="href string:$root/manageRelatedProjects">Related projects Info blocks + Calendar Tags + + +

OLD! Related digital sources

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

Keywords

diff -r 065c4284238f -r c15138774864 zpt/www/main_template.zpt --- a/zpt/www/main_template.zpt Tue May 27 11:33:16 2014 +0200 +++ b/zpt/www/main_template.zpt Tue May 27 11:33:57 2014 +0200 @@ -5,7 +5,7 @@ global crumbs template/getBreadcrumbs | nothing; section here/getSection | nothing; sections here/getSections | nothing; - lang here/getLang | nothing; + lang here/getLang | nothing; langroot python:here.getMPIWGRoot().aq_parent.absolute_url(); allsecs python:{'en':{ 'institute':'institute', 'staff':'staff', @@ -60,8 +60,8 @@
@@ -123,7 +123,8 @@ | Bibliothek (intern) | Überblick | Kontakt - | Impressum/Lizenz + | Impressum + | Lizenzen