Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
api: Do not require short_name to create user.
Steve Howellc60f4236a93c
diff --git a/docs/tutorials/writing-views.md b/docs/tutorials/writing-views.mdindex e0fa157efc0..e9be7ff04f6 100644--- a/docs/tutorials/writing-views.md+++ b/docs/tutorials/writing-views.md@@ -153,7 +153,7 @@ from zerver.lib.request import has_request_variables, REQ@require_realm_admin@has_request_variablesdef create_user_backend(request, user_profile, email=REQ(), password=REQ(),- full_name=REQ(), short_name=REQ()):+ full_name=REQ()):# ... code here```diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.mdindex b35cbad1576..1b9f423867e 100644--- a/templates/zerver/api/changelog.md+++ b/templates/zerver/api/changelog.md@@ -10,6 +10,11 @@ below features are supported.## Changes in Zulip 3.1+**Feature level 27**++* The `short_name` field is removed from `display_recipients`+ in `POST /users`.+**Feature level 26*** The `sender_short_name` field is no longer included indiff --git a/version.py b/version.pyindex 08c34af2a6b..74a19be0466 100644--- a/version.py+++ b/version.py@@ -29,7 +29,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"## Changes should be accompanied by documentation explaining what the# new level means in templates/zerver/api/changelog.md.-API_FEATURE_LEVEL = 26+API_FEATURE_LEVEL = 27# 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. Bumpdiff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.jsindex 3317f2dfd39..d8e938a3dcc 100644--- a/zerver/openapi/javascript_examples.js+++ b/zerver/openapi/javascript_examples.js@@ -130,7 +130,6 @@ add_example('create_user', '/users:post', 200, async (client) => {email: '[email protected]',password: 'temp',full_name: 'New User',- short_name: 'newbie',};return await client.users.create(params);diff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.pyindex c6f10d4acf3..3d782b196c1 100644--- a/zerver/openapi/python_examples.py+++ b/zerver/openapi/python_examples.py@@ -153,7 +153,6 @@ def create_user(client: Client) -> None:'email': '[email protected]','password': 'temp','full_name': 'New User',- 'short_name': 'newbie',}result = client.create_user(request)# {code_example|end}diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex ead35703d39..b5ea648d0bd 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -1520,14 +1520,6 @@ paths:type: stringexample: New Userrequired: true- - name: short_name- in: query- description: |- The short name of the new user. Not user-visible.- schema:- type: string- example: newuser- required: trueresponses:"200":description: Success.diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.pyindex bc45dfa87d6..76d0ad898e6 100644--- a/zerver/tests/test_users.py+++ b/zerver/tests/test_users.py@@ -782,18 +782,19 @@ class AdminCreateUserTest(ZulipTestCase):))self.assert_json_error(result, "Missing 'full_name' argument")+ # Test short_name gets properly ignoredresult = self.client_post("/json/users", dict(- email='[email protected]',+ email='[email protected]',password='xxxx',full_name='Romeo Montague',+ short_name='DEPRECATED'))- self.assert_json_error(result, "Missing 'short_name' argument")+ self.assert_json_success(result)result = self.client_post("/json/users", dict(email='broken',password='xxxx',full_name='Romeo Montague',- short_name='Romeo',))self.assert_json_error(result, "Bad name or username")@@ -802,7 +803,6 @@ class AdminCreateUserTest(ZulipTestCase):email='[email protected]',password='xxxx',full_name='Romeo Montague',- short_name='Romeo',))self.assert_json_error(result,"Email '[email protected]' not allowed in this organization")@@ -812,7 +812,6 @@ class AdminCreateUserTest(ZulipTestCase):email='[email protected]',password='xxxx',full_name='Romeo Montague',- short_name='Romeo',)# Check can't use a bad password with zxcvbn enabledwith self.settings(PASSWORD_MIN_LENGTH=6, PASSWORD_MIN_GUESSES=1000):@@ -825,7 +824,7 @@ class AdminCreateUserTest(ZulipTestCase):# Romeo is a newly registered usernew_user = get_user_by_delivery_email('[email protected]', get_realm('zulip'))self.assertEqual(new_user.full_name, 'Romeo Montague')- self.assertEqual(new_user.short_name, 'Romeo')+ self.assertEqual(new_user.short_name, 'deprecated')# Make sure the recipient field is set correctly.self.assertEqual(new_user.recipient, Recipient.objects.get(type=Recipient.PERSONAL,diff --git a/zerver/views/users.py b/zerver/views/users.pyindex 09613fb4c0e..d3c4bb3af20 100644--- a/zerver/views/users.py+++ b/zerver/views/users.py@@ -486,9 +486,13 @@ def get_members_backend(request: HttpRequest, user_profile: UserProfile, user_id@require_realm_admin@has_request_variables-def create_user_backend(request: HttpRequest, user_profile: UserProfile,- email: str=REQ(), password: str=REQ(), full_name_raw: str=REQ("full_name"),- short_name: str=REQ()) -> HttpResponse:+def create_user_backend(+ request: HttpRequest,+ user_profile: UserProfile,+ email: str=REQ(),+ password: str=REQ(),+ full_name_raw: str=REQ("full_name"),+) -> HttpResponse:full_name = check_full_name(full_name_raw)form = CreateUserForm({'full_name': full_name, 'email': email})if not form.is_valid():@@ -518,6 +522,8 @@ def create_user_backend(request: HttpRequest, user_profile: UserProfile,if not check_password_strength(password):return json_error(PASSWORD_TOO_WEAK_ERROR)+ short_name = 'deprecated'+do_create_user(email, password, realm, full_name, short_name, acting_user=user_profile)return json_success()