Mercurial > hg > MPIWGWeb
changeset 249:f07dc0d2c60c
add project calendar (ticket #137).
author | casties |
---|---|
date | Wed, 23 Apr 2014 16:53:10 +0200 |
parents | a14e462fca1c |
children | 2e507e256726 |
files | MPIWGProjects.py MPIWGStaff.py zpt/project/edit_calendar.zpt zpt/project/edit_template.zpt zpt/project/project_index_html.zpt |
diffstat | 5 files changed, 118 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- /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 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html metal:use-macro="here/edit_template/macros/page"> +<head> +</head> +<body> + <tal:block metal:fill-slot="navsel" tal:define="global menusel string:calendar" /> + <tal:block metal:fill-slot="body"> + <form tal:attributes="action string:$root/editProjectCalendar" method="post" tal:define="cal here/getProjectCalendar"> + <h3>Project calendar</h3> + <p> + Calendar URL: <input name="url" tal:attributes="value cal/url | nothing" size="80" /> + </p> + <p> + URL has to link to publicly accessible calendar in iCalendar format.<br /> (e.g. + https://sogo.mpiwg-berlin.mpg.de/SOGo/dav/public/mpiwg-calendar/Calendar/A5B-52288800-1-2F304600.ics) + </p> + <p tal:condition="cal">Remove the calendar URL to switch off calendar display.</p> + <p tal:condition="not:cal">Calendar display properties can be changed after the calendar has been created.</p> + <p tal:condition="cal"> + <tal:block tal:define="name string:only_upcoming; value python:test(cal.getFlag('only_upcoming'), 'yes', 'no');"> + Show only upcoming events in the calendar: <span metal:use-macro="here/en/common_template/macros/yesno_input_radio" /> + </tal:block> + </p> + <p tal:condition="cal"> + Number of events to show: <input name="show_num" size="2" tal:attributes="value python:cal.getFlag('show_num', 5)" /> + </p> + <p> + <input type="submit" value="submit" /> + </p> + </form> + + </tal:block> +</body> +</html>
--- 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</a></span> <span tal:attributes="class python:test('infoblocks'==menusel, 'mainmenusel', 'mainmenu')"><a tal:attributes="href string:$root/manageInfoBlocks">Info blocks</a></span> + <span tal:attributes="class python:test('calendar'==menusel, 'mainmenusel', 'mainmenu')"><a + tal:attributes="href string:$root/editCalendarForm">Calendar</a></span> <span tal:attributes="class python:test('themes'==menusel, 'mainmenusel', 'mainmenu')"><a tal:attributes="href string:$root/tagTheProject">Tags</a></span> <span class="mainmenu"><a target="_blank"
--- a/zpt/project/project_index_html.zpt Tue Mar 18 10:18:35 2014 +0100 +++ b/zpt/project/project_index_html.zpt Wed Apr 23 16:53:10 2014 +0200 @@ -177,6 +177,26 @@ </div> </div> + <!-- project calendar --> + <div class="sideblock" tal:define="calendar here/getProjectCalendar" tal:condition="calendar"> + <tal:block tal:define="upcoming python:calendar.getFlag('only_upcoming', False); + show_num python:calendar.getFlag('show_num', 2); + events python:test(upcoming, calendar.getAllItemsFromTodayOn()[:show_num], calendar.getNext(show_num, reverse=False))" + tal:condition="events"> + <h2 class="line" tal:condition="upcoming">Upcoming events</h2> + <h2 class="line" tal:condition="not:upcoming">Events</h2> + <div class="item" tal:repeat="event events"> + <tal:block tal:define="url python:event.getValue('url'); loc python:event.getValue('location');"> + <span tal:content="python:event.getDate()" />: + <span tal:replace="loc" /> <span tal:condition="loc">–</span> + <a target="_blank" tal:omit-tag="not:url" tal:attributes="href url"> + <i><span tal:replace="python:event.getValue('title')" /></i> + </a> + </tal:block> + </div> + </tal:block> + </div> + <!-- related digital sources --> <div class="sideblock" tal:define="sources here/getRelatedDigitalSources" tal:condition="sources"> <h2>OLD! Related digital sources</h2> @@ -192,6 +212,7 @@ Funding </div> </div> + <!-- sideblock --> <div class="sideblock" tal:define="tags python:here.thesaurus.getTagsAsHash(here.getId())" tal:condition="tags"> <h2>Keywords</h2>