From 228e39661bcf6feb4ca79a827c137b7b92b84c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 20 Nov 2011 20:18:21 +0100 Subject: [PATCH] add event search --- tabellio/searchform/configure.zcml | 7 + tabellio/searchform/docsearch.pt | 12 +- tabellio/searchform/docsearchpfb.pt | 4 - tabellio/searchform/eventsearch.pt | 126 ++++++++++++++++++ tabellio/searchform/form.py | 72 ++++++++++ .../searchform/form_templates/view_form.pt | 8 ++ 6 files changed, 219 insertions(+), 10 deletions(-) create mode 100644 tabellio/searchform/eventsearch.pt create mode 100644 tabellio/searchform/form_templates/view_form.pt diff --git a/tabellio/searchform/configure.zcml b/tabellio/searchform/configure.zcml index e6b97d5..d55fc51 100644 --- a/tabellio/searchform/configure.zcml +++ b/tabellio/searchform/configure.zcml @@ -86,6 +86,13 @@ template="guided-search.pt" permission="zope2.View"/> + +
Documents parlementaires
+
+
-
-
@@ -58,7 +58,9 @@
Dossiers parlementaires
+
+
-
-
@@ -93,7 +93,9 @@
Questions & interpellations
+
+
-
-
diff --git a/tabellio/searchform/docsearchpfb.pt b/tabellio/searchform/docsearchpfb.pt index baeb4b0..13a85af 100644 --- a/tabellio/searchform/docsearchpfb.pt +++ b/tabellio/searchform/docsearchpfb.pt @@ -51,10 +51,8 @@
-
-
@@ -89,10 +87,8 @@
-
-
diff --git a/tabellio/searchform/eventsearch.pt b/tabellio/searchform/eventsearch.pt new file mode 100644 index 0000000..385af5f --- /dev/null +++ b/tabellio/searchform/eventsearch.pt @@ -0,0 +1,126 @@ + + + + + + + +
+

Événements

+
+ +
+
+ + +
+ +
+ Nombre de résultats : +
+ +
+ +
+ +
+
+
+ +
+ +
+ + + + + + + + + diff --git a/tabellio/searchform/form.py b/tabellio/searchform/form.py index cfefb45..7fdf45b 100644 --- a/tabellio/searchform/form.py +++ b/tabellio/searchform/form.py @@ -462,6 +462,44 @@ class DeputySearchForm(form.Form): def handleApply(self, action): pass + +class IEventSearch(interface.Interface): + search_type_is_event = schema.TextLine(title=u'Search Type', default=u'1', required=False) + + start = schema.Date(title=_(u'Start'), required=False) + end = schema.Date(title=_(u'End'), required=False) + + +class EventSearchForm(form.Form): + prefix = 'event' + fields = field.Fields(IEventSearch) + ignoreContext = True + template = ViewPageTemplateFile('form_templates/view_form.pt') + + def updateWidgets(self): + super(EventSearchForm, self).updateWidgets() + self.widgets['search_type_is_event'].mode = z3c.form.interfaces.HIDDEN_MODE + + @button.buttonAndHandler(_(u'Submit')) + def handleApply(self, action): + pass + + +class DeputySearchForm(form.Form): + prefix = 'deputy' + fields = field.Fields(IDeputySearch) + ignoreContext = True + template = ViewPageTemplateFile('form_templates/view_deputy_search.pt') + + def updateWidgets(self): + super(DeputySearchForm, self).updateWidgets() + self.widgets['search_type_is_deputy'].mode = z3c.form.interfaces.HIDDEN_MODE + + @button.buttonAndHandler(_(u'Submit')) + def handleApply(self, action): + pass + + class IGlobalSearchForm(interface.Interface): search_type_is_document = schema.TextLine(title=u'Search Type', required=False) search_type_is_dossier = schema.TextLine(title=u'Search Type', required=False) @@ -694,6 +732,40 @@ class SearchView(BrowserView): def question_search_results(self): return self.search_results(search_type='question') + def event_search_form(self): + f = EventSearchForm(self.context, self.request) + f.update() + return f.render() + + def event_search_results(self): + f = EventSearchForm(self.context, self.request) + f.update() + + data, errors = f.extractData() + kw = {} + + print data + if not data.get('search_type_is_event'): + return None + + if data.get('start') and data.get('end'): + kw['start'] = {'query': [data.get('start'), data.get('end')], 'range': 'minmax'} + elif data.get('start'): + kw['start'] = {'query': data.get('start'), 'range': 'min'} + elif data.get('end'): + kw['start'] = {'query': data.get('end'), 'range': 'max'} + + kw['sort_on'] = 'start' + kw['sort_order'] = 'descending' + + kw['portal_type'] = ('tabellio.agenda.event', + 'tabellio.agenda.comevent', + 'tabellio.agenda.parlevent') + + catalog = getToolByName(self.context, 'portal_catalog') + return catalog(**kw) + + def pfbdocform_url(self): catalog = getToolByName(self.context, 'portal_catalog') try: diff --git a/tabellio/searchform/form_templates/view_form.pt b/tabellio/searchform/form_templates/view_form.pt new file mode 100644 index 0000000..824f8fe --- /dev/null +++ b/tabellio/searchform/form_templates/view_form.pt @@ -0,0 +1,8 @@ + + + + + + +