app questions in config panel: handle choices with nice display names for webadmin

This commit is contained in:
Alexandre Aubin 2022-01-24 18:31:04 +01:00
parent 8836fdeeaa
commit fde01fafd7

View file

@ -1127,6 +1127,7 @@ class DomainQuestion(Question):
return value
class AppQuestion(Question):
argument_type = "app"
@ -1141,7 +1142,13 @@ class AppQuestion(Question):
for _filter in self.filters:
apps = [app for app in apps if _filter in app and app[_filter]]
self.choices = ["_none"] + [app['id'] for app in apps]
def _app_display(app):
domain_path = f" ({app['domain_path']})" if 'domain_path' in app else ""
return app["label"] + domain_path
self.choices = {"_none": "---"}
self.choices.update({app['id']: _app_display(app) for app in apps})
class UserQuestion(Question):
argument_type = "user"