add method to find an agenda url for an event
This commit is contained in:
parent
4a44772448
commit
6cd1a8c366
|
@ -6,6 +6,7 @@ from zope import schema
|
|||
from zope.interface import implements
|
||||
from Products.Five.browser import BrowserView
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
from Acquisition import aq_parent
|
||||
|
||||
from zope.i18n.locales import locales
|
||||
from plone.directives import form, dexterity
|
||||
|
@ -62,6 +63,17 @@ class BaseEvent(Item):
|
|||
def end_hour(self):
|
||||
return '%dh%02d' % (self.end.hour, self.end.minute)
|
||||
|
||||
def agenda_url(self):
|
||||
parent = aq_parent(self)
|
||||
if parent.portal_type == 'tabellio.agenda.folder':
|
||||
return parent.absolute_url()
|
||||
catalog = getToolByName(self, 'portal_catalog')
|
||||
try:
|
||||
return catalog(portal_type='tabellio.agenda.folder')[0].getURL()
|
||||
except IndexError:
|
||||
return '#'
|
||||
|
||||
|
||||
def listen_url(self):
|
||||
return '#'
|
||||
|
||||
|
@ -74,8 +86,6 @@ class Event(BaseEvent):
|
|||
|
||||
class EventBaseView:
|
||||
def next_event_url(self, portal_type=None):
|
||||
catalog = getToolByName(self.context, 'portal_catalog')
|
||||
|
||||
# do not go more than 100 days in the future
|
||||
end = self.context.start + datetime.timedelta(100)
|
||||
start = self.context.start
|
||||
|
@ -96,8 +106,6 @@ class EventBaseView:
|
|||
return None
|
||||
|
||||
def previous_event_url(self, portal_type=None):
|
||||
catalog = getToolByName(self.context, 'portal_catalog')
|
||||
|
||||
end = self.context.start
|
||||
# do not go back more than 100 days in the past
|
||||
start = self.context.start - datetime.timedelta(100)
|
||||
|
|
Reference in New Issue