Permalink
Browse files

added searchable text indexer

  • Loading branch information...
gborelli committed Mar 28, 2013
1 parent 5c503fd commit 01ace6b40c86b3336850053ca7c3e0f1b5daabc8
View
@@ -44,8 +44,7 @@
'Products.Poi',
'abstract.z3cform.usertokeninput',
'collective.js.jqueryui > 1.8.16.9',
- 'collective.prettydate',
- # 'collective.dexteritytextindexer'
+ 'collective.prettydate'
],
extras_require={
'test': [
@@ -8,6 +8,7 @@
<grok:grok package="." />
<include file="permission.zcml" />
+ <include file="indexers.zcml" />
<include package=".browser" />
<subscriber for=".interfaces.IProject
@@ -18,10 +19,6 @@
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
handler=".events.update_tracker_managers" />
- <adapter name="start" factory=".indexers.start" />
- <adapter name="end" factory=".indexers.end" />
- <adapter name="booking_date" factory=".indexers.date" />
-
<adapter
for=".interfaces.IIteration"
provides=".interfaces.IStoriesListing"
@@ -2,6 +2,9 @@
from plone.indexer.decorator import indexer
from .interfaces import IIteration
+from .interfaces import IEpic
+from .interfaces import IStory
+from .interfaces import IProject
from .interfaces import IBooking
@@ -18,3 +21,41 @@ def end(obj):
@indexer(IBooking)
def date(obj):
return DateTime(obj.date.isoformat())
+
+
+def SearchableText(obj, text=False):
+ return ' '.join((obj.id, obj.title, obj.description, ))
+
+
+@indexer(IProject)
+def SearchableText_project(obj):
+ searchable = [SearchableText(obj)]
+ if obj.notes is not None or obj.text.output is None:
+ searchable.append(obj.notes.output)
+
+ if obj.customer is not None:
+ searchable.append(obj.customer)
+
+ if obj.classifiers:
+ searchable.append(' '.join(obj.classifiers))
+
+ return ' '.join(searchable)
+
+
+@indexer(IIteration)
+def SearchableText_iteration(obj):
+ return SearchableText(obj)
+
+
+@indexer(IStory)
+def SearchableText_story(obj):
+ if obj.text is None:
+ return SearchableText(obj)
+ return ' '.join((SearchableText(obj), obj.text))
+
+
+@indexer(IEpic)
+def SearchableText_epic(obj):
+ if obj.text is None or obj.text.output is None:
+ return SearchableText(obj)
+ return ' '.join((SearchableText(obj), obj.text.output))
@@ -0,0 +1,15 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ i18n_domain="collective.simplemanagement">
+
+ <adapter name="start" factory=".indexers.start" />
+ <adapter name="end" factory=".indexers.end" />
+ <adapter name="booking_date" factory=".indexers.date" />
+ <adapter name="SearchableText"
+ factory=".indexers.SearchableText_project" />
+ <adapter name="SearchableText"
+ factory=".indexers.SearchableText_iteration" />
+ <adapter name="SearchableText"
+ factory=".indexers.SearchableText_story" />
+
+</configure>
@@ -180,7 +180,7 @@ class IIteration(form.Schema):
class IEpic(form.Schema):
- text = schema.Text(title=_(u"Text"))
+ text = RichText(title=_(u"Text"))
estimate = schema.Decimal(
title=_(u"Estimate (man days)"),
default=Decimal('0.00')
@@ -193,6 +193,7 @@ class IStory(form.Schema):
title=_(u"Text"),
required=False
)
+
estimate = schema.Decimal(
title=_(u"Estimate (man hours)"),
default=Decimal('0.00')

0 comments on commit 01ace6b

Please sign in to comment.