diff --git a/tabellio/searchform/docsearch.pt b/tabellio/searchform/docsearch.pt index ce3ec39..9901899 100644 --- a/tabellio/searchform/docsearch.pt +++ b/tabellio/searchform/docsearch.pt @@ -18,6 +18,44 @@
Documents parlementaires
+ + +
+ +
+ Nombre de résultats : +
+ +
+ +
+ + + +
+
Dossiers parlementaires
diff --git a/tabellio/searchform/form.py b/tabellio/searchform/form.py index daf7d0f..88e886f 100644 --- a/tabellio/searchform/form.py +++ b/tabellio/searchform/form.py @@ -5,6 +5,7 @@ from plone.z3cform.layout import wrap_form from Products.CMFCore.utils import getToolByName from z3c.form.ptcompat import ViewPageTemplateFile +import z3c.form.interfaces from z3c.relationfield.schema import RelationChoice, RelationList from plone.formwidget.contenttree import ObjPathSourceBinder @@ -33,12 +34,29 @@ def possible_document_types(context): terms.append(SimpleVocabulary.createTerm(doctype_id, doctype_id, doctype)) return SimpleVocabulary(terms) +@grok.provider(IContextSourceBinder) +def possible_dossier_types(context): + catalog = getToolByName(context, 'portal_catalog') + possible_dostypes = catalog.uniqueValuesFor('dostype') + terms = [] + for dostype in possible_dostypes: + dostype_id = dostype.encode('ascii', 'replace') + terms.append(SimpleVocabulary.createTerm(dostype_id, dostype_id, dostype)) + return SimpleVocabulary(terms) + + +def get_catalog_kwargs(context, data): + kw = {} + + return kw + class IDocumentSearch(interface.Interface): + search_type = schema.TextLine(title=u'Search Type', default=u'document') nodoc = schema.TextLine(title=_(u'Document Number'), required=False) nosuite = schema.TextLine(title=_(u'Suite Number'), required=False) - doctype = schema.Set(title=_(u'Type'), required=False, - value_type=schema.Choice(values=[_(u'Lorem'), _(u'Ipsum')])) + doctype = schema.Choice(title=_(u'Type'), required=False, + source=possible_document_types) #subjects = ttitle = schema.TextLine(title=_(u'Title'), required=False) text = schema.TextLine(title=_(u'Text'), required=False) @@ -53,10 +71,15 @@ class IDocumentSearch(interface.Interface): class DocumentSearchForm(form.Form): + method = 'get' fields = field.Fields(IDocumentSearch) ignoreContext = True template = ViewPageTemplateFile('form_templates/view_effectivesearch.pt') + def updateWidgets(self): + super(DocumentSearchForm, self).updateWidgets() + self.widgets['search_type'].mode = z3c.form.interfaces.HIDDEN_MODE + @button.buttonAndHandler(_(u'Search')) def handleApply(self, action): data, errors = self.extractData() @@ -69,8 +92,8 @@ class DocumentSearchForm(form.Form): class IDossierSearch(interface.Interface): nodos = schema.TextLine(title=_(u'Dossier Number'), required=False) - dostype = schema.Set(title=_(u'Type'), required=False, - value_type=schema.Choice(values=[_(u'Lorem'), _(u'Ipsum')])) + dostype = schema.Choice(title=_(u'Type'), required=False, + source=possible_dossier_types) #subjects = ttitle = schema.TextLine(title=_(u'Title'), required=False) authors = RelationList(title=_(u'Authors'), default=[], required=False, @@ -84,6 +107,7 @@ class IDossierSearch(interface.Interface): class DossierSearchForm(form.Form): + method = 'get' fields = field.Fields(IDossierSearch) ignoreContext = True template = ViewPageTemplateFile('form_templates/view_dossier_search.pt') @@ -150,6 +174,7 @@ class IDocumentPfbSearch(interface.Interface): class DocumentPfbSearchForm(form.Form): + method = 'get' fields = field.Fields(IDocumentPfbSearch) ignoreContext = True template = ViewPageTemplateFile('form_templates/view_pfbdocsearch.pt') @@ -164,19 +189,62 @@ class DocumentPfbSearchForm(form.Form): return +class IGlobalSearchForm(interface.Interface): + search_type = schema.TextLine(title=u'Search Type') + + nodoc = schema.TextLine(title=_(u'Document Number'), required=False) + nosuite = schema.TextLine(title=_(u'Suite Number'), required=False) + doctype = schema.Choice(title=_(u'Type'), required=False, + source=possible_document_types) + + nodos = schema.TextLine(title=_(u'Dossier Number'), required=False) + dostype = schema.Choice(title=_(u'Type'), required=False, + source=possible_dossier_types) + + #subjects = + #subjects = + ttitle = schema.TextLine(title=_(u'Title'), required=False) + text = schema.TextLine(title=_(u'Text'), required=False) + authors = RelationList(title=_(u'Authors'), default=[], required=False, + value_type=RelationChoice(title=_(u'Author'), + source=ObjPathSourceBinder( + portal_type=['themis.datatypes.deputy']))) + # polgroups + # session + start = schema.Date(title=_(u'Start'), required=False) + end = schema.Date(title=_(u'End'), required=False) + + +class GlobalSearchForm(form.Form): + fields = field.Fields(IGlobalSearchForm) + ignoreContext = True + class SearchView(BrowserView): - def document_results(self): - f = DocumentPfbSearchForm(self.context, self.request) + def search_results(self): + f = GlobalSearchForm(self.context, self.request) f.update() data, errors = f.extractData() - catalog = getToolByName(self.context, 'portal_catalog') + kw = {} + if data.get('search_type') == 'document': + kw['portal_type'] = 'tabellio.documents.document' + elif data.get('search_type') == 'dossier': + kw['portal_type'] = 'tabellio.documents.dossier' + if data.get('ttitle'): kw['Title'] = data.get('ttitle') + if data.get('nodoc'): + kw['nodoc'] = data.get('nodoc') + + if data.get('nodos'): + kw['nodos'] = data.get('nodos') + if data.get('doctype'): kw['doctype'] = possible_document_types(self.context).getTermByToken(data.get('doctype')).title + if data.get('dostype'): + kw['dostype'] = possible_dossier_types(self.context).getTermByToken(data.get('doctype')).title if data.get('start') and data.get('end'): kw['dateDoc'] = {'query': [data.get('start'), data.get('end')], 'range': 'minmax'} elif data.get('start'): @@ -184,20 +252,20 @@ class SearchView(BrowserView): elif data.get('end'): kw['dateDoc'] = {'query': data.get('end'), 'range': 'max'} + kw['sort_on'] = 'dateDoc' + kw['sort_order'] = 'descending' if data.get('sort_on') == 'Type': kw['sort_on'] = 'doctype' + kw['sort_order'] = 'ascending' elif data.get('sort_on') == 'Number': kw['sort_on'] = 'no' - elif data.get('sort_on') == 'Session': - kw['sort_on'] = 'session' - kw['sort_order'] = 'descending' + kw['sort_order'] = 'ascending' if not kw: return [] - return catalog( - portal_type=['tabellio.documents.document'], - **kw) + catalog = getToolByName(self.context, 'portal_catalog') + return catalog(**kw) def document_pfb_search_form(self): f = DocumentPfbSearchForm(self.context, self.request) diff --git a/tabellio/searchform/form_templates/view_dossier_search.pt b/tabellio/searchform/form_templates/view_dossier_search.pt index 4b1a16c..3ee5fd7 100644 --- a/tabellio/searchform/form_templates/view_dossier_search.pt +++ b/tabellio/searchform/form_templates/view_dossier_search.pt @@ -7,57 +7,5 @@ -
- De faux résultats pour le moment -
- -
-
    -
  • -

    Proposition de décret - 123 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • - -
  • -

    Proposition de décret - 124 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • - -
  • -

    Proposition de décret - 125 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • - -
  • -

    Proposition de décret - 126 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • -
-
- -
- Précédent - Suivant -

- Page n° : - 1 - 2 - 3 - 3 -

-
- diff --git a/tabellio/searchform/form_templates/view_effectivesearch.pt b/tabellio/searchform/form_templates/view_effectivesearch.pt index 840777d..ba01895 100644 --- a/tabellio/searchform/form_templates/view_effectivesearch.pt +++ b/tabellio/searchform/form_templates/view_effectivesearch.pt @@ -6,57 +6,4 @@ - -
- De faux résultats pour le moment -
- -
-
    -
  • -

    Proposition de décret - 123 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • - -
  • -

    Proposition de décret - 124 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • - -
  • -

    Proposition de décret - 125 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • - -
  • -

    Proposition de décret - 126 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • -
-
- -
- Précédent - Suivant -

- Page n° : - 1 - 2 - 3 - 3 -

-
- diff --git a/tabellio/searchform/form_templates/view_question_search.pt b/tabellio/searchform/form_templates/view_question_search.pt index 4b1a16c..0845c72 100644 --- a/tabellio/searchform/form_templates/view_question_search.pt +++ b/tabellio/searchform/form_templates/view_question_search.pt @@ -7,57 +7,4 @@ -
- De faux résultats pour le moment -
- -
-
    -
  • -

    Proposition de décret - 123 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • - -
  • -

    Proposition de décret - 124 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • - -
  • -

    Proposition de décret - 125 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • - -
  • -

    Proposition de décret - 126 (2010-2011) n° 1

    -

    Proposition de décret visant à élargir la définition des primo-arrivants - dans l'enseignement de la Communauté française.

    -

    Auteurs : Persoons Caroline, Bertiaux Françoise…

    -

    Statut : Version définitive

    -
  • -
-
- -
- Précédent - Suivant -

- Page n° : - 1 - 2 - 3 - 3 -

-
- -