From 558797a8b80c3e0a917ca8a7cb4519d2d2818ef0 Mon Sep 17 00:00:00 2001 From: Mikel Larreategi Date: Mon, 26 Jan 2026 15:33:43 +0100 Subject: [PATCH] Alphabetically sort the list of portal types in the contraint configuration form --- news/320.feature | 1 + src/plone/app/content/browser/constraintypes.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 news/320.feature diff --git a/news/320.feature b/news/320.feature new file mode 100644 index 00000000..12e3c1f4 --- /dev/null +++ b/news/320.feature @@ -0,0 +1 @@ +Alphabetically sort the list of portal types in the constraints configuration form @erral diff --git a/src/plone/app/content/browser/constraintypes.py b/src/plone/app/content/browser/constraintypes.py index edb62496..03a246ca 100644 --- a/src/plone/app/content/browser/constraintypes.py +++ b/src/plone/app/content/browser/constraintypes.py @@ -4,6 +4,8 @@ from z3c.form import button from z3c.form import form from z3c.form.browser.checkbox import CheckBoxFieldWidget +from zope.globalrequest import getRequest +from zope.i18n import translate from zope.i18nmessageid import MessageFactory from zope.interface import implementer from zope.interface import Interface @@ -50,10 +52,14 @@ def ST(key, title): class ValidTypes: def __call__(self, context): constrain_aspect = context.context + request = getRequest() items = [] for type_ in constrain_aspect.getDefaultAddableTypes(): items.append(SimpleTerm(value=type_.getId(), title=type_.Title())) - return SimpleVocabulary(items) + + return SimpleVocabulary( + sorted(items, key=lambda x: translate(x.title, context=request).lower()) + ) ValidTypesFactory = ValidTypes()