different views for agenda
This commit is contained in:
parent
1491d5c032
commit
0a1ebfde63
|
@ -13,4 +13,8 @@ tabellio.agenda.egg-info/requires.txt
|
|||
tabellio.agenda.egg-info/top_level.txt
|
||||
tabellio/agenda/__init__.py
|
||||
tabellio/agenda/event.py
|
||||
tabellio/agenda/interfaces.py
|
||||
tabellio/agenda/folder.py
|
||||
tabellio/agenda/interfaces.py
|
||||
tabellio/agenda/parlevent.py
|
||||
tabellio/agenda/portlets.py
|
||||
tabellio/agenda/utils.py
|
|
@ -33,14 +33,25 @@ class BaseEvent(Item):
|
|||
def longdatetime(self):
|
||||
# unfortunately this forces the locale
|
||||
formatter = locales.getLocale('fr').dates.getFormatter('dateTime', 'medium')
|
||||
formatter.setPattern(u'EEEE d MMM yyyy à HH:mm')
|
||||
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)
|
||||
|
|
|
@ -4,16 +4,33 @@ from zope.interface import implements
|
|||
from Products.Five.browser import BrowserView
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
|
||||
from zope.schema.interfaces import IVocabularyFactory
|
||||
from zope.schema.vocabulary import SimpleVocabulary
|
||||
|
||||
from plone.directives import form, dexterity
|
||||
from plone.dexterity.content import Container
|
||||
|
||||
from tabellio.agenda.interfaces import MessageFactory as _
|
||||
import tabellio.config.utils
|
||||
|
||||
import utils
|
||||
|
||||
class AgendaModeVocabulary(object):
|
||||
grok.implements(IVocabularyFactory)
|
||||
|
||||
def __call__(self, context):
|
||||
values = [('month', _(u'Month')), ('list', _(u'List')), ('seances', _(u'Seances'))]
|
||||
terms = []
|
||||
for key, value in values:
|
||||
terms.append(SimpleVocabulary.createTerm(key, value.encode('utf-8'), key))
|
||||
return SimpleVocabulary(terms)
|
||||
grok.global_utility(AgendaModeVocabulary, name=u'tabellio.agenda.agendaModes')
|
||||
|
||||
|
||||
class IAgendaFolder(form.Schema):
|
||||
title = schema.TextLine(title=_(u'Title'))
|
||||
mode = schema.Choice(title=_(u'Mode'),
|
||||
vocabulary='tabellio.agenda.agendaModes')
|
||||
|
||||
|
||||
class AgendaFolder(Container):
|
||||
|
@ -24,6 +41,15 @@ class View(grok.View, utils.MonthlyView):
|
|||
grok.context(IAgendaFolder)
|
||||
grok.require('zope2.View')
|
||||
|
||||
def as_list(self):
|
||||
return self.context.mode == 'list'
|
||||
|
||||
def as_month(self):
|
||||
return self.context.mode == 'month'
|
||||
|
||||
def as_seances(self):
|
||||
return self.context.mode == 'seances'
|
||||
|
||||
def update(self):
|
||||
utils.MonthlyView.update(self)
|
||||
return self.updated
|
||||
|
@ -43,3 +69,4 @@ class View(grok.View, utils.MonthlyView):
|
|||
brains = self.get_events_from_catalog(last_date, first_date, sort_on='start')
|
||||
return [x.getObject() for x in brains]
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
<div tal:replace="structure provider:plone.abovecontentbody" />
|
||||
|
||||
<div tal:condition="view/as_month">
|
||||
|
||||
<table class="ploneCalendar"
|
||||
summary="Agenda"
|
||||
id="tabellio-agenda"
|
||||
|
@ -130,6 +132,61 @@ jq('#tabellio-agenda tbody a').click(
|
|||
});
|
||||
</script>
|
||||
|
||||
</div> <!-- not:view/as_list -->
|
||||
|
||||
|
||||
<div tal:condition="python: view.as_list() or view.as_seances()">
|
||||
|
||||
<div>
|
||||
<a href="#" rel="nofollow"
|
||||
title="Previous month"
|
||||
id="agenda-calendar-previous"
|
||||
tal:define="prevMonthMonth view/prevMonthMonth;
|
||||
prevMonthYear view/prevMonthYear"
|
||||
tal:attributes="href string:?year=${prevMonthYear}&month=${prevMonthMonth}"
|
||||
i18n:attributes="title title_previous_month;">«</a>
|
||||
<span i18n:translate="" tal:omit-tag="">
|
||||
<span i18n:name="monthname" i18n:translate=""
|
||||
tal:content="view/monthName"
|
||||
tal:omit-tag="">monthname</span>
|
||||
<span i18n:name="year" i18n:translate="" tal:content="view/year" tal:omit-tag="">year</span>
|
||||
</span>
|
||||
|
||||
<a href="#" rel="nofollow" title="Next month" id="agenda-calendar-next"
|
||||
tal:define="nextMonthMonth view/nextMonthMonth;
|
||||
nextMonthYear view/nextMonthYear"
|
||||
tal:attributes="href string:?year=${nextMonthYear}&month=${nextMonthMonth}"
|
||||
i18n:attributes="title title_next_month;">»</a>
|
||||
</div>
|
||||
|
||||
<table id="events-table-list" tal:condition="view/as_list">
|
||||
<tr tal:repeat="event view/getMonthEvents"
|
||||
tal:attributes="id string:event-${event/id};
|
||||
class event/klass">
|
||||
<td class="date"><span tal:content="event/longdatetime"/></td>
|
||||
<td>
|
||||
<h3 tal:content="event/title"/>
|
||||
<p tal:condition="event/description" class="description" tal:content="event/description"></p>
|
||||
<a href="#" tal:attributes="href event/absolute_url">Détails</a>
|
||||
</td>
|
||||
<td>
|
||||
<p tal:condition="event/place" class="place" tal:content="event/place"></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table id="events-table-seances" tal:condition="view/as_seances">
|
||||
<tr tal:repeat="event view/getMonthEvents"
|
||||
tal:attributes="id string:event-${event/id};
|
||||
class event/klass">
|
||||
<td class="date"><a tal:attributes="href event/absolute_url"><span tal:content="event/shortdatetime"/></a></td>
|
||||
<td class="streaming"><a href="#">Streaming</a></td>
|
||||
<td class="cri"><a href="#">Compte-rendu intégral</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div tal:replace="structure provider:plone.belowcontentbody" />
|
||||
|
||||
|
|
|
@ -21,3 +21,6 @@ class IParlEvent(IBaseEvent):
|
|||
class ParlEvent(BaseEvent):
|
||||
implements(IParlEvent)
|
||||
|
||||
def klass(self):
|
||||
return 'parlementary-event'
|
||||
|
||||
|
|
Reference in New Issue