Skip to content

Commit

Permalink
Merge pull request #83 from plone/thet-fcmorecolumns
Browse files Browse the repository at this point in the history
 More available columns in folder_contents.
  • Loading branch information
jensens committed Apr 8, 2016
2 parents a41da74 + 3b529a3 commit 59f1b26
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 30 deletions.
15 changes: 14 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,23 @@ Incompatibilities:

New:

- *add item here*
- Add ``Creator``, ``Description``, ``end``, ``start`` and ``location`` to the available columns and context attributes for folder_contents.
[thet]

Show attributes from ``_unsafe_metadata`` if user has "Modify Portal Content" permissions.
[thet]

Fixes:

- Remove ``portal_type`` from available columns and use ``Type`` instead, which is meant to be read by humans.
``portal_type`` is now available on the attributes object.
[thet]

- Added most notably `portal_type`, `review_state` and `Subject` but also `exclude_from_nav`, `is_folderish`, `last_comment_date`, `meta_type` and `total_comments` to ``BaseVocabularyView`` ``translate_ignored`` list.
Some of them are necessary for frontend logic and others cannot be translated.
Fixes https://github.com/plone/plone.app.content/issues/77
[thet]

- Vocabulary permissions are considered View permission by default, if not
stated different in PERMISSION global. Renamed _permissions to PERMISSIONS,
Deprecated BBB name in place. Also minor code-style changes
Expand Down
72 changes: 54 additions & 18 deletions plone/app/content/browser/contents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,43 @@ def get_actions(self):
def get_columns(self):
# Base set of columns
columns = {
'id': translate(_('ID'), context=self.request),
'ModificationDate': translate(_('Last modified'), context=self.request), # noqa
'EffectiveDate': translate(_('Publication date'), context=self.request), # noqa
'ExpirationDate': translate(_('Expiration date'), context=self.request), #noqa
'CreationDate': translate(_('Created on'), context=self.request), # noqa
'review_state': translate(_('Review state'), context=self.request), # noqa
'Subject': translate(_('Tags'), context=self.request),
'portal_type': translate(_('Type'), context=self.request),
'is_folderish': translate(_('Folder'), context=self.request),
'Creator': translate(_('Creator'), context=self.request),
'Description': translate(_('Description'), context=self.request),
'EffectiveDate': translate(_('Publication date'), context=self.request), # noqa
'end': translate(_('End Date'), context=self.request),
'exclude_from_nav': translate(_('Excluded from navigation'), context=self.request), # noqa
'ExpirationDate': translate(_('Expiration date'), context=self.request), # noqa
'getObjSize': translate(_('Object Size'), context=self.request), # noqa
'id': translate(_('ID'), context=self.request),
'is_folderish': translate(_('Folder'), context=self.request),
'last_comment_date': translate(_('Last comment date'), context=self.request), # noqa
'location': translate(_('Location'), context=self.request),
'ModificationDate': translate(_('Last modified'), context=self.request), # noqa
'review_state': translate(_('Review state'), context=self.request), # noqa
'start': translate(_('Start Date'), context=self.request),
'Subject': translate(_('Tags'), context=self.request),
'Type': translate(_('Type'), context=self.request),
'total_comments': translate(_('Total comments'), context=self.request), # noqa
}
# These columns either have alternatives or are probably not useful
ignored = [
'Creator', 'Date', 'Description', 'Title', 'Type', 'author_name',
'cmf_uid', 'commentators', 'created', 'effective', 'end',
'expires', 'getIcon', 'getId', 'getRemoteUrl', 'in_response_to',
'listCreators', 'location', 'meta_type', 'modified', 'start',
'Date',
'Title',
'author_name',
'cmf_uid',
'commentators',
'created',
'effective',
'expires',
'getIcon',
'getId',
'getRemoteUrl',
'in_response_to',
'listCreators',
'meta_type',
'modified',
'portal_type',
'sync_uid'
]
# Add in extra metadata columns
Expand Down Expand Up @@ -221,7 +238,7 @@ def get_options(self):
'contextInfoUrl': '%s{path}/@@fc-contextInfo' % base_url,
'setDefaultPageUrl': '%s{path}/@@fc-setDefaultPage' % base_url,
'availableColumns': columns,
'attributes': ['Title', 'path', 'getURL', 'getIcon'] + columns.keys(),
'attributes': ['Title', 'path', 'getURL', 'getIcon', 'portal_type'] + columns.keys(), # noqa
'buttons': self.get_actions(),
'rearrange': {
'properties': {
Expand Down Expand Up @@ -251,11 +268,30 @@ def __call__(self):

class ContextInfo(BrowserView):

attributes = ['UID', 'Title', 'Type', 'path', 'review_state',
'ModificationDate', 'EffectiveDate', 'CreationDate',
'is_folderish', 'Subject', 'getURL', 'id',
'exclude_from_nav', 'getObjSize', 'last_comment_date',
'total_comments', 'portal_type']
attributes = [
'CreationDate',
'Creator',
'Description',
'EffectiveDate',
'end',
'exclude_from_nav',
'getObjSize',
'getURL',
'id',
'is_folderish',
'last_comment_date',
'location'
'ModificationDate',
'path',
'portal_type',
'review_state',
'start',
'Subject',
'Title',
'total_comments',
'Type',
'UID',
]

def __call__(self):
factories_menu = getUtility(
Expand Down
64 changes: 53 additions & 11 deletions plone/app/content/browser/vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

DEFAULT_PERMISSION = 'View'
PERMISSIONS = {
'plone.app.vocabularies.Users': 'Modify portal content',
'plone.app.vocabularies.Catalog': 'View',
'plone.app.vocabularies.Keywords': 'Modify portal content',
'plone.app.vocabularies.SyndicatableFeedItems': 'Modify portal content'
'plone.app.vocabularies.SyndicatableFeedItems': 'Modify portal content',
'plone.app.vocabularies.Users': 'Modify portal content',
}

_permissions = deprecated(PERMISSIONS, 'Use PERMISSION variable instead')
Expand All @@ -51,9 +51,18 @@ def _parseJSON(s):
return s


_unsafe_metadata = ['Creator', 'listCreators', 'author_name', 'commentors']
_unsafe_metadata = [
'author_name',
'commentors',
'Creator',
'listCreators',
]
_safe_callable_metadata = [
'getURL', 'getPath', 'review_state', 'getIcon', 'is_folderish',
'getIcon',
'getPath',
'getURL',
'is_folderish',
'review_state',
]


Expand Down Expand Up @@ -143,15 +152,48 @@ def __call__(self):
attributes = attributes.split(',')

translate_ignored = [
'Creator', 'Date', 'Description', 'Title', 'author_name',
'cmf_uid', 'commentators', 'created', 'effective', 'end',
'expires', 'getIcon', 'getId', 'getRemoteUrl', 'in_response_to',
'listCreators', 'location', 'modified', 'start', 'sync_uid',
'path', 'getURL', 'EffectiveDate', 'getObjSize', 'id',
'UID', 'ExpirationDate', 'ModificationDate', 'CreationDate',
'author_name',
'cmf_uid',
'commentators',
'created',
'CreationDate',
'Creator',
'Date',
'Description',
'effective',
'EffectiveDate',
'end',
'exclude_from_nav',
'ExpirationDate',
'expires',
'getIcon',
'getId',
'getObjSize',
'getRemoteUrl',
'getURL',
'id',
'in_response_to',
'is_folderish',
'last_comment_date',
'listCreators',
'location',
'meta_type',
'ModificationDate',
'modified',
'path',
'portal_type',
'review_state',
'start',
'Subject',
'sync_uid',
'Title',
'total_comments'
'UID',
]
if attributes:
base_path = getNavigationRoot(context)
sm = getSecurityManager()
can_edit = sm.checkPermission('Modify portal content', context)
for vocab_item in results:
if not results_are_brains:
vocab_item = vocab_item.value
Expand All @@ -160,7 +202,7 @@ def __call__(self):
key = attr
if ':' in attr:
key, attr = attr.split(':', 1)
if attr in _unsafe_metadata:
if attr in _unsafe_metadata and not can_edit:
continue
if key == 'path':
attr = 'getPath'
Expand Down

0 comments on commit 59f1b26

Please sign in to comment.