plone / plone.app.content

Various views for Plone, such as folder_contents, as well as general content infrastructure, such as base classes and name choosers.
https://pypi.org/project/plone.app.content/
7 stars 32 forks source link

Type names with matching `Title` brake the left panel viewlet #212

Open szakitibi opened 4 years ago

szakitibi commented 4 years ago

Expected result

image

Current behavior

image

Details

With types defined with matching translated titles, e.g. two "Folder" types like:

[...
 ('Folder',
  {'action': 'http://localhost:8080/Plone/++add++Folder',
   'description': '',
   'extra': {'class': 'contenttype-folder', 'id': 'folder', 'separator': None},
   'icon': None,
   'id': 'Folder',
   'selected': False,
   'submenu': None,
   'title': 'Folder'}),
...
 ('Folder',
  {'action': 'http://localhost:8080/Plone/++add++customers.special.Folder',
   'description': '',
   'extra': {'class': 'contenttype-customers-special-folder', 'id': 'customers-special-folder', 'separator': None},
   'icon': None,
   'id': 'customers.special.Folder',
   'selected': False,
   'submenu': None,
   'title': 'Folder'})]

This section of code forced to compare dictionaries:

https://github.com/plone/plone.app.content/blob/bb29d6419525768d28e2f942f5ebe1b78ab83450/plone/app/content/browser/folderfactories.py#L141-L145

Which results the following error:

TypeError: '<' not supported between instances of 'dict' and 'dict'

Suggested solution

results.sort(key=lambda ctype: translate(ctype['title'], context=request))

Note: Unless this violates some underlying rule banning matching titles for content types.