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.
This commit is contained in:
Prakhar Pratyush 2024-02-07 21:41:43 +05:30 committed by Tim Abbott
parent ab453fbe20
commit ee612dafac
29 changed files with 159 additions and 134 deletions

View File

@ -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**

View File

@ -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<void> {
async function test_change_signup_announcements_stream(page: Page): Promise<void> {
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<void> {
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:

View File

@ -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,

View File

@ -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();

View File

@ -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":

View File

@ -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",

View File

@ -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,
});

View File

@ -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",

View File

@ -10,7 +10,7 @@
{{#if is_new_stream_announcements_stream}}
<li>{{#tr}}New stream notifications{{/tr}}</li>
{{/if}}
{{#if is_signup_notification_stream}}
{{#if is_signup_announcements_stream}}
<li>{{#tr}}New user notifications{{/tr}}</li>
{{/if}}
</ul>

View File

@ -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"}}

View File

@ -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);

View File

@ -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}) => {

View File

@ -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,
},

View File

@ -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.

View File

@ -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

View File

@ -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
)

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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",
),
]

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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()

View File

@ -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,
)

View File

@ -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,

View File

@ -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")

View File

@ -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)

View File

@ -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: