diff --git a/docs/tutorials/writing-views.md b/docs/tutorials/writing-views.md index e0fa157efc..e9be7ff04f 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_variables def 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.md index b35cbad157..1b9f423867 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 in diff --git a/version.py b/version.py index 08c34af2a6..74a19be046 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. Bump diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.js index 3317f2dfd3..d8e938a3dc 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: 'notnewbie@zulip.com', 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.py index c6f10d4acf..3d782b196c 100644 --- a/zerver/openapi/python_examples.py +++ b/zerver/openapi/python_examples.py @@ -153,7 +153,6 @@ def create_user(client: Client) -> None: 'email': 'newbie@zulip.com', '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.yaml index ead35703d3..b5ea648d0b 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -1520,14 +1520,6 @@ paths: type: string example: New User required: true - - name: short_name - in: query - description: | - The short name of the new user. Not user-visible. - schema: - type: string - example: newuser - required: true responses: "200": description: Success. diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py index bc45dfa87d..76d0ad898e 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 ignored result = self.client_post("/json/users", dict( - email='romeo@not-zulip.com', + email='romeo@zulip.com', 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='romeo@not-zulip.com', password='xxxx', full_name='Romeo Montague', - short_name='Romeo', )) self.assert_json_error(result, "Email 'romeo@not-zulip.com' not allowed in this organization") @@ -812,7 +812,6 @@ class AdminCreateUserTest(ZulipTestCase): email='romeo@zulip.net', password='xxxx', full_name='Romeo Montague', - short_name='Romeo', ) # Check can't use a bad password with zxcvbn enabled with self.settings(PASSWORD_MIN_LENGTH=6, PASSWORD_MIN_GUESSES=1000): @@ -825,7 +824,7 @@ class AdminCreateUserTest(ZulipTestCase): # Romeo is a newly registered user new_user = get_user_by_delivery_email('romeo@zulip.net', 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.py index 09613fb4c0..d3c4bb3af2 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()