mirror of https://github.com/zulip/zulip.git
custom_profile_field: Add "Pronouns" custom field type.
This commit adds "Pronouns" custom profile field type. We also add "Pronouns" type field in the development environment
This commit is contained in:
parent
ab9c5ae482
commit
2bf70fe4db
|
@ -20,6 +20,13 @@ format used by the Zulip server that they are interacting with.
|
||||||
|
|
||||||
## Changes in Zulip 6.0
|
## Changes in Zulip 6.0
|
||||||
|
|
||||||
|
**Feature level 151**
|
||||||
|
|
||||||
|
* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
|
||||||
|
[`POST /realm/profile_fields`](/api/create-custom-profile-field),
|
||||||
|
[`GET /realm/profile_fields`](/api/get-custom-profile-fields): Added
|
||||||
|
pronouns custom profile field type.
|
||||||
|
|
||||||
**Feature level 150**
|
**Feature level 150**
|
||||||
|
|
||||||
* [`GET /events`](/api/get-events): Separate events are now sent on changing
|
* [`GET /events`](/api/get-events): Separate events are now sent on changing
|
||||||
|
|
|
@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
|
||||||
# Changes should be accompanied by documentation explaining what the
|
# Changes should be accompanied by documentation explaining what the
|
||||||
# new level means in templates/zerver/api/changelog.md, as well as
|
# new level means in templates/zerver/api/changelog.md, as well as
|
||||||
# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.
|
# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.
|
||||||
API_FEATURE_LEVEL = 150
|
API_FEATURE_LEVEL = 151
|
||||||
|
|
||||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||||
# only when going from an old version of the code to a newer version. Bump
|
# only when going from an old version of the code to a newer version. Bump
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Generated by Django 4.0.7 on 2022-10-04 13:59
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("zerver", "0416_set_default_emoji_style"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="customprofilefield",
|
||||||
|
name="field_type",
|
||||||
|
field=models.PositiveSmallIntegerField(
|
||||||
|
choices=[
|
||||||
|
(1, "Short text"),
|
||||||
|
(2, "Long text"),
|
||||||
|
(4, "Date picker"),
|
||||||
|
(5, "Link"),
|
||||||
|
(7, "External account"),
|
||||||
|
(8, "Pronouns"),
|
||||||
|
(3, "List of options"),
|
||||||
|
(6, "Person picker"),
|
||||||
|
],
|
||||||
|
default=1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -4479,6 +4479,7 @@ class CustomProfileField(models.Model):
|
||||||
URL = 5
|
URL = 5
|
||||||
USER = 6
|
USER = 6
|
||||||
EXTERNAL_ACCOUNT = 7
|
EXTERNAL_ACCOUNT = 7
|
||||||
|
PRONOUNS = 8
|
||||||
|
|
||||||
# These are the fields whose validators require more than var_name
|
# These are the fields whose validators require more than var_name
|
||||||
# and value argument. i.e. SELECT require field_data, USER require
|
# and value argument. i.e. SELECT require field_data, USER require
|
||||||
|
@ -4510,6 +4511,7 @@ class CustomProfileField(models.Model):
|
||||||
str,
|
str,
|
||||||
"EXTERNAL_ACCOUNT",
|
"EXTERNAL_ACCOUNT",
|
||||||
),
|
),
|
||||||
|
(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 = [*FIELD_TYPE_DATA, *SELECT_FIELD_TYPE_DATA, *USER_FIELD_TYPE_DATA]
|
||||||
|
|
|
@ -417,7 +417,7 @@ def get_realm_profile_fields(client: Client) -> None:
|
||||||
def reorder_realm_profile_fields(client: Client) -> None:
|
def reorder_realm_profile_fields(client: Client) -> None:
|
||||||
# {code_example|start}
|
# {code_example|start}
|
||||||
# Reorder the custom profile fields in the user's organization.
|
# Reorder the custom profile fields in the user's organization.
|
||||||
order = [8, 7, 6, 5, 4, 3, 2, 1]
|
order = [9, 8, 7, 6, 5, 4, 3, 2, 1]
|
||||||
request = {"order": json.dumps(order)}
|
request = {"order": json.dumps(order)}
|
||||||
|
|
||||||
result = client.call_endpoint(url="/realm/profile_fields", method="PATCH", request=request)
|
result = client.call_endpoint(url="/realm/profile_fields", method="PATCH", request=request)
|
||||||
|
|
|
@ -8301,6 +8301,13 @@ paths:
|
||||||
"field_data": '{"subtype":"github"}',
|
"field_data": '{"subtype":"github"}',
|
||||||
"order": 8,
|
"order": 8,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"name": "Pronouns",
|
||||||
|
"type": 8,
|
||||||
|
"hint": "What pronouns should people use to refer to you?",
|
||||||
|
"order": 9,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
patch:
|
patch:
|
||||||
|
@ -8328,7 +8335,7 @@ paths:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: integer
|
type: integer
|
||||||
example: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
|
example: [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
|
||||||
required: true
|
required: true
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
|
@ -8372,6 +8379,9 @@ paths:
|
||||||
- **5**: Link
|
- **5**: Link
|
||||||
- **6**: Person picker
|
- **6**: Person picker
|
||||||
- **7**: External account
|
- **7**: External account
|
||||||
|
- **8**: Pronouns
|
||||||
|
|
||||||
|
**Changes**: Field type `8` added in Zulip 6.0 (feature level 151).
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
example: 3
|
example: 3
|
||||||
|
@ -9787,6 +9797,9 @@ paths:
|
||||||
- `URL` for links.
|
- `URL` for links.
|
||||||
- `EXTERNAL_ACCOUNT` for external accounts.
|
- `EXTERNAL_ACCOUNT` for external accounts.
|
||||||
- `USER` for selecting a user for the field.
|
- `USER` for selecting a user for the field.
|
||||||
|
- `PRONOUNS` for a short text field with convenient typeahead for one's preferred pronouns.
|
||||||
|
|
||||||
|
**Changes**: `PRONOUNS` type added in Zulip 6.0 (feature level 151).
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
|
@ -15484,6 +15497,9 @@ components:
|
||||||
- **5**: Link
|
- **5**: Link
|
||||||
- **6**: Person picker
|
- **6**: Person picker
|
||||||
- **7**: External account
|
- **7**: External account
|
||||||
|
- **8**: Pronouns
|
||||||
|
|
||||||
|
**Changes**: Field type `8` added in Zulip 6.0 (feature level 151).
|
||||||
order:
|
order:
|
||||||
type: integer
|
type: integer
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -366,6 +366,16 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase):
|
||||||
result = self.client_post("/json/realm/profile_fields", info=data)
|
result = self.client_post("/json/realm/profile_fields", info=data)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
|
||||||
|
def test_create_field_of_type_pronouns(self) -> None:
|
||||||
|
self.login("iago")
|
||||||
|
data = {
|
||||||
|
"name": "Pronouns for you",
|
||||||
|
"hint": "What pronouns should people use to refer to you?",
|
||||||
|
"field_type": CustomProfileField.PRONOUNS,
|
||||||
|
}
|
||||||
|
result = self.client_post("/json/realm/profile_fields", info=data)
|
||||||
|
self.assert_json_success(result)
|
||||||
|
|
||||||
def test_not_realm_admin(self) -> None:
|
def test_not_realm_admin(self) -> None:
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
result = self.client_post("/json/realm/profile_fields")
|
result = self.client_post("/json/realm/profile_fields")
|
||||||
|
@ -657,6 +667,7 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase):
|
||||||
("Favorite website", "https://zulip.com"),
|
("Favorite website", "https://zulip.com"),
|
||||||
("Mentor", [self.example_user("cordelia").id]),
|
("Mentor", [self.example_user("cordelia").id]),
|
||||||
("GitHub username", "zulip-mobile"),
|
("GitHub username", "zulip-mobile"),
|
||||||
|
("Pronouns", "he/him"),
|
||||||
]
|
]
|
||||||
|
|
||||||
data: List[ProfileDataElementUpdateDict] = []
|
data: List[ProfileDataElementUpdateDict] = []
|
||||||
|
|
|
@ -614,6 +614,7 @@ class PermissionTest(ZulipTestCase):
|
||||||
"Favorite website": "https://zulip.com",
|
"Favorite website": "https://zulip.com",
|
||||||
"Mentor": [cordelia.id],
|
"Mentor": [cordelia.id],
|
||||||
"GitHub username": "timabbott",
|
"GitHub username": "timabbott",
|
||||||
|
"Pronouns": "she/her",
|
||||||
}
|
}
|
||||||
|
|
||||||
for field_name in fields:
|
for field_name in fields:
|
||||||
|
@ -722,6 +723,7 @@ class PermissionTest(ZulipTestCase):
|
||||||
"Favorite website": "https://zulip.github.io",
|
"Favorite website": "https://zulip.github.io",
|
||||||
"Mentor": [hamlet.id],
|
"Mentor": [hamlet.id],
|
||||||
"GitHub username": "timabbott",
|
"GitHub username": "timabbott",
|
||||||
|
"Pronouns": None,
|
||||||
}
|
}
|
||||||
new_profile_data = []
|
new_profile_data = []
|
||||||
for field_name in fields:
|
for field_name in fields:
|
||||||
|
|
|
@ -725,6 +725,12 @@ class Command(BaseCommand):
|
||||||
zulip_realm, "Mentor", CustomProfileField.USER
|
zulip_realm, "Mentor", CustomProfileField.USER
|
||||||
)
|
)
|
||||||
github_profile = try_add_realm_default_custom_profile_field(zulip_realm, "github")
|
github_profile = try_add_realm_default_custom_profile_field(zulip_realm, "github")
|
||||||
|
pronouns = try_add_realm_custom_profile_field(
|
||||||
|
zulip_realm,
|
||||||
|
"Pronouns",
|
||||||
|
CustomProfileField.PRONOUNS,
|
||||||
|
hint="What pronouns should people use to refer to you?",
|
||||||
|
)
|
||||||
|
|
||||||
# Fill in values for Iago and Hamlet
|
# Fill in values for Iago and Hamlet
|
||||||
hamlet = get_user_by_delivery_email("hamlet@zulip.com", zulip_realm)
|
hamlet = get_user_by_delivery_email("hamlet@zulip.com", zulip_realm)
|
||||||
|
@ -739,6 +745,7 @@ class Command(BaseCommand):
|
||||||
{"id": favorite_website.id, "value": "https://zulip.readthedocs.io/en/latest/"},
|
{"id": favorite_website.id, "value": "https://zulip.readthedocs.io/en/latest/"},
|
||||||
{"id": mentor.id, "value": [hamlet.id]},
|
{"id": mentor.id, "value": [hamlet.id]},
|
||||||
{"id": github_profile.id, "value": "zulip"},
|
{"id": github_profile.id, "value": "zulip"},
|
||||||
|
{"id": pronouns.id, "value": "he/him"},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
do_update_user_custom_profile_data_if_changed(
|
do_update_user_custom_profile_data_if_changed(
|
||||||
|
@ -755,6 +762,7 @@ class Command(BaseCommand):
|
||||||
{"id": favorite_website.id, "value": "https://blog.zulig.org"},
|
{"id": favorite_website.id, "value": "https://blog.zulig.org"},
|
||||||
{"id": mentor.id, "value": [iago.id]},
|
{"id": mentor.id, "value": [iago.id]},
|
||||||
{"id": github_profile.id, "value": "zulipbot"},
|
{"id": github_profile.id, "value": "zulipbot"},
|
||||||
|
{"id": pronouns.id, "value": "he/him"},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue