Skip to content

Commit

Permalink
Modified enquirer field to be LocalRoleField. Use overridable vocabul…
Browse files Browse the repository at this point in the history
…ary.
  • Loading branch information
sgeulette committed Mar 24, 2017
1 parent a156642 commit cbb78f8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ Changelog
3.0 (unreleased)
----------------

- Added special index value for empty field.
- Modified enquirer field to be LocalRoleField. Use overridable vocabulary.
[sgeulette]
- Block local roles on task content
[sgeulette]
- Added special index value for empty field.
[sgeulette]

2.5 (2016-12-07)
----------------
Expand Down
20 changes: 15 additions & 5 deletions src/collective/task/behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ def __call__(self, context):
AssignedGroupsVocabularyFactory = AssignedGroupsVocabulary()


class EnquirerVocabulary(object):
""" Define own factory and named utility that can be easily overrided in componentregistry.xml """

def __call__(self, context):
voc = getUtility(IVocabularyFactory, name="plone.principalsource.Users", context=context)
return voc(context)

EnquirerVocabularyFactory = EnquirerVocabulary()


def get_users_vocabulary(group):
"""Get users vocabulary when an assigned group is selected."""
terms = []
Expand Down Expand Up @@ -97,15 +107,15 @@ class ITask(model.Schema):
vocabulary="plone.principalsource.Users"
)

enquirer = schema.Choice(
title=_(u"Enquirer"),
due_date = schema.Date(
title=_(u"Due date"),
required=False,
vocabulary="plone.principalsource.Users"
)

due_date = schema.Date(
title=_(u"Due date"),
enquirer = LocalRoleField(
title=_(u"Enquirer"),
required=False,
vocabulary="collective.task.Enquirer"
)


Expand Down
6 changes: 6 additions & 0 deletions src/collective/task/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
component="collective.task.behaviors.AssignedGroupsVocabularyFactory"
/>

<utility
name="collective.task.Enquirer"
provides="zope.schema.interfaces.IVocabularyFactory"
component="collective.task.behaviors.EnquirerVocabularyFactory"
/>

<utility
name="collective.task.related_taskcontainer"
provides="dexterity.localroles.interfaces.ILocalRolesRelatedSearchUtility"
Expand Down

0 comments on commit cbb78f8

Please sign in to comment.