61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from five import grok
|
|
from zope import schema
|
|
from zope.interface import implements
|
|
from Products.Five.browser import BrowserView
|
|
from Products.CMFCore.utils import getToolByName
|
|
|
|
from zope.i18n.locales import locales
|
|
from plone.directives import form, dexterity
|
|
from plone.dexterity.content import Item
|
|
|
|
from tabellio.agenda.interfaces import MessageFactory as _
|
|
|
|
|
|
class IBaseEvent(form.Schema):
|
|
title = schema.TextLine(title=_(u'Title'))
|
|
description = schema.Text(title=_(u'Description'))
|
|
|
|
place = schema.TextLine(title=_(u'Place'))
|
|
|
|
start = schema.Datetime(title=_(u'Start'))
|
|
end = schema.Datetime(title=_(u'End'))
|
|
|
|
|
|
|
|
class IEvent(IBaseEvent):
|
|
pass
|
|
|
|
|
|
|
|
class BaseEvent(Item):
|
|
def longdatetime(self):
|
|
# unfortunately this forces the locale
|
|
formatter = locales.getLocale('fr').dates.getFormatter('dateTime', 'medium')
|
|
formatter.setPattern(u'EEEE d MMMM yyyy à HH:mm')
|
|
return formatter.format(self.start)
|
|
longdatetime = property(longdatetime)
|
|
|
|
def shortdatetime(self):
|
|
# unfortunately this forces the locale
|
|
formatter = locales.getLocale('fr').dates.getFormatter('dateTime', 'medium')
|
|
formatter.setPattern(u'd MMMM yyyy')
|
|
return formatter.format(self.start)
|
|
shortdatetime = property(shortdatetime)
|
|
|
|
|
|
|
|
class Event(BaseEvent):
|
|
implements(IEvent)
|
|
|
|
def klass(self):
|
|
return 'generic-event'
|
|
|
|
|
|
class View(grok.View):
|
|
grok.context(IEvent)
|
|
grok.require('zope2.View')
|
|
|
|
|