From 60225591dcc947c61b1d13202942d86886a42839 Mon Sep 17 00:00:00 2001 From: ColeBurch <48129706+ColeBurch@users.noreply.github.com> Date: Sun, 21 Jan 2024 11:12:14 -0700 Subject: [PATCH] settings: Reorder custom profile field types. This commit alphabetizes the custom profile field types in the settings UI. Fixes #28511. --- .../0417_alter_customprofilefield_field_type.py | 8 ++++---- zerver/models/custom_profile_fields.py | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/zerver/migrations/0417_alter_customprofilefield_field_type.py b/zerver/migrations/0417_alter_customprofilefield_field_type.py index beb262ac8e..048a443c80 100644 --- a/zerver/migrations/0417_alter_customprofilefield_field_type.py +++ b/zerver/migrations/0417_alter_customprofilefield_field_type.py @@ -14,13 +14,13 @@ class Migration(migrations.Migration): name="field_type", field=models.PositiveSmallIntegerField( choices=[ - (1, "Text (short)"), - (2, "Text (long)"), (4, "Date"), - (5, "Link"), (7, "External account"), - (8, "Pronouns"), + (5, "Link"), (3, "List of options"), + (8, "Pronouns"), + (2, "Text (long)"), + (1, "Text (short)"), (6, "Users"), ], default=1, diff --git a/zerver/models/custom_profile_fields.py b/zerver/models/custom_profile_fields.py index b7083eec0a..a3d22e978a 100644 --- a/zerver/models/custom_profile_fields.py +++ b/zerver/models/custom_profile_fields.py @@ -120,7 +120,9 @@ class CustomProfileField(models.Model): (PRONOUNS, gettext_lazy("Pronouns"), check_short_string, str, "PRONOUNS"), ] - ALL_FIELD_TYPES = [*FIELD_TYPE_DATA, *SELECT_FIELD_TYPE_DATA, *USER_FIELD_TYPE_DATA] + ALL_FIELD_TYPES = sorted( + [*FIELD_TYPE_DATA, *SELECT_FIELD_TYPE_DATA, *USER_FIELD_TYPE_DATA], key=lambda x: x[1] + ) FIELD_VALIDATORS: Dict[int, Validator[ProfileDataElementValue]] = { item[0]: item[2] for item in FIELD_TYPE_DATA