[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/ Skeleton search form.
Charlie Clark
charlie at begeistert.org
Wed Oct 6 19:47:28 EDT 2010
Log message for revision 117309:
Skeleton search form.
Changed:
A Products.CMFDefault/trunk/Products/CMFDefault/browser/search/
A Products.CMFDefault/trunk/Products/CMFDefault/browser/search/TODO.txt
A Products.CMFDefault/trunk/Products/CMFDefault/browser/search/__init__.py
A Products.CMFDefault/trunk/Products/CMFDefault/browser/search/configure.zcml
A Products.CMFDefault/trunk/Products/CMFDefault/browser/search/interfaces.py
A Products.CMFDefault/trunk/Products/CMFDefault/browser/search/search.pt
A Products.CMFDefault/trunk/Products/CMFDefault/browser/search/search.py
A Products.CMFDefault/trunk/Products/CMFDefault/browser/search/vocab.py
-=-
Added: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/TODO.txt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/search/TODO.txt (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/search/TODO.txt 2010-10-06 23:47:27 UTC (rev 117309)
@@ -0,0 +1,7 @@
+Search Views
+------------
+
+search.py
+search_form.py
+search_form_template.pt
+search_results_template.pt
Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/__init__.py
___________________________________________________________________
Added: svn:eol-style
+ native
Added: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/configure.zcml
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/search/configure.zcml (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/search/configure.zcml 2010-10-06 23:47:27 UTC (rev 117309)
@@ -0,0 +1,37 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
+
+ <browser:page
+ for="Products.CMFCore.interfaces.ISiteRoot"
+ layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"
+ name="search.html"
+ class=".search.Search"
+ permission="zope2.View"
+ />
+
+ <utility
+ component=".vocab.subject_vocab"
+ provides="zope.schema.interfaces.IVocabularyFactory"
+ name="cmf.subject"
+ />
+
+ <utility
+ component=".vocab.status_vocab"
+ provides="zope.schema.interfaces.IVocabularyFactory"
+ name="cmf.review state"
+ />
+
+ <utility
+ component=".vocab.date_vocab"
+ provides="zope.schema.interfaces.IVocabularyFactory"
+ name="cmf.date"
+ />
+
+ <utility
+ component=".vocab.type_vocab"
+ provides="zope.schema.interfaces.IVocabularyFactory"
+ name="cmf.type"
+ />
+
+</configure>
Added: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/interfaces.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/search/interfaces.py (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/search/interfaces.py 2010-10-06 23:47:27 UTC (rev 117309)
@@ -0,0 +1,73 @@
+
+from datetime import date
+
+from zope.interface import Interface
+from zope.schema import Choice, Int, Datetime, List, TextLine, ASCIILine
+
+from Products.CMFDefault.utils import Message as _
+
+class ISearchSchema(Interface):
+
+ review_state = Choice(
+ title=(_(u"Review Status")),
+ vocabulary=u"cmf.review state",
+ description=(_(
+ u"As a reviewer, you may search for items based on"
+ u" their review state. If you wish to constrain"
+ u" results to items in certain states, select them"
+ u" from this list.")),
+ default="None"
+ )
+
+ search_text = TextLine(
+ title=(_(u"Full Text")),
+ description=(_(
+ u"For a simple text search, enter your search term"
+ u" here. Multiple words may be found by combining"
+ u" them with AND and OR. This will find text in"
+ u" items' contents, title and description.")),
+ required=False
+ )
+
+ subject = Choice(
+ title=(_(u"Subject")),
+ description=(_(u"")),
+ vocabulary=u"cmf.subject",
+ default="None"
+ )
+
+ description = TextLine(
+ title=(_(u"Description")),
+ description=(_(
+ u"You may also search the items' descriptions and"
+ u" titles specifically. Multiple words may be found by"
+ u" combining them with AND and OR.")),
+ required=False
+ )
+
+ when = Choice(
+ title=(_(u"Find new items since...")),
+ description=(_(
+ u"You may find only recent items by selecting a time-frame."
+ )),
+ vocabulary=u"cmf.date",
+ default=date.today())
+
+ portal_type = Choice(
+ title=(_(u"Item type")),
+ description=(_(
+ u"You may limit your results to particular kinds of"
+ u" items by selecting them above. To find all kinds of"
+ u" items, do not select anything.")),
+ vocabulary=u"cmf.type",
+ default="None")
+
+ creator = ASCIILine(
+ title=(_(u"Creator")),
+ description=(_(
+ u"To find items by a particular user only, enter their"
+ u"username above. Note that you must enter their username"
+ u"exactly.")),
+ required=False
+ )
+
Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/interfaces.py
___________________________________________________________________
Added: svn:eol-style
+ native
Added: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/search.pt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/search/search.pt (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/search/search.pt 2010-10-06 23:47:27 UTC (rev 117309)
@@ -0,0 +1,34 @@
+<html metal:use-macro="context/@@standard_macros/page">
+
+<body>
+
+<metal:slot metal:fill-slot="body" i18n:domain="cmf_default">
+
+<ul class="errors" tal:condition="view/errors">
+ <li tal:repeat="error view/error_views"
+ tal:content="structure error">Error Message</li>
+</ul>
+
+<h1 tal:content="view/label | nothing ">Portal Search</h1>
+
+<form action="." method="post" tal:attributes="action request/ACTUAL_URL">
+
+ <fieldset tal:repeat="widget view/widgets">
+ <label tal:attributes="for widget/name" tal:content="widget/label"></label>
+ <tal:block replace="structure widget" />
+ <legend tal:content="widget/hint"></legend>
+ <tal:block condition="widget/error"
+ replace="structure widget/error" />
+ </fieldset>
+
+ <div class="buttons">
+ <tal:loop tal:repeat="action view/actions"
+ tal:replace="structure action/render" />
+ </div>
+
+</form>
+
+</metal:slot>
+
+</body>
+</html>
Added: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/search.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/search/search.py (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/search/search.py 2010-10-06 23:47:27 UTC (rev 117309)
@@ -0,0 +1,50 @@
+##############################################################################
+#
+# Copyright (c) 2010 Zope Foundation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Search views"""
+
+from zope.interface import Interface
+from zope.formlib import form
+
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+
+from Products.CMFCore.interfaces import ISyndicationInfo
+from Products.CMFDefault.formlib.form import EditFormBase
+from Products.CMFDefault.utils import Message as _
+from Products.CMFDefault.browser.utils import memoize
+
+from interfaces import ISearchSchema
+
+class Search(EditFormBase):
+
+ template = ViewPageTemplateFile("search.pt")
+ form_fields = form.FormFields(ISearchSchema)
+
+ actions = form.Actions(
+ form.Action(
+ name='search',
+ label=_(u"Search"),
+ success='handle_search',
+ failure='handle_failure',
+ ),
+ )
+
+ @property
+ def catalog(self):
+ return self._getTool('portal_catalog')
+
+ @property
+ def types(self):
+ return self._getTool('portal_types')
+
+ def handle_search(self, action, data):
+ pass
\ No newline at end of file
Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/search.py
___________________________________________________________________
Added: svn:eol-style
+ native
Added: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/vocab.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/search/vocab.py (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/search/vocab.py 2010-10-06 23:47:27 UTC (rev 117309)
@@ -0,0 +1,58 @@
+
+from datetime import date, timedelta
+
+from DateTime import DateTime
+
+from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
+
+from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import MessageFactory as _
+
+def status_vocab(context):
+ catalog = getToolByName(context, 'portal_catalog')
+ values = [((u'--any--'), "None")]
+ values += [(v, v) for v in catalog.uniqueValuesFor('review_state')]
+ return SimpleVocabulary.fromItems(values)
+
+def subject_vocab(context):
+ catalog = getToolByName(context, 'portal_catalog')
+ values = [((u'--any--'), "None")]
+ values += [(v, v) for v in catalog.uniqueValuesFor('Subject')]
+ return SimpleVocabulary.fromItems(values)
+
+def date_vocab(context):
+ mtool = getToolByName(context, 'portal_membership')
+ dates = [SimpleTerm(date(1970, 1, 1), date(1970, 1, 1), 'Ever')]
+ if not mtool.isAnonymousUser():
+ login_time = mtool.getAuthenticatedMember().last_login_time
+ if not hasattr(login_time, 'parts'):
+ login_time = DateTime(login_time)
+ login = date(*login_time.parts()[:3])
+ dates.append(SimpleTerm(
+ login, login, 'Last login')
+ )
+
+ today = date.today()
+ dates.append(SimpleTerm(today - timedelta(days=1),
+ today - timedelta(days=1),
+ u'Yesterday'
+ )
+ )
+ dates.append(SimpleTerm(today - timedelta(days=7),
+ today - timedelta(days=7),
+ u'Last week'
+ )
+ )
+ dates.append(SimpleTerm(today - timedelta(days=31),
+ today - timedelta(days=31),
+ u'Last month'
+ )
+ )
+ return SimpleVocabulary(dates)
+
+def type_vocab(context):
+ ttool = getToolByName(context, 'portal_types')
+ types = ttool.listTypeInfo()
+ terms = [SimpleTerm(None, None, '--any--')]
+ terms += [SimpleTerm(t.getId(), t.getId(), t.Title()) for t in types]
+ return SimpleVocabulary(terms)
Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/browser/search/vocab.py
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the checkins
mailing list