From ee612dafacea1c4d00aa682333f8bce73e2f7677 Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Wed, 7 Feb 2024 21:41:43 +0530 Subject: [PATCH] settings: Rename signup_notifications_stream realm setting. This commit renames the realm-level setting 'signup_notifications_stream' to 'signup_announcements_stream'. The new name reflects better what the setting does. --- api_docs/changelog.md | 5 +- web/e2e-tests/admin.test.ts | 6 +- web/src/admin.js | 4 +- web/src/server_events_dispatch.js | 8 +-- web/src/settings_components.js | 12 ++-- web/src/settings_org.js | 14 ++-- web/src/stream_edit.js | 8 +-- web/src/ui_init.js | 2 +- .../confirm_deactivate_stream.hbs | 2 +- .../settings/organization_settings_admin.hbs | 4 +- web/tests/dispatch.test.js | 6 +- web/tests/dispatch_subs.test.js | 4 +- web/tests/lib/events.js | 4 +- zerver/actions/create_realm.py | 6 +- zerver/actions/create_user.py | 10 +-- zerver/actions/realm_settings.py | 14 ++-- zerver/lib/event_schema.py | 2 +- zerver/lib/events.py | 8 +-- zerver/lib/import_realm.py | 2 +- ...tream_realm_signup_announcements_stream.py | 18 ++++++ zerver/models/realms.py | 10 +-- zerver/openapi/zulip.yaml | 10 ++- zerver/tests/test_audit_log.py | 10 +-- zerver/tests/test_events.py | 14 ++-- zerver/tests/test_home.py | 8 +-- zerver/tests/test_new_users.py | 6 +- zerver/tests/test_realm.py | 64 +++++++++---------- zerver/tests/test_signup.py | 4 +- zerver/views/realm.py | 28 ++++---- 29 files changed, 159 insertions(+), 134 deletions(-) create mode 100644 zerver/migrations/0498_rename_signup_notifications_stream_realm_signup_announcements_stream.py diff --git a/api_docs/changelog.md b/api_docs/changelog.md index 4211e3e01d..ae9aaef22b 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -23,8 +23,9 @@ format used by the Zulip server that they are interacting with. **Feature level 241** * [`POST /register`](/api/register-queue), [`POST /events`](/api/get-events), - `PATCH /realm`: Renamed the realm setting `notifications_stream` - to `new_stream_announcements_stream`. + `PATCH /realm`: Renamed the realm settings `notifications_stream` and + `signup_notifications_stream` to `new_stream_announcements_stream` and + `signup_announcements_stream`, respectively. **Feature level 240** diff --git a/web/e2e-tests/admin.test.ts b/web/e2e-tests/admin.test.ts index d25865cd2f..e3ffb6161c 100644 --- a/web/e2e-tests/admin.test.ts +++ b/web/e2e-tests/admin.test.ts @@ -47,10 +47,10 @@ async function test_change_new_stream_announcements_stream(page: Page): Promise< await submit_announcements_stream_settings(page); } -async function test_change_signup_notifications_stream(page: Page): Promise { +async function test_change_signup_announcements_stream(page: Page): Promise { console.log('Changing signup notifications stream to Verona by filtering with "verona"'); - await page.click("#realm_signup_notifications_stream_id_widget"); + await page.click("#realm_signup_announcements_stream_id_widget"); await page.waitForSelector(".dropdown-list-search-input", {visible: true}); await page.type(".dropdown-list-search-input", "verona"); @@ -264,7 +264,7 @@ async function admin_test(page: Page): Promise { await common.manage_organization(page); await test_change_new_stream_announcements_stream(page); - await test_change_signup_notifications_stream(page); + await test_change_signup_announcements_stream(page); await test_organization_permissions(page); // Currently, Firefox (with puppeteer) does not support file upload: diff --git a/web/src/admin.js b/web/src/admin.js index a60abcfe6d..3709fdab05 100644 --- a/web/src/admin.js +++ b/web/src/admin.js @@ -31,7 +31,7 @@ const admin_settings_label = { realm_allow_edit_history: $t({defaultMessage: "Enable message edit history"}), realm_mandatory_topics: $t({defaultMessage: "Require topics in stream messages"}), realm_new_stream_announcements_stream: $t({defaultMessage: "New stream announcements"}), - realm_signup_notifications_stream: $t({defaultMessage: "New user announcements"}), + realm_signup_announcements_stream: $t({defaultMessage: "New user announcements"}), realm_inline_image_preview: $t({ defaultMessage: "Show previews of uploaded and linked images and videos", }), @@ -138,7 +138,7 @@ export function build_page() { realm_default_language_code: realm.realm_default_language, realm_waiting_period_threshold: realm.realm_waiting_period_threshold, realm_new_stream_announcements_stream_id: realm.realm_new_stream_announcements_stream_id, - realm_signup_notifications_stream_id: realm.realm_signup_notifications_stream_id, + realm_signup_announcements_stream_id: realm.realm_signup_announcements_stream_id, is_admin: current_user.is_admin, is_guest: current_user.is_guest, is_owner: current_user.is_owner, diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js index b0224827a6..d035f62dae 100644 --- a/web/src/server_events_dispatch.js +++ b/web/src/server_events_dispatch.js @@ -240,7 +240,7 @@ export function dispatch_normal_event(event) { send_welcome_emails: noop, message_content_allowed_in_email_notifications: noop, enable_spectator_access: noop, - signup_notifications_stream_id: noop, + signup_announcements_stream_id: noop, emails_restricted_to_domains: noop, video_chat_provider: compose_call_ui.update_audio_and_video_chat_button_display, jitsi_server_url: compose_call_ui.update_audio_and_video_chat_button_display, @@ -564,9 +564,9 @@ export function dispatch_normal_event(event) { realm.realm_new_stream_announcements_stream_id = -1; settings_org.sync_realm_settings("new_stream_announcements_stream_id"); } - if (realm.realm_signup_notifications_stream_id === stream.stream_id) { - realm.realm_signup_notifications_stream_id = -1; - settings_org.sync_realm_settings("signup_notifications_stream_id"); + if (realm.realm_signup_announcements_stream_id === stream.stream_id) { + realm.realm_signup_announcements_stream_id = -1; + settings_org.sync_realm_settings("signup_announcements_stream_id"); } } stream_list.update_subscribe_to_more_streams_link(); diff --git a/web/src/settings_components.js b/web/src/settings_components.js index 255d297ad9..7da94baced 100644 --- a/web/src/settings_components.js +++ b/web/src/settings_components.js @@ -240,7 +240,7 @@ export function sort_object_by_key(obj) { export let default_code_language_widget = null; export let new_stream_announcements_stream_widget = null; -export let signup_notifications_stream_widget = null; +export let signup_announcements_stream_widget = null; export let create_multiuse_invite_group_widget = null; export let can_remove_subscribers_group_widget = null; export let can_access_all_users_group_widget = null; @@ -251,8 +251,8 @@ export function get_widget_for_dropdown_list_settings(property_name) { switch (property_name) { case "realm_new_stream_announcements_stream_id": return new_stream_announcements_stream_widget; - case "realm_signup_notifications_stream_id": - return signup_notifications_stream_widget; + case "realm_signup_announcements_stream_id": + return signup_announcements_stream_widget; case "realm_default_code_block_language": return default_code_language_widget; case "realm_create_multiuse_invite_group": @@ -277,8 +277,8 @@ export function set_new_stream_announcements_stream_widget(widget) { new_stream_announcements_stream_widget = widget; } -export function set_signup_notifications_stream_widget(widget) { - signup_notifications_stream_widget = widget; +export function set_signup_announcements_stream_widget(widget) { + signup_announcements_stream_widget = widget; } export function set_create_multiuse_invite_group_widget(widget) { @@ -505,7 +505,7 @@ export function check_property_changed(elem, for_realm_default_settings, sub, gr proposed_val = JSON.stringify(proposed_val); break; case "realm_new_stream_announcements_stream_id": - case "realm_signup_notifications_stream_id": + case "realm_signup_announcements_stream_id": case "realm_default_code_block_language": case "can_remove_subscribers_group": case "realm_create_multiuse_invite_group": diff --git a/web/src/settings_org.js b/web/src/settings_org.js index 1b109477d0..bee907b196 100644 --- a/web/src/settings_org.js +++ b/web/src/settings_org.js @@ -475,7 +475,7 @@ export function discard_property_element_changes(elem, for_realm_default_setting populate_auth_methods(property_value); break; case "realm_new_stream_announcements_stream_id": - case "realm_signup_notifications_stream_id": + case "realm_signup_announcements_stream_id": case "realm_default_code_block_language": case "can_remove_subscribers_group": case "realm_create_multiuse_invite_group": @@ -660,26 +660,26 @@ export function init_dropdown_widgets() { ); new_stream_announcements_stream_widget.setup(); - const signup_notifications_stream_widget = new dropdown_widget.DropdownWidget({ - widget_name: "realm_signup_notifications_stream_id", + const signup_announcements_stream_widget = new dropdown_widget.DropdownWidget({ + widget_name: "realm_signup_announcements_stream_id", get_options: notification_stream_options, $events_container: $("#settings_overlay_container #organization-settings"), item_click_callback(event, dropdown) { dropdown.hide(); event.preventDefault(); event.stopPropagation(); - settings_components.signup_notifications_stream_widget.render(); + settings_components.signup_announcements_stream_widget.render(); settings_components.save_discard_widget_status_handler($("#org-notifications")); }, tippy_props: { placement: "bottom-start", }, - default_id: realm.realm_signup_notifications_stream_id, + default_id: realm.realm_signup_announcements_stream_id, unique_id_type: dropdown_widget.DATA_TYPES.NUMBER, text_if_current_value_not_in_options: $t({defaultMessage: "Cannot view stream"}), }); - settings_components.set_signup_notifications_stream_widget(signup_notifications_stream_widget); - signup_notifications_stream_widget.setup(); + settings_components.set_signup_announcements_stream_widget(signup_announcements_stream_widget); + signup_announcements_stream_widget.setup(); const default_code_language_widget = new dropdown_widget.DropdownWidget({ widget_name: "realm_default_code_block_language", diff --git a/web/src/stream_edit.js b/web/src/stream_edit.js index f33e8748d5..a5797cec36 100644 --- a/web/src/stream_edit.js +++ b/web/src/stream_edit.js @@ -608,15 +608,15 @@ export function initialize() { const is_new_stream_announcements_stream = stream_id === realm.realm_new_stream_announcements_stream_id; - const is_signup_notification_stream = - stream_id === realm.realm_signup_notifications_stream_id; + const is_signup_announcements_stream = + stream_id === realm.realm_signup_announcements_stream_id; const is_announcement_stream = - is_new_stream_announcements_stream || is_signup_notification_stream; + is_new_stream_announcements_stream || is_signup_announcements_stream; const html_body = render_settings_deactivation_stream_modal({ stream_name_with_privacy_symbol_html, is_new_stream_announcements_stream, - is_signup_notification_stream, + is_signup_announcements_stream, is_announcement_stream, }); diff --git a/web/src/ui_init.js b/web/src/ui_init.js index 27f27243f3..4bf7b35632 100644 --- a/web/src/ui_init.js +++ b/web/src/ui_init.js @@ -597,7 +597,7 @@ export function initialize_everything(state_data) { "realm_push_notifications_enabled", "realm_push_notifications_enabled_end_timestamp", "realm_send_welcome_emails", - "realm_signup_notifications_stream_id", + "realm_signup_announcements_stream_id", "realm_upload_quota_mib", "realm_uri", "realm_user_group_edit_policy", diff --git a/web/templates/confirm_dialog/confirm_deactivate_stream.hbs b/web/templates/confirm_dialog/confirm_deactivate_stream.hbs index 8bf0330922..737e21c1f7 100644 --- a/web/templates/confirm_dialog/confirm_deactivate_stream.hbs +++ b/web/templates/confirm_dialog/confirm_deactivate_stream.hbs @@ -10,7 +10,7 @@ {{#if is_new_stream_announcements_stream}}
  • {{#tr}}New stream notifications{{/tr}}
  • {{/if}} - {{#if is_signup_notification_stream}} + {{#if is_signup_announcements_stream}}
  • {{#tr}}New user notifications{{/tr}}
  • {{/if}} diff --git a/web/templates/settings/organization_settings_admin.hbs b/web/templates/settings/organization_settings_admin.hbs index 2e9a6b23e9..b1323c5b5d 100644 --- a/web/templates/settings/organization_settings_admin.hbs +++ b/web/templates/settings/organization_settings_admin.hbs @@ -22,8 +22,8 @@ value_type="number"}} {{> ../dropdown_widget_with_label - widget_name="realm_signup_notifications_stream_id" - label=admin_settings_label.realm_signup_notifications_stream + widget_name="realm_signup_announcements_stream_id" + label=admin_settings_label.realm_signup_announcements_stream value_type="number"}} diff --git a/web/tests/dispatch.test.js b/web/tests/dispatch.test.js index c676673a51..849ef80a1f 100644 --- a/web/tests/dispatch.test.js +++ b/web/tests/dispatch.test.js @@ -532,10 +532,10 @@ run_test("realm settings", ({override}) => { assert_same(realm.realm_new_stream_announcements_stream_id, 42); realm.realm_new_stream_announcements_stream_id = -1; // make sure to reset for future tests - event = event_fixtures.realm__update__signup_notifications_stream_id; + event = event_fixtures.realm__update__signup_announcements_stream_id; dispatch(event); - assert_same(realm.realm_signup_notifications_stream_id, 41); - realm.realm_signup_notifications_stream_id = -1; // make sure to reset for future tests + assert_same(realm.realm_signup_announcements_stream_id, 41); + realm.realm_signup_announcements_stream_id = -1; // make sure to reset for future tests event = event_fixtures.realm__update__default_code_block_language; dispatch(event); diff --git a/web/tests/dispatch_subs.test.js b/web/tests/dispatch_subs.test.js index 2d842ef0d9..091b55ec87 100644 --- a/web/tests/dispatch_subs.test.js +++ b/web/tests/dispatch_subs.test.js @@ -242,7 +242,7 @@ test("stream delete (special streams)", ({override}) => { // sanity check data assert.equal(event.streams.length, 2); realm.realm_new_stream_announcements_stream_id = event.streams[0].stream_id; - realm.realm_signup_notifications_stream_id = event.streams[1].stream_id; + realm.realm_signup_announcements_stream_id = event.streams[1].stream_id; override(stream_settings_ui, "remove_stream", noop); override(settings_org, "sync_realm_settings", noop); @@ -254,7 +254,7 @@ test("stream delete (special streams)", ({override}) => { dispatch(event); assert.equal(realm.realm_new_stream_announcements_stream_id, -1); - assert.equal(realm.realm_signup_notifications_stream_id, -1); + assert.equal(realm.realm_signup_announcements_stream_id, -1); }); test("stream delete (stream is selected in compose)", ({override, override_rewire}) => { diff --git a/web/tests/lib/events.js b/web/tests/lib/events.js index cddd3953b7..e831498ec1 100644 --- a/web/tests/lib/events.js +++ b/web/tests/lib/events.js @@ -358,10 +358,10 @@ exports.fixtures = { value: 50, }, - realm__update__signup_notifications_stream_id: { + realm__update__signup_announcements_stream_id: { type: "realm", op: "update", - property: "signup_notifications_stream_id", + property: "signup_announcements_stream_id", value: 41, }, diff --git a/zerver/actions/create_realm.py b/zerver/actions/create_realm.py index 0e2e45a197..70cc8c67b1 100644 --- a/zerver/actions/create_realm.py +++ b/zerver/actions/create_realm.py @@ -284,16 +284,16 @@ def do_create_realm( # stream is the new_stream_announcements_stream. DefaultStream.objects.create(stream=new_stream_announcements_stream, realm=realm) - signup_notifications_stream = ensure_stream( + signup_announcements_stream = ensure_stream( realm, Realm.INITIAL_PRIVATE_STREAM_NAME, invite_only=True, stream_description="A private stream for core team members.", acting_user=None, ) - realm.signup_notifications_stream = signup_notifications_stream + realm.signup_announcements_stream = signup_announcements_stream - realm.save(update_fields=["new_stream_announcements_stream", "signup_notifications_stream"]) + realm.save(update_fields=["new_stream_announcements_stream", "signup_announcements_stream"]) if plan_type is None and settings.BILLING_ENABLED: # We use acting_user=None for setting the initial plan type. diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.py index 92b093d72f..27624c4cca 100644 --- a/zerver/actions/create_user.py +++ b/zerver/actions/create_user.py @@ -89,14 +89,14 @@ def create_historical_user_messages( def send_message_to_signup_notification_stream( sender: UserProfile, realm: Realm, message: str ) -> None: - signup_notifications_stream = realm.get_signup_notifications_stream() - if signup_notifications_stream is None: + signup_announcements_stream = realm.get_signup_announcements_stream() + if signup_announcements_stream is None: return with override_language(realm.default_language): topic_name = _("signups") - internal_send_stream_message(sender, signup_notifications_stream, topic_name, message) + internal_send_stream_message(sender, signup_announcements_stream, topic_name, message) def notify_new_user(user_profile: UserProfile) -> None: @@ -576,9 +576,9 @@ def do_create_user( ) if realm_creation: - assert realm.signup_notifications_stream is not None + assert realm.signup_announcements_stream is not None bulk_add_subscriptions( - realm, [realm.signup_notifications_stream], [user_profile], acting_user=None + realm, [realm.signup_announcements_stream], [user_profile], acting_user=None ) from zerver.lib.onboarding import send_initial_realm_messages diff --git a/zerver/actions/realm_settings.py b/zerver/actions/realm_settings.py index 16f70df3f1..9d9089edc9 100644 --- a/zerver/actions/realm_settings.py +++ b/zerver/actions/realm_settings.py @@ -260,7 +260,7 @@ def do_set_realm_authentication_methods( def do_set_realm_stream( realm: Realm, - field: Literal["new_stream_announcements_stream", "signup_notifications_stream"], + field: Literal["new_stream_announcements_stream", "signup_announcements_stream"], stream: Optional[Stream], stream_id: int, *, @@ -272,10 +272,10 @@ def do_set_realm_stream( old_value = realm.new_stream_announcements_stream_id realm.new_stream_announcements_stream = stream property = "new_stream_announcements_stream_id" - elif field == "signup_notifications_stream": - old_value = realm.signup_notifications_stream_id - realm.signup_notifications_stream = stream - property = "signup_notifications_stream_id" + elif field == "signup_announcements_stream": + old_value = realm.signup_announcements_stream_id + realm.signup_announcements_stream = stream + property = "signup_announcements_stream_id" else: raise AssertionError("Invalid realm stream field.") @@ -312,11 +312,11 @@ def do_set_realm_new_stream_announcements_stream( ) -def do_set_realm_signup_notifications_stream( +def do_set_realm_signup_announcements_stream( realm: Realm, stream: Optional[Stream], stream_id: int, *, acting_user: Optional[UserProfile] ) -> None: do_set_realm_stream( - realm, "signup_notifications_stream", stream, stream_id, acting_user=acting_user + realm, "signup_announcements_stream", stream, stream_id, acting_user=acting_user ) diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py index e5bcd19e94..851c1f2c9c 100644 --- a/zerver/lib/event_schema.py +++ b/zerver/lib/event_schema.py @@ -918,7 +918,7 @@ def check_realm_update( assert "extra_data" not in event - if prop in ["new_stream_announcements_stream_id", "signup_notifications_stream_id", "org_type"]: + if prop in ["new_stream_announcements_stream_id", "signup_announcements_stream_id", "org_type"]: assert isinstance(value, int) return diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 6d8c08cbc9..db370eee3a 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -368,11 +368,11 @@ def fetch_initial_state_data( else: state["realm_new_stream_announcements_stream_id"] = -1 - signup_notifications_stream = realm.get_signup_notifications_stream() - if signup_notifications_stream: - state["realm_signup_notifications_stream_id"] = signup_notifications_stream.id + signup_announcements_stream = realm.get_signup_announcements_stream() + if signup_announcements_stream: + state["realm_signup_announcements_stream_id"] = signup_announcements_stream.id else: - state["realm_signup_notifications_stream_id"] = -1 + state["realm_signup_announcements_stream_id"] = -1 state["max_stream_name_length"] = Stream.MAX_NAME_LENGTH state["max_stream_description_length"] = Stream.MAX_DESCRIPTION_LENGTH diff --git a/zerver/lib/import_realm.py b/zerver/lib/import_realm.py index 668d89c3a7..529c8720c9 100644 --- a/zerver/lib/import_realm.py +++ b/zerver/lib/import_realm.py @@ -956,7 +956,7 @@ def do_import_realm(import_dir: Path, subdomain: str, processes: int = 1) -> Rea re_map_foreign_keys( data, "zerver_realm", "new_stream_announcements_stream", related_table="stream" ) - re_map_foreign_keys(data, "zerver_realm", "signup_notifications_stream", related_table="stream") + re_map_foreign_keys(data, "zerver_realm", "signup_announcements_stream", related_table="stream") if "zerver_usergroup" in data: update_model_ids(UserGroup, data, "usergroup") for setting_name in Realm.REALM_PERMISSION_GROUP_SETTINGS: diff --git a/zerver/migrations/0498_rename_signup_notifications_stream_realm_signup_announcements_stream.py b/zerver/migrations/0498_rename_signup_notifications_stream_realm_signup_announcements_stream.py new file mode 100644 index 0000000000..2f832f613a --- /dev/null +++ b/zerver/migrations/0498_rename_signup_notifications_stream_realm_signup_announcements_stream.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.9 on 2024-02-07 16:42 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("zerver", "0497_rename_notifications_stream_realm_new_stream_announcements_stream"), + ] + + operations = [ + migrations.RenameField( + model_name="realm", + old_name="signup_notifications_stream", + new_name="signup_announcements_stream", + ), + ] diff --git a/zerver/models/realms.py b/zerver/models/realms.py index 050dd9021e..daf53ebb38 100644 --- a/zerver/models/realms.py +++ b/zerver/models/realms.py @@ -342,7 +342,7 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub blank=True, on_delete=models.SET_NULL, ) - signup_notifications_stream = models.ForeignKey( + signup_announcements_stream = models.ForeignKey( "Stream", related_name="+", null=True, @@ -792,12 +792,12 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub return self.new_stream_announcements_stream return None - def get_signup_notifications_stream(self) -> Optional["Stream"]: + def get_signup_announcements_stream(self) -> Optional["Stream"]: if ( - self.signup_notifications_stream is not None - and not self.signup_notifications_stream.deactivated + self.signup_announcements_stream is not None + and not self.signup_announcements_stream.deactivated ): - return self.signup_notifications_stream + return self.signup_announcements_stream return None @property diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index fe7b3c9fbc..f032827f51 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -4540,7 +4540,7 @@ paths: description: | Whether or not this organization is configured to send the standard Zulip [welcome emails](/help/disable-welcome-emails) to new users joining the organization. - signup_notifications_stream_id: + signup_announcements_stream_id: type: integer description: | The ID of the stream to which automated messages announcing @@ -4552,6 +4552,9 @@ paths: primarily relevant to clients containing UI for changing it. [new-user-announce]: /help/configure-notification-bot#new-user-announcements + + **Changes**: In Zulip 9.0 (feature level 241), renamed + 'signup_notifications_stream_id' to `signup_announcements_stream_id`. user_group_edit_policy: type: integer description: | @@ -15134,7 +15137,7 @@ paths: **Changes**: In Zulip 9.0 (feature level 241), renamed 'realm_notifications_stream_id' to `realm_new_stream_announcements_stream_id`. - realm_signup_notifications_stream_id: + realm_signup_announcements_stream_id: type: integer description: | Present if `realm` is present in `fetch_event_types`. @@ -15148,6 +15151,9 @@ paths: primarily relevant to clients containing UI for changing it. [new-user-announce]: /help/configure-notification-bot#new-user-announcements + + **Changes**: In Zulip 9.0 (feature level 241), renamed + 'realm_signup_notifications_stream_id' to `realm_signup_announcements_stream_id`. realm_user_settings_defaults: type: object additionalProperties: false diff --git a/zerver/tests/test_audit_log.py b/zerver/tests/test_audit_log.py index 934fee188b..3217952772 100644 --- a/zerver/tests/test_audit_log.py +++ b/zerver/tests/test_audit_log.py @@ -36,7 +36,7 @@ from zerver.actions.realm_settings import ( do_set_realm_authentication_methods, do_set_realm_new_stream_announcements_stream, do_set_realm_property, - do_set_realm_signup_notifications_stream, + do_set_realm_signup_announcements_stream, ) from zerver.actions.streams import ( bulk_add_subscriptions, @@ -580,15 +580,15 @@ class TestRealmAuditLog(ZulipTestCase): 1, ) - def test_set_realm_signup_notifications_stream(self) -> None: + def test_set_realm_signup_announcements_stream(self) -> None: now = timezone_now() realm = get_realm("zulip") user = self.example_user("hamlet") - old_value = realm.signup_notifications_stream_id + old_value = realm.signup_announcements_stream_id stream_name = "test" stream = self.make_stream(stream_name, realm) - do_set_realm_signup_notifications_stream(realm, stream, stream.id, acting_user=user) + do_set_realm_signup_announcements_stream(realm, stream, stream.id, acting_user=user) self.assertEqual( RealmAuditLog.objects.filter( realm=realm, @@ -598,7 +598,7 @@ class TestRealmAuditLog(ZulipTestCase): extra_data={ RealmAuditLog.OLD_VALUE: old_value, RealmAuditLog.NEW_VALUE: stream.id, - "property": "signup_notifications_stream", + "property": "signup_announcements_stream", }, ).count(), 1, diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index d630179f61..03116a6c70 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -80,7 +80,7 @@ from zerver.actions.realm_settings import ( do_set_realm_authentication_methods, do_set_realm_new_stream_announcements_stream, do_set_realm_property, - do_set_realm_signup_notifications_stream, + do_set_realm_signup_announcements_stream, do_set_realm_user_default_setting, ) from zerver.actions.scheduled_messages import ( @@ -2307,23 +2307,23 @@ class NormalActionsTest(BaseAction): ) check_realm_update("events[0]", events[0], "new_stream_announcements_stream_id") - def test_change_realm_signup_notifications_stream(self) -> None: + def test_change_realm_signup_announcements_stream(self) -> None: stream = get_stream("Rome", self.user_profile.realm) - for signup_notifications_stream, signup_notifications_stream_id in ( + for signup_announcements_stream, signup_announcements_stream_id in ( (stream, stream.id), (None, -1), ): events = self.verify_action( partial( - do_set_realm_signup_notifications_stream, + do_set_realm_signup_announcements_stream, self.user_profile.realm, - signup_notifications_stream, - signup_notifications_stream_id, + signup_announcements_stream, + signup_announcements_stream_id, acting_user=None, ) ) - check_realm_update("events[0]", events[0], "signup_notifications_stream_id") + check_realm_update("events[0]", events[0], "signup_announcements_stream_id") def test_change_is_admin(self) -> None: reset_email_visibility_to_everyone_in_zulip_realm() diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index df63a169ff..4bf32ac27e 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -188,7 +188,7 @@ class HomeTest(ZulipTestCase): "realm_push_notifications_enabled", "realm_push_notifications_enabled_end_timestamp", "realm_send_welcome_emails", - "realm_signup_notifications_stream_id", + "realm_signup_announcements_stream_id", "realm_upload_quota_mib", "realm_uri", "realm_user_group_edit_policy", @@ -661,15 +661,15 @@ class HomeTest(ZulipTestCase): change_user_is_active(user, False) return user - def test_signup_notifications_stream(self) -> None: + def test_signup_announcements_stream(self) -> None: realm = get_realm("zulip") - realm.signup_notifications_stream = get_stream("Denmark", realm) + realm.signup_announcements_stream = get_stream("Denmark", realm) realm.save() self.login("hamlet") result = self._get_home_page() page_params = self._get_page_params(result) self.assertEqual( - page_params["state_data"]["realm_signup_notifications_stream_id"], + page_params["state_data"]["realm_signup_announcements_stream_id"], get_stream("Denmark", realm).id, ) diff --git a/zerver/tests/test_new_users.py b/zerver/tests/test_new_users.py index 4d371eaa83..d1f031233f 100644 --- a/zerver/tests/test_new_users.py +++ b/zerver/tests/test_new_users.py @@ -290,8 +290,8 @@ class TestNotifyNewUser(ZulipTestCase): message.content, ) - realm.signup_notifications_stream = None - realm.save(update_fields=["signup_notifications_stream"]) + realm.signup_announcements_stream = None + realm.save(update_fields=["signup_announcements_stream"]) new_user.refresh_from_db() notify_new_user(new_user) self.assertEqual(self.get_message_count(), message_count + 1) @@ -321,7 +321,7 @@ class TestNotifyNewUser(ZulipTestCase): message = self.get_last_message() actual_stream = Stream.objects.get(id=message.recipient.type_id) - self.assertEqual(actual_stream, realm.signup_notifications_stream) + self.assertEqual(actual_stream, realm.signup_announcements_stream) self.assertIn( f"@_**new user {user_no}|{new_user.id}** joined this organization.", message.content, diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index 64092b8373..39364eab8a 100644 --- a/zerver/tests/test_realm.py +++ b/zerver/tests/test_realm.py @@ -555,69 +555,69 @@ class RealmTest(ZulipTestCase): self.assertEqual(stats, (2, 1, 10)) self.assertIsNone(realm.get_new_stream_announcements_stream()) - def test_change_signup_notifications_stream(self) -> None: + def test_change_signup_announcements_stream(self) -> None: # We need an admin user. self.login("iago") - disabled_signup_notifications_stream_id = -1 + disabled_signup_announcements_stream_id = -1 req = dict( - signup_notifications_stream_id=orjson.dumps( - disabled_signup_notifications_stream_id + signup_announcements_stream_id=orjson.dumps( + disabled_signup_announcements_stream_id ).decode() ) result = self.client_patch("/json/realm", req) self.assert_json_success(result) realm = get_realm("zulip") - self.assertEqual(realm.signup_notifications_stream, None) + self.assertEqual(realm.signup_announcements_stream, None) - new_signup_notifications_stream_id = Stream.objects.get(name="Denmark").id + new_signup_announcements_stream_id = Stream.objects.get(name="Denmark").id req = dict( - signup_notifications_stream_id=orjson.dumps(new_signup_notifications_stream_id).decode() + signup_announcements_stream_id=orjson.dumps(new_signup_announcements_stream_id).decode() ) result = self.client_patch("/json/realm", req) self.assert_json_success(result) realm = get_realm("zulip") - assert realm.signup_notifications_stream is not None - self.assertEqual(realm.signup_notifications_stream.id, new_signup_notifications_stream_id) + assert realm.signup_announcements_stream is not None + self.assertEqual(realm.signup_announcements_stream.id, new_signup_announcements_stream_id) # Test that admin can set the setting to an unsubscribed private stream as well. - new_signup_notifications_stream_id = self.make_stream("private_stream", invite_only=True).id + new_signup_announcements_stream_id = self.make_stream("private_stream", invite_only=True).id req = dict( - signup_notifications_stream_id=orjson.dumps(new_signup_notifications_stream_id).decode() + signup_announcements_stream_id=orjson.dumps(new_signup_announcements_stream_id).decode() ) result = self.client_patch("/json/realm", req) self.assert_json_success(result) realm = get_realm("zulip") - assert realm.signup_notifications_stream is not None - self.assertEqual(realm.signup_notifications_stream.id, new_signup_notifications_stream_id) + assert realm.signup_announcements_stream is not None + self.assertEqual(realm.signup_announcements_stream.id, new_signup_announcements_stream_id) - invalid_signup_notifications_stream_id = 1234 + invalid_signup_announcements_stream_id = 1234 req = dict( - signup_notifications_stream_id=orjson.dumps( - invalid_signup_notifications_stream_id + signup_announcements_stream_id=orjson.dumps( + invalid_signup_announcements_stream_id ).decode() ) result = self.client_patch("/json/realm", req) self.assert_json_error(result, "Invalid stream ID") realm = get_realm("zulip") - assert realm.signup_notifications_stream is not None + assert realm.signup_announcements_stream is not None self.assertNotEqual( - realm.signup_notifications_stream.id, invalid_signup_notifications_stream_id + realm.signup_announcements_stream.id, invalid_signup_announcements_stream_id ) - def test_get_default_signup_notifications_stream(self) -> None: + def test_get_default_signup_announcements_stream(self) -> None: realm = get_realm("zulip") verona = get_stream("verona", realm) - realm.signup_notifications_stream = verona - realm.save(update_fields=["signup_notifications_stream"]) + realm.signup_announcements_stream = verona + realm.save(update_fields=["signup_announcements_stream"]) - signup_notifications_stream = realm.get_signup_notifications_stream() - assert signup_notifications_stream is not None - self.assertEqual(signup_notifications_stream, verona) - do_deactivate_stream(signup_notifications_stream, acting_user=None) - self.assertIsNone(realm.get_signup_notifications_stream()) + signup_announcements_stream = realm.get_signup_announcements_stream() + assert signup_announcements_stream is not None + self.assertEqual(signup_announcements_stream, verona) + do_deactivate_stream(signup_announcements_stream, acting_user=None) + self.assertIsNone(realm.get_signup_announcements_stream()) def test_change_realm_default_language(self) -> None: # we need an admin user. @@ -973,9 +973,9 @@ class RealmTest(ZulipTestCase): self.assertEqual(realm.new_stream_announcements_stream.name, "general") self.assertEqual(realm.new_stream_announcements_stream.realm, realm) - assert realm.signup_notifications_stream is not None - self.assertEqual(realm.signup_notifications_stream.name, "core team") - self.assertEqual(realm.signup_notifications_stream.realm, realm) + assert realm.signup_announcements_stream is not None + self.assertEqual(realm.signup_announcements_stream.name, "core team") + self.assertEqual(realm.signup_announcements_stream.realm, realm) self.assertEqual(realm.plan_type, Realm.PLAN_TYPE_LIMITED) @@ -1020,9 +1020,9 @@ class RealmTest(ZulipTestCase): self.assertEqual(realm.new_stream_announcements_stream.name, "general") self.assertEqual(realm.new_stream_announcements_stream.realm, realm) - assert realm.signup_notifications_stream is not None - self.assertEqual(realm.signup_notifications_stream.name, "core team") - self.assertEqual(realm.signup_notifications_stream.realm, realm) + assert realm.signup_announcements_stream is not None + self.assertEqual(realm.signup_announcements_stream.name, "core team") + self.assertEqual(realm.signup_announcements_stream.realm, realm) def test_realm_is_web_public(self) -> None: realm = get_realm("zulip") diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 868226e14a..d87f40a01e 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -2850,8 +2850,8 @@ class UserSignUpTest(ZulipTestCase): def test_signup_to_realm_on_manual_license_plan(self) -> None: realm = get_realm("zulip") denmark_stream = get_stream("Denmark", realm) - realm.signup_notifications_stream = denmark_stream - realm.save(update_fields=["signup_notifications_stream"]) + realm.signup_announcements_stream = denmark_stream + realm.save(update_fields=["signup_announcements_stream"]) _, ledger = self.subscribe_realm_to_monthly_plan_on_manual_license_management(realm, 5, 5) diff --git a/zerver/views/realm.py b/zerver/views/realm.py index 37d3cb2f77..ce5070dde2 100644 --- a/zerver/views/realm.py +++ b/zerver/views/realm.py @@ -16,7 +16,7 @@ from zerver.actions.realm_settings import ( do_set_realm_authentication_methods, do_set_realm_new_stream_announcements_stream, do_set_realm_property, - do_set_realm_signup_notifications_stream, + do_set_realm_signup_announcements_stream, do_set_realm_user_default_setting, parse_and_set_setting_value_if_required, validate_authentication_methods_dict_from_api, @@ -111,7 +111,7 @@ def update_realm( # Note: push_notifications_enabled and push_notifications_enabled_end_timestamp # are not offered here as it is maintained by the server, not via the API. new_stream_announcements_stream_id: Optional[int] = REQ(json_validator=check_int, default=None), - signup_notifications_stream_id: Optional[int] = REQ(json_validator=check_int, default=None), + signup_announcements_stream_id: Optional[int] = REQ(json_validator=check_int, default=None), message_retention_days_raw: Optional[Union[int, str]] = REQ( "message_retention_days", json_validator=check_string_or_int, default=None ), @@ -389,7 +389,7 @@ def update_realm( do_set_realm_authentication_methods(realm, authentication_methods, acting_user=user_profile) data["authentication_methods"] = authentication_methods - # Realm.new_stream_announcements_stream and Realm.signup_notifications_stream are not boolean, + # Realm.new_stream_announcements_stream and Realm.signup_announcements_stream are not boolean, # str or integer field, and thus doesn't fit into the do_set_realm_property framework. if new_stream_announcements_stream_id is not None and ( realm.new_stream_announcements_stream is None @@ -408,22 +408,22 @@ def update_realm( ) data["new_stream_announcements_stream_id"] = new_stream_announcements_stream_id - if signup_notifications_stream_id is not None and ( - realm.signup_notifications_stream is None - or realm.signup_notifications_stream.id != signup_notifications_stream_id + if signup_announcements_stream_id is not None and ( + realm.signup_announcements_stream is None + or realm.signup_announcements_stream.id != signup_announcements_stream_id ): - new_signup_notifications_stream = None - if signup_notifications_stream_id >= 0: - (new_signup_notifications_stream, sub) = access_stream_by_id( - user_profile, signup_notifications_stream_id, allow_realm_admin=True + new_signup_announcements_stream = None + if signup_announcements_stream_id >= 0: + (new_signup_announcements_stream, sub) = access_stream_by_id( + user_profile, signup_announcements_stream_id, allow_realm_admin=True ) - do_set_realm_signup_notifications_stream( + do_set_realm_signup_announcements_stream( realm, - new_signup_notifications_stream, - signup_notifications_stream_id, + new_signup_announcements_stream, + signup_announcements_stream_id, acting_user=user_profile, ) - data["signup_notifications_stream_id"] = signup_notifications_stream_id + data["signup_announcements_stream_id"] = signup_announcements_stream_id if string_id is not None: if not user_profile.is_realm_owner: