Sort items in content types vocabulary
authorThierry Florac <thierry.florac@onf.fr>
Wed, 13 Sep 2017 09:45:30 +0200
changeset 155 444aec7a527d
parent 154 b07b899e9c1f
child 156 6866b24c20ea
Sort items in content types vocabulary
src/pyams_content/shared/common/__init__.py
--- a/src/pyams_content/shared/common/__init__.py	Wed Sep 13 09:36:26 2017 +0200
+++ b/src/pyams_content/shared/common/__init__.py	Wed Sep 13 09:45:30 2017 +0200
@@ -81,8 +81,9 @@
     def __init__(self, context):
         request = check_request()
         translate = request.localizer.translate
-        terms = [SimpleTerm(content.content_type, title=translate(content.content_name))
-                 for content in CONTENT_TYPES.values()]
+        terms = sorted([SimpleTerm(content.content_type, title=translate(content.content_name))
+                        for content in CONTENT_TYPES.values()],
+                       key=lambda x: x.title)
         super(ContentTypesVocabulary, self).__init__(terms)