From 40e1df608de3b588954f16c0c617f85904907d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 18 Jul 2012 09:53:57 +0200 Subject: [PATCH] add new 'bureau event' type --- tabellio/agenda/burevent.py | 20 +++++++ tabellio/agenda/event.py | 11 +++- tabellio/agenda/folder.py | 23 +++++--- tabellio/agenda/folder_templates/view.pt | 2 + tabellio/agenda/indexer.py | 1 + tabellio/agenda/parlevent.py | 2 + tabellio/agenda/profiles/default/types.xml | 1 + .../types/tabellio.agenda.burevent.xml | 52 +++++++++++++++++++ .../default/types/tabellio.agenda.folder.xml | 1 + tabellio/agenda/utils.py | 1 + 10 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 tabellio/agenda/burevent.py create mode 100644 tabellio/agenda/profiles/default/types/tabellio.agenda.burevent.xml diff --git a/tabellio/agenda/burevent.py b/tabellio/agenda/burevent.py new file mode 100644 index 0000000..dc39dec --- /dev/null +++ b/tabellio/agenda/burevent.py @@ -0,0 +1,20 @@ +from zope import schema +from zope.interface import implements +from z3c.relationfield.schema import RelationChoice + +from plone.formwidget.contenttree import ObjPathSourceBinder + +from tabellio.agenda.interfaces import MessageFactory as _ +from parlevent import IParlEvent, ParlEvent + + +class IBurEvent(IParlEvent): + pass + + +class BurEvent(ParlEvent): + implements(IBurEvent) + + def klass(self): + return 'bureau-event' + diff --git a/tabellio/agenda/event.py b/tabellio/agenda/event.py index cdebf36..4b400c6 100644 --- a/tabellio/agenda/event.py +++ b/tabellio/agenda/event.py @@ -115,7 +115,10 @@ class EventBaseView: start = self.context.start if portal_type is None: - portal_type = ('tabellio.agenda.parlevent', 'tabellio.agenda.comevent') + portal_type = ('tabellio.agenda.parlevent', + 'tabellio.agenda.comevent', + 'tabellio.agenda.burevent', + ) monthly_view = MonthlyView(self.context, init_calendar=True) serie_of_events = monthly_view.get_events_from_catalog( @@ -135,7 +138,11 @@ class EventBaseView: start = self.context.start - datetime.timedelta(100) if portal_type is None: - portal_type = ('tabellio.agenda.event', 'tabellio.agenda.parlevent', 'tabellio.agenda.comevent') + portal_type = ('tabellio.agenda.event', + 'tabellio.agenda.parlevent', + 'tabellio.agenda.comevent', + 'tabellio.agenda.burevent' + ) monthly_view = MonthlyView(self.context, init_calendar=True) serie_of_events = monthly_view.get_events_from_catalog( diff --git a/tabellio/agenda/folder.py b/tabellio/agenda/folder.py index 2bdacdf..dbd0ccc 100644 --- a/tabellio/agenda/folder.py +++ b/tabellio/agenda/folder.py @@ -34,8 +34,9 @@ class AgendaSelectorVocabulary(object): def __call__(self, context): values = [('all', _(u'All events')), ('parlevent', _(u'Parlementary Events')), + ('burevent', _(u'Bureau Events')), ('comevent', _(u'Commission Events')), - ('parlcomevent', _(u'Parlmentary and Commission Events')), + ('parlcomevent', _(u'Parlmentary, Commission and Bureau Events')), ('genevent', _(u'General Events'))] terms = [] for key, value in values: @@ -89,25 +90,35 @@ class View(grok.View, utils.MonthlyView): return ['parl'] elif self.context.selector == 'comevent': return ['com'] + elif self.context.selector == 'burevent': + return ['bur'] elif self.context.selector == 'genevent': return ['gen'] elif self.context.selector == 'parlcomevent': - return ['parl', 'com'] + return ['parl', 'com', 'bur'] else: - return ['parl', 'com', 'gen'] + return ['parl', 'com', 'bur', 'gen'] def get_events_from_catalog(self, start, end, **keywords): if self.context.selector == 'parlevent': portal_type = ['tabellio.agenda.parlevent'] elif self.context.selector == 'comevent': portal_type = ['tabellio.agenda.comevent'] + elif self.context.selector == 'burevent': + portal_type = ['tabellio.agenda.burevent'] elif self.context.selector == 'genevent': portal_type = ['tabellio.agenda.event'] elif self.context.selector == 'parlcomevent': - portal_type = ['tabellio.agenda.parlevent', 'tabellio.agenda.comevent'] + portal_type = ['tabellio.agenda.parlevent', + 'tabellio.agenda.comevent', + 'tabellio.agenda.burevent', + ] else: - portal_type = ['tabellio.agenda.event', 'tabellio.agenda.parlevent', - 'tabellio.agenda.comevent'] + portal_type = ['tabellio.agenda.event', + 'tabellio.agenda.parlevent', + 'tabellio.agenda.burevent', + 'tabellio.agenda.comevent', + ] return utils.MonthlyView.get_events_from_catalog(self, start, end, portal_type=portal_type, **keywords) diff --git a/tabellio/agenda/folder_templates/view.pt b/tabellio/agenda/folder_templates/view.pt index 376c17f..29fa8bf 100644 --- a/tabellio/agenda/folder_templates/view.pt +++ b/tabellio/agenda/folder_templates/view.pt @@ -114,6 +114,7 @@ @@ -196,6 +197,7 @@ jq('#tabellio-agenda tbody a').click( diff --git a/tabellio/agenda/indexer.py b/tabellio/agenda/indexer.py index faffb39..70d2012 100644 --- a/tabellio/agenda/indexer.py +++ b/tabellio/agenda/indexer.py @@ -7,6 +7,7 @@ from z3c.form.interfaces import IFormLayer from event import IEvent from parlevent import IParlEvent from comevent import IComEvent +from burevent import IBurEvent class IEventIndexer(Interface): """Dexterity behavior interface for enabling the dynamic SearchableText diff --git a/tabellio/agenda/parlevent.py b/tabellio/agenda/parlevent.py index 1039fc1..77b39dc 100644 --- a/tabellio/agenda/parlevent.py +++ b/tabellio/agenda/parlevent.py @@ -59,9 +59,11 @@ class ParlEventBaseView(EventBaseView): def next_event_url(self): return EventBaseView.next_event_url(self, portal_type=('tabellio.agenda.parlevent', + 'tabellio.agenda.burevent', 'tabellio.agenda.comevent')) def previous_event_url(self): return EventBaseView.previous_event_url(self, portal_type=('tabellio.agenda.parlevent', + 'tabellio.agenda.burevent', 'tabellio.agenda.comevent')) diff --git a/tabellio/agenda/profiles/default/types.xml b/tabellio/agenda/profiles/default/types.xml index c9fb765..5e6b7c8 100644 --- a/tabellio/agenda/profiles/default/types.xml +++ b/tabellio/agenda/profiles/default/types.xml @@ -2,5 +2,6 @@ + diff --git a/tabellio/agenda/profiles/default/types/tabellio.agenda.burevent.xml b/tabellio/agenda/profiles/default/types/tabellio.agenda.burevent.xml new file mode 100644 index 0000000..b1f6225 --- /dev/null +++ b/tabellio/agenda/profiles/default/types/tabellio.agenda.burevent.xml @@ -0,0 +1,52 @@ + + + + + Bureau Event + A bureau event + document_icon.gif + False + True + True + + + + tabellio.agenda.burevent.IBurEvent + + + tabellio.agenda.burevent.BurEvent + + + cmf.AddPortalContent + + + + + + + + + view + False + + + + + + + + + + + + + + + + + + + diff --git a/tabellio/agenda/profiles/default/types/tabellio.agenda.folder.xml b/tabellio/agenda/profiles/default/types/tabellio.agenda.folder.xml index da3c1fe..3049145 100644 --- a/tabellio/agenda/profiles/default/types/tabellio.agenda.folder.xml +++ b/tabellio/agenda/profiles/default/types/tabellio.agenda.folder.xml @@ -11,6 +11,7 @@ True + diff --git a/tabellio/agenda/utils.py b/tabellio/agenda/utils.py index 9cf538f..ac60ab5 100644 --- a/tabellio/agenda/utils.py +++ b/tabellio/agenda/utils.py @@ -46,6 +46,7 @@ class MonthlyView: if portal_type is None: portal_type = ('tabellio.agenda.event', 'tabellio.agenda.parlevent', + 'tabellio.agenda.burevent', 'tabellio.agenda.comevent') catalog = getToolByName(self.context, 'portal_catalog')