Skip to content

Commit

Permalink
provide Mimetype icon path for file types in contentlisting object
Browse files Browse the repository at this point in the history
  • Loading branch information
fgrcon committed Oct 2, 2016
1 parent 9017531 commit 7573f60
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Breaking changes:

New features:

- *add item here*
- provide Mimetype icon path for file types in contentlisting object
https://github.com/plone/Products.CMFPlone/issues/1734 [fgrcon]

Bug fixes:

Expand Down
14 changes: 14 additions & 0 deletions plone/app/contentlisting/contentlisting.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,17 @@ def isVisibleInNav(self):
return False

return True

def MimeTypeIcon(self):
if not self.PortalType() == 'File':
return None
portal_url = api.portal.get().absolute_url()
mtt = api.portal.get_tool(name='mimetypes_registry')

if self.getObject().file.contentType:
ctype = mtt.lookup(self.getObject().file.contentType)
return os.path.join(portal_url,
guess_icon_path(ctype[0])
)
else:
return None
4 changes: 4 additions & 0 deletions plone/app/contentlisting/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ def ContentTypeClass():
"""The contenttype suitable as a css class name, matching Plone
conventions.
"""
def MimeTypeIcon():
""" return mimetype icon from mimetype registry if contenttype is
File else None
"""

1 comment on commit 7573f60

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fgrcon Jenkins CI reporting about code analysis
See the full report here: http://jenkins.plone.org/job/package-plone.app.contentlisting/23/violations

plone/app/contentlisting/catalog.py:42:12: P002 found "hasattr", consider replacing it
plone/app/contentlisting/catalog.py:44:14: P002 found "hasattr", consider replacing it
plone/app/contentlisting/catalog.py:81:12: P002 found "hasattr", consider replacing it
plone/app/contentlisting/catalog.py:182:12: P002 found "hasattr", consider replacing it
plone/app/contentlisting/contentlisting.py:127:12: P002 found "hasattr", consider replacing it
plone/app/contentlisting/contentlisting.py:147:22: F821 undefined name 'api'
plone/app/contentlisting/contentlisting.py:148:15: F821 undefined name 'api'
plone/app/contentlisting/contentlisting.py:149:1: W293 blank line contains whitespace
plone/app/contentlisting/contentlisting.py:152:20: F821 undefined name 'os'
plone/app/contentlisting/contentlisting.py:153:17: E128 continuation line under-indented for visual indent
plone/app/contentlisting/contentlisting.py:153:17: F821 undefined name 'guess_icon_path'
plone/app/contentlisting/contentlisting.py:154:17: E124 closing bracket does not match visual indentation
plone/app/contentlisting/interfaces.py:0:1: I001 isort found changes, run it on the file
plone/app/contentlisting/interfaces.py:92:12: W292 no newline at end of file
plone/app/contentlisting/realobject.py:37:12: P002 found "hasattr", consider replacing it

Follow these instructions to reproduce it locally.

Please sign in to comment.