mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	message_edit: Add "Nobody" option for move_messages_between_streams_policy.
This commit is contained in:
		@@ -251,11 +251,18 @@ test_message_policy(
 | 
				
			|||||||
run_test("user_can_edit_topic_of_any_message_nobody_case", () => {
 | 
					run_test("user_can_edit_topic_of_any_message_nobody_case", () => {
 | 
				
			||||||
    page_params.is_admin = true;
 | 
					    page_params.is_admin = true;
 | 
				
			||||||
    page_params.is_guest = false;
 | 
					    page_params.is_guest = false;
 | 
				
			||||||
    page_params.realm_edit_topic_policy =
 | 
					    page_params.realm_edit_topic_policy = settings_config.edit_topic_policy_values.nobody.code;
 | 
				
			||||||
        settings_config.edit_topic_policy_values.nobody.code;
 | 
					 | 
				
			||||||
    assert.equal(settings_data.user_can_edit_topic_of_any_message(), false);
 | 
					    assert.equal(settings_data.user_can_edit_topic_of_any_message(), false);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					run_test("user_can_move_messages_between_streams_nobody_case", () => {
 | 
				
			||||||
 | 
					    page_params.is_admin = true;
 | 
				
			||||||
 | 
					    page_params.is_guest = false;
 | 
				
			||||||
 | 
					    page_params.realm_move_messages_between_streams_policy =
 | 
				
			||||||
 | 
					        settings_config.move_messages_between_streams_policy_values.nobody.code;
 | 
				
			||||||
 | 
					    assert.equal(settings_data.user_can_move_messages_between_streams(), false);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test_message_policy(
 | 
					test_message_policy(
 | 
				
			||||||
    "user_can_delete_own_message",
 | 
					    "user_can_delete_own_message",
 | 
				
			||||||
    "realm_delete_own_message_policy",
 | 
					    "realm_delete_own_message_policy",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -299,6 +299,8 @@ export const edit_topic_policy_values = {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const move_messages_between_streams_policy_values = invite_to_realm_policy_values;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const time_limit_dropdown_values = [
 | 
					export const time_limit_dropdown_values = [
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        text: $t({defaultMessage: "Any time"}),
 | 
					        text: $t({defaultMessage: "Any time"}),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -117,6 +117,9 @@ export function get_organization_settings_options() {
 | 
				
			|||||||
    options.edit_topic_policy_values = get_sorted_options_list(
 | 
					    options.edit_topic_policy_values = get_sorted_options_list(
 | 
				
			||||||
        settings_config.edit_topic_policy_values,
 | 
					        settings_config.edit_topic_policy_values,
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					    options.move_messages_between_streams_policy_values = get_sorted_options_list(
 | 
				
			||||||
 | 
					        settings_config.move_messages_between_streams_policy_values,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    return options;
 | 
					    return options;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -191,7 +191,7 @@
 | 
				
			|||||||
                    <label for="realm_move_messages_between_streams_policy">{{t "Who can move messages between streams" }}
 | 
					                    <label for="realm_move_messages_between_streams_policy">{{t "Who can move messages between streams" }}
 | 
				
			||||||
                    </label>
 | 
					                    </label>
 | 
				
			||||||
                    <select name="realm_move_messages_between_streams_policy" class="setting-widget prop-element" id="id_realm_move_messages_between_streams_policy" data-setting-widget-type="number">
 | 
					                    <select name="realm_move_messages_between_streams_policy" class="setting-widget prop-element" id="id_realm_move_messages_between_streams_policy" data-setting-widget-type="number">
 | 
				
			||||||
                        {{> dropdown_options_widget option_values=common_policy_values}}
 | 
					                        {{> dropdown_options_widget option_values=move_messages_between_streams_policy_values}}
 | 
				
			||||||
                    </select>
 | 
					                    </select>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,9 @@ format used by the Zulip server that they are interacting with.
 | 
				
			|||||||
* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
 | 
					* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
 | 
				
			||||||
  `PATCH /realm`: Nobody added as an option for the realm setting
 | 
					  `PATCH /realm`: Nobody added as an option for the realm setting
 | 
				
			||||||
  `edit_topic_policy`.
 | 
					  `edit_topic_policy`.
 | 
				
			||||||
 | 
					* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
 | 
				
			||||||
 | 
					  `PATCH /realm`: Nobody added as an option for the realm setting
 | 
				
			||||||
 | 
					  `move_messages_between_streams_policy`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Feature levels 157-158 are reserved for future use in 6.x maintenance
 | 
					Feature levels 157-158 are reserved for future use in 6.x maintenance
 | 
				
			||||||
releases.
 | 
					releases.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -374,6 +374,8 @@ class Realm(models.Model):  # type: ignore[django-manager-missing] # django-stub
 | 
				
			|||||||
        POLICY_NOBODY,
 | 
					        POLICY_NOBODY,
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MOVE_MESSAGES_BETWEEN_STREAMS_POLICY_TYPES = INVITE_TO_REALM_POLICY_TYPES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DEFAULT_COMMUNITY_TOPIC_EDITING_LIMIT_SECONDS = 259200
 | 
					    DEFAULT_COMMUNITY_TOPIC_EDITING_LIMIT_SECONDS = 259200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Who in the organization is allowed to add custom emojis.
 | 
					    # Who in the organization is allowed to add custom emojis.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4042,8 +4042,10 @@ paths:
 | 
				
			|||||||
                                        - 2 = Administrators only
 | 
					                                        - 2 = Administrators only
 | 
				
			||||||
                                        - 3 = [Full members][calc-full-member] only
 | 
					                                        - 3 = [Full members][calc-full-member] only
 | 
				
			||||||
                                        - 4 = Moderators only
 | 
					                                        - 4 = Moderators only
 | 
				
			||||||
 | 
					                                        - 6 = Nobody
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        **Changes**: New in Zulip 4.0 (feature level 56)
 | 
					                                        **Changes**: New in Zulip 4.0 (feature level 56). Nobody added
 | 
				
			||||||
 | 
					                                        as an option in Zulip 7.0 (feature level 159).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        [permission-level]: /api/roles-and-permissions#permission-levels
 | 
					                                        [permission-level]: /api/roles-and-permissions#permission-levels
 | 
				
			||||||
                                        [calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
 | 
					                                        [calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
 | 
				
			||||||
@@ -11914,8 +11916,10 @@ paths:
 | 
				
			|||||||
                          - 2 = Administrators only
 | 
					                          - 2 = Administrators only
 | 
				
			||||||
                          - 3 = [Full members][calc-full-member] only
 | 
					                          - 3 = [Full members][calc-full-member] only
 | 
				
			||||||
                          - 4 = Moderators only
 | 
					                          - 4 = Moderators only
 | 
				
			||||||
 | 
					                          - 6 = Nobody
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                          **Changes**: New in Zulip 4.0 (feature level 56)
 | 
					                          **Changes**: New in Zulip 4.0 (feature level 56). Nobody added
 | 
				
			||||||
 | 
					                          as an option in Zulip 7.0 (feature level 159).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                          [permission-level]: /api/roles-and-permissions#permission-levels
 | 
					                          [permission-level]: /api/roles-and-permissions#permission-levels
 | 
				
			||||||
                          [calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
 | 
					                          [calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2572,7 +2572,7 @@ class RealmPropertyActionTest(BaseAction):
 | 
				
			|||||||
            default_code_block_language=["python", "javascript"],
 | 
					            default_code_block_language=["python", "javascript"],
 | 
				
			||||||
            message_content_delete_limit_seconds=[1000, 1100, 1200],
 | 
					            message_content_delete_limit_seconds=[1000, 1100, 1200],
 | 
				
			||||||
            invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
 | 
					            invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
 | 
				
			||||||
            move_messages_between_streams_policy=Realm.COMMON_POLICY_TYPES,
 | 
					            move_messages_between_streams_policy=Realm.MOVE_MESSAGES_BETWEEN_STREAMS_POLICY_TYPES,
 | 
				
			||||||
            add_custom_emoji_policy=Realm.COMMON_POLICY_TYPES,
 | 
					            add_custom_emoji_policy=Realm.COMMON_POLICY_TYPES,
 | 
				
			||||||
            delete_own_message_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
 | 
					            delete_own_message_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
 | 
				
			||||||
            edit_topic_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
 | 
					            edit_topic_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2056,6 +2056,18 @@ class EditMessageTest(EditMessageTestCase):
 | 
				
			|||||||
                messages = get_topic_messages(user_profile, new_stream, "test")
 | 
					                messages = get_topic_messages(user_profile, new_stream, "test")
 | 
				
			||||||
                self.assert_length(messages, 4)
 | 
					                self.assert_length(messages, 4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Check sending messages when policy is Realm.POLICY_NOBODY.
 | 
				
			||||||
 | 
					        do_set_realm_property(
 | 
				
			||||||
 | 
					            user_profile.realm,
 | 
				
			||||||
 | 
					            "move_messages_between_streams_policy",
 | 
				
			||||||
 | 
					            Realm.POLICY_NOBODY,
 | 
				
			||||||
 | 
					            acting_user=None,
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        check_move_message_according_to_policy(UserProfile.ROLE_REALM_OWNER, expect_fail=True)
 | 
				
			||||||
 | 
					        check_move_message_according_to_policy(
 | 
				
			||||||
 | 
					            UserProfile.ROLE_REALM_ADMINISTRATOR, expect_fail=True
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Check sending messages when policy is Realm.POLICY_ADMINS_ONLY.
 | 
					        # Check sending messages when policy is Realm.POLICY_ADMINS_ONLY.
 | 
				
			||||||
        do_set_realm_property(
 | 
					        do_set_realm_property(
 | 
				
			||||||
            user_profile.realm,
 | 
					            user_profile.realm,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1173,7 +1173,7 @@ class RealmAPITest(ZulipTestCase):
 | 
				
			|||||||
            ],
 | 
					            ],
 | 
				
			||||||
            message_content_delete_limit_seconds=[1000, 1100, 1200],
 | 
					            message_content_delete_limit_seconds=[1000, 1100, 1200],
 | 
				
			||||||
            invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
 | 
					            invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
 | 
				
			||||||
            move_messages_between_streams_policy=Realm.COMMON_POLICY_TYPES,
 | 
					            move_messages_between_streams_policy=Realm.MOVE_MESSAGES_BETWEEN_STREAMS_POLICY_TYPES,
 | 
				
			||||||
            add_custom_emoji_policy=Realm.COMMON_POLICY_TYPES,
 | 
					            add_custom_emoji_policy=Realm.COMMON_POLICY_TYPES,
 | 
				
			||||||
            delete_own_message_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
 | 
					            delete_own_message_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
 | 
				
			||||||
            edit_topic_policy=Realm.EDIT_TOPIC_POLICY_TYPES,
 | 
					            edit_topic_policy=Realm.EDIT_TOPIC_POLICY_TYPES,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -116,7 +116,7 @@ def update_realm(
 | 
				
			|||||||
        json_validator=check_int_in(Realm.COMMON_POLICY_TYPES), default=None
 | 
					        json_validator=check_int_in(Realm.COMMON_POLICY_TYPES), default=None
 | 
				
			||||||
    ),
 | 
					    ),
 | 
				
			||||||
    move_messages_between_streams_policy: Optional[int] = REQ(
 | 
					    move_messages_between_streams_policy: Optional[int] = REQ(
 | 
				
			||||||
        json_validator=check_int_in(Realm.COMMON_POLICY_TYPES), default=None
 | 
					        json_validator=check_int_in(Realm.MOVE_MESSAGES_BETWEEN_STREAMS_POLICY_TYPES), default=None
 | 
				
			||||||
    ),
 | 
					    ),
 | 
				
			||||||
    user_group_edit_policy: Optional[int] = REQ(
 | 
					    user_group_edit_policy: Optional[int] = REQ(
 | 
				
			||||||
        json_validator=check_int_in(Realm.COMMON_POLICY_TYPES), default=None
 | 
					        json_validator=check_int_in(Realm.COMMON_POLICY_TYPES), default=None
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user