diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index efaa0c2c6d..eea57d7bed 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -1624,7 +1624,7 @@ paths: "name": "Favorite editor", "type": 3, "hint": "", - "field_data": '{"vim":{"text":"Vim","order":"1"},"emacs":{"text":"Emacs","order":"2"}}', + "field_data": '{"0":{"text":"Vim","order":"1"},"1":{"text":"Emacs","order":"2"}}', "order": 4, }, { @@ -6243,7 +6243,7 @@ paths: "is_guest": false, "profile_data": { - "4": {"value": "vim"}, + "4": {"value": "0"}, "2": { "value": "I am:\n* The prince of Denmark\n* Nephew to the usurping Claudius", @@ -7753,7 +7753,7 @@ paths: "name": "Favorite editor", "type": 3, "hint": "", - "field_data": '{"vim":{"text":"Vim","order":"1"},"emacs":{"text":"Emacs","order":"2"}}', + "field_data": '{"0":{"text":"Vim","order":"1"},"1":{"text":"Emacs","order":"2"}}', "order": 4, }, { @@ -8482,7 +8482,7 @@ paths: "is_guest": false, "profile_data": { - "4": {"value": "vim"}, + "4": {"value": "0"}, "2": { "value": "I am:\n* The prince of Denmark\n* Nephew to the usurping Claudius", @@ -8572,7 +8572,7 @@ paths: "is_guest": false, "profile_data": { - "4": {"value": "vim"}, + "4": {"value": "0"}, "2": { "value": "I am:\n* The prince of Denmark\n* Nephew to the usurping Claudius", @@ -8666,7 +8666,7 @@ paths: items: type: object example: - [{"id": 4, "value": "vim"}, {"id": 5, "value": "1909-04-05"}] + [{"id": 4, "value": "0"}, {"id": 5, "value": "1909-04-05"}] required: false responses: diff --git a/zerver/tests/test_custom_profile_data.py b/zerver/tests/test_custom_profile_data.py index c2cd92738d..b70dbbd73f 100644 --- a/zerver/tests/test_custom_profile_data.py +++ b/zerver/tests/test_custom_profile_data.py @@ -106,8 +106,8 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): data["field_data"] = orjson.dumps( { - "python": {"text": "Python"}, - "java": {"text": "Java"}, + "0": {"text": "Python"}, + "1": {"text": "Java"}, } ).decode() result = self.client_post("/json/realm/profile_fields", info=data) @@ -115,8 +115,8 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): data["field_data"] = orjson.dumps( { - "python": {"text": "Python", "order": ""}, - "java": {"text": "Java", "order": "2"}, + "0": {"text": "Python", "order": ""}, + "1": {"text": "Java", "order": "2"}, } ).decode() result = self.client_post("/json/realm/profile_fields", info=data) @@ -125,7 +125,7 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): data["field_data"] = orjson.dumps( { "": {"text": "Python", "order": "1"}, - "java": {"text": "Java", "order": "2"}, + "1": {"text": "Java", "order": "2"}, } ).decode() result = self.client_post("/json/realm/profile_fields", info=data) @@ -133,8 +133,8 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): data["field_data"] = orjson.dumps( { - "python": {"text": "Python", "order": 1}, - "java": {"text": "Java", "order": "2"}, + "0": {"text": "Python", "order": 1}, + "1": {"text": "Java", "order": "2"}, } ).decode() result = self.client_post("/json/realm/profile_fields", info=data) @@ -146,8 +146,8 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): data["field_data"] = orjson.dumps( { - "python": {"text": "Duplicate", "order": "1"}, - "java": {"text": "Duplicate", "order": "2"}, + "0": {"text": "Duplicate", "order": "1"}, + "1": {"text": "Duplicate", "order": "2"}, } ).decode() result = self.client_post("/json/realm/profile_fields", info=data) @@ -155,8 +155,8 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): data["field_data"] = orjson.dumps( { - "python": {"text": "Python", "order": "1"}, - "java": {"text": "Java", "order": "2"}, + "0": {"text": "Python", "order": "1"}, + "1": {"text": "Java", "order": "2"}, } ).decode() result = self.client_post("/json/realm/profile_fields", info=data) @@ -497,8 +497,8 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): field_data = orjson.dumps( { - "vim": "Vim", - "emacs": {"order": "2", "text": "Emacs"}, + "0": "Vim", + "1": {"order": "2", "text": "Emacs"}, } ).decode() result = self.client_patch( @@ -509,9 +509,9 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): field_data = orjson.dumps( { - "vim": {"order": "1", "text": "Vim"}, - "emacs": {"order": "2", "text": "Emacs"}, - "notepad": {"order": "3", "text": "Notepad"}, + "0": {"order": "1", "text": "Vim"}, + "1": {"order": "2", "text": "Emacs"}, + "2": {"order": "3", "text": "Notepad"}, } ).decode() result = self.client_patch( @@ -594,7 +594,7 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): ("Phone number", "*short* text data"), ("Biography", "~~short~~ **long** text data"), ("Favorite food", "long short text data"), - ("Favorite editor", "vim"), + ("Favorite editor", "0"), ("Birthday", "1909-03-05"), ("Favorite website", "https://zulip.com"), ("Mentor", [self.example_user("cordelia").id]), @@ -667,7 +667,7 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): data = [ { "id": field.id, - "value": "emacs", + "value": "1", } ] @@ -732,23 +732,23 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): realm = get_realm("zulip") field = CustomProfileField.objects.get(name="Favorite editor", realm=realm) self.assertTrue( - CustomProfileFieldValue.objects.filter(field_id=field.id, value="vim").exists() + CustomProfileFieldValue.objects.filter(field_id=field.id, value="0").exists() ) self.assertTrue( - CustomProfileFieldValue.objects.filter(field_id=field.id, value="emacs").exists() + CustomProfileFieldValue.objects.filter(field_id=field.id, value="1").exists() ) - new_options = {"emacs": {"text": "Emacs", "order": "1"}} + new_options = {"1": {"text": "Emacs", "order": "1"}} result = self.client_patch( f"/json/realm/profile_fields/{field.id}", info={"name": "Favorite editor", "field_data": orjson.dumps(new_options).decode()}, ) self.assert_json_success(result) self.assertFalse( - CustomProfileFieldValue.objects.filter(field_id=field.id, value="vim").exists() + CustomProfileFieldValue.objects.filter(field_id=field.id, value="0").exists() ) self.assertTrue( - CustomProfileFieldValue.objects.filter(field_id=field.id, value="emacs").exists() + CustomProfileFieldValue.objects.filter(field_id=field.id, value="1").exists() ) diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py index 773151fc76..0943271718 100644 --- a/zerver/tests/test_users.py +++ b/zerver/tests/test_users.py @@ -608,7 +608,7 @@ class PermissionTest(ZulipTestCase): "Phone number": "short text data", "Biography": "long text data", "Favorite food": "short text data", - "Favorite editor": "vim", + "Favorite editor": "0", "Birthday": "1909-03-05", "Favorite website": "https://zulip.com", "Mentor": [cordelia.id], diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index 7566fa71c3..aec10bc517 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -726,8 +726,8 @@ class Command(BaseCommand): hint="Or drink, if you'd prefer", ) field_data: ProfileFieldData = { - "vim": {"text": "Vim", "order": "1"}, - "emacs": {"text": "Emacs", "order": "2"}, + "0": {"text": "Vim", "order": "1"}, + "1": {"text": "Emacs", "order": "2"}, } favorite_editor = try_add_realm_custom_profile_field( zulip_realm, "Favorite editor", CustomProfileField.SELECT, field_data=field_data @@ -754,7 +754,7 @@ class Command(BaseCommand): {"id": phone_number.id, "value": "+1-234-567-8901"}, {"id": biography.id, "value": "Betrayer of Othello."}, {"id": favorite_food.id, "value": "Apples"}, - {"id": favorite_editor.id, "value": "emacs"}, + {"id": favorite_editor.id, "value": "1"}, {"id": birthday.id, "value": "2000-01-01"}, {"id": favorite_website.id, "value": "https://zulip.readthedocs.io/en/latest/"}, {"id": mentor.id, "value": [hamlet.id]}, @@ -770,7 +770,7 @@ class Command(BaseCommand): "value": "I am:\n* The prince of Denmark\n* Nephew to the usurping Claudius", }, {"id": favorite_food.id, "value": "Dark chocolate"}, - {"id": favorite_editor.id, "value": "vim"}, + {"id": favorite_editor.id, "value": "0"}, {"id": birthday.id, "value": "1900-01-01"}, {"id": favorite_website.id, "value": "https://blog.zulig.org"}, {"id": mentor.id, "value": [iago.id]},