Created
December 7, 2012 06:51
-
-
Save jone/4231295 to your computer and use it in GitHub Desktop.
ftw.workspace integration of ftw.task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configure | |
xmlns="http://namespaces.zope.org/zope" | |
xmlns:browser="http://namespaces.zope.org/browser"> | |
<browser:page | |
for="*" | |
name="tabbedview_view-tasks" | |
class=".tasks.TasksTab" | |
permission="zope2.View" | |
/> | |
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n" name="Workspace" | |
meta_type="Factory-based Type Information with dynamic views" | |
i18n:domain="egov.tabbedview"> | |
<action title="Tasks" action_id="tasks" | |
category="tabbedview-tabs" | |
condition_expr="" url_expr="string:${object_url}?view=tasks" | |
visible="True"> | |
<permission value="View"/> | |
</action> | |
</object> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Products.CMFCore.utils import getToolByName | |
from ftw.tabbedview.browser.listing import CatalogListingView | |
from ftw.table import helper | |
from zope.component.hooks import getSite | |
from zope.i18nmessageid import MessageFactory | |
_ = MessageFactory('domain') | |
def user_or_contact(item, value): | |
"""Expected `value`: either a userid (string) or | |
a list / tuple / set of userids | |
Also compatible with uids for contact objects | |
""" | |
if not value: | |
return '-' | |
elif isinstance(value, basestring): | |
userids = (value,) | |
elif type(value) in (list, tuple, set): | |
userids = value | |
else: | |
raise ValueError('Expected string or list as value, ' | |
'got ' % type(value)) | |
portal = getSite() | |
acl_users = getToolByName(portal, 'acl_users') | |
transformed = [] | |
for userid in userids: | |
user = acl_users.getUserById(userid) | |
if not user: | |
# look for a object | |
contact = portal.reference_catalog.lookupObject(userid) | |
if contact: | |
transformed.append(contact.Title()) | |
else: | |
transformed.append(userid) | |
else: | |
fullname = user.getProperty('fullname', '').strip() | |
transformed.append(fullname or userid) | |
return ', '.join(transformed) | |
def translate_state(item, value): | |
"""This helper method translates a value like a state in the plone domain""" | |
parent = item.aq_parent | |
return parent.translate(default=value, domain='plone', msgid=value) | |
class TasksTab(CatalogListingView): | |
"""Lists all tasks within this context in a tabbedview listing tab. | |
""" | |
types = ('Task',) | |
sort_on = 'sortable_title' | |
show_selects = False | |
show_menu = False | |
columns = ( | |
{'column': 'Title', | |
'sort_index': 'sortable_title', | |
'column_title': _(u'label_taskstab_title', | |
default=u'Title'), | |
'transform': helper.linked}, | |
{'column': 'end', | |
'column_title': _(u'label_taskstab_end_date', | |
default=u'End'), | |
'transform': helper.readable_date_time_text, | |
'width': 90}, | |
{'column': 'getResponsibility', | |
'column_title': _(u'label_taskstab_responsibility', | |
default=u'Responsibility'), | |
'transform': user_or_contact}, | |
{'column': 'review_state', | |
'column_title': _(u'label_taskstab_review_state', | |
default=u'State'), | |
'transform': translate_state, | |
'width': 70}, | |
{'column': 'Creator', | |
'column_title': _(u'label_taskstab_creator', | |
default=u'Creator'), | |
'transform': user_or_contact}, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment