mirror of https://github.com/zulip/zulip.git
settings: Refactor callers of do_change_user_setting to pass acting_user.
This commit is contained in:
parent
f0ea002d94
commit
550d97a593
|
@ -19,7 +19,10 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
|
|||
)
|
||||
)
|
||||
do_change_user_setting(
|
||||
user_profile=user_profile, setting_name=setting, setting_value=setting_value
|
||||
user_profile=user_profile,
|
||||
setting_name=setting,
|
||||
setting_value=setting_value,
|
||||
acting_user=user_profile,
|
||||
)
|
||||
return msg
|
||||
|
||||
|
|
|
@ -2065,6 +2065,7 @@ class NormalActionsTest(BaseAction):
|
|||
self.user_profile,
|
||||
"default_view",
|
||||
"all_messages",
|
||||
acting_user=self.user_profile,
|
||||
),
|
||||
state_change_expected=True,
|
||||
user_settings_object=True,
|
||||
|
@ -2195,7 +2196,9 @@ class UserDisplayActionTest(BaseAction):
|
|||
|
||||
for value in values:
|
||||
events = self.verify_action(
|
||||
lambda: do_change_user_setting(self.user_profile, setting_name, value),
|
||||
lambda: do_change_user_setting(
|
||||
self.user_profile, setting_name, value, acting_user=self.user_profile
|
||||
),
|
||||
num_events=num_events,
|
||||
)
|
||||
|
||||
|
@ -2215,7 +2218,9 @@ class UserDisplayActionTest(BaseAction):
|
|||
|
||||
for value in values:
|
||||
events = self.verify_action(
|
||||
lambda: do_change_user_setting(self.user_profile, "timezone", value),
|
||||
lambda: do_change_user_setting(
|
||||
self.user_profile, "timezone", value, acting_user=self.user_profile
|
||||
),
|
||||
num_events=num_events,
|
||||
)
|
||||
|
||||
|
@ -2347,7 +2352,9 @@ class SubscribeActionTest(BaseAction):
|
|||
|
||||
class DraftActionTest(BaseAction):
|
||||
def do_enable_drafts_synchronization(self, user_profile: UserProfile) -> None:
|
||||
do_change_user_setting(user_profile, "enable_drafts_synchronization", True)
|
||||
do_change_user_setting(
|
||||
user_profile, "enable_drafts_synchronization", True, acting_user=self.user_profile
|
||||
)
|
||||
|
||||
def test_draft_create_event(self) -> None:
|
||||
self.do_enable_drafts_synchronization(self.user_profile)
|
||||
|
|
|
@ -436,7 +436,9 @@ class MarkdownTest(ZulipTestCase):
|
|||
if test.get("translate_emoticons", False):
|
||||
# Create a userprofile and send message with it.
|
||||
user_profile = self.example_user("othello")
|
||||
do_change_user_setting(user_profile, "translate_emoticons", True)
|
||||
do_change_user_setting(
|
||||
user_profile, "translate_emoticons", True, acting_user=None
|
||||
)
|
||||
msg = Message(sender=user_profile, sending_client=get_client("test"))
|
||||
rendering_result = render_markdown(msg, test["input"])
|
||||
converted = rendering_result.rendered_content
|
||||
|
@ -1219,7 +1221,7 @@ class MarkdownTest(ZulipTestCase):
|
|||
|
||||
def test_no_translate_emoticons_if_off(self) -> None:
|
||||
user_profile = self.example_user("othello")
|
||||
do_change_user_setting(user_profile, "translate_emoticons", False)
|
||||
do_change_user_setting(user_profile, "translate_emoticons", False, acting_user=None)
|
||||
msg = Message(sender=user_profile, sending_client=get_client("test"))
|
||||
|
||||
content = ":)"
|
||||
|
|
|
@ -420,7 +420,7 @@ def accounts_register(
|
|||
do_activate_mirror_dummy_user(user_profile, acting_user=user_profile)
|
||||
do_change_password(user_profile, password)
|
||||
do_change_full_name(user_profile, full_name, user_profile)
|
||||
do_change_user_setting(user_profile, "timezone", timezone)
|
||||
do_change_user_setting(user_profile, "timezone", timezone, acting_user=user_profile)
|
||||
# TODO: When we clean up the `do_activate_mirror_dummy_user` code path,
|
||||
# make it respect invited_as_admin / is_realm_admin.
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ def json_change_settings(
|
|||
}
|
||||
for k, v in list(request_settings.items()):
|
||||
if v is not None and getattr(user_profile, k) != v:
|
||||
do_change_user_setting(user_profile, k, v)
|
||||
do_change_user_setting(user_profile, k, v, acting_user=user_profile)
|
||||
|
||||
req_vars = {
|
||||
k: v for k, v in list(locals().items()) if k in user_profile.notification_setting_types
|
||||
|
@ -277,7 +277,7 @@ def json_change_settings(
|
|||
do_change_notification_settings(user_profile, k, v, acting_user=user_profile)
|
||||
|
||||
if timezone is not None and user_profile.timezone != timezone:
|
||||
do_change_user_setting(user_profile, "timezone", timezone)
|
||||
do_change_user_setting(user_profile, "timezone", timezone, acting_user=user_profile)
|
||||
|
||||
# TODO: Do this more generally.
|
||||
from zerver.lib.request import RequestNotes
|
||||
|
|
Loading…
Reference in New Issue