mirror of https://github.com/zulip/zulip.git
refactor: Rename do_set_user_display_setting to do_set_user_setting.
This commit is contained in:
parent
430c5cb8e7
commit
9443e01a5d
|
@ -5082,7 +5082,7 @@ def do_change_notification_settings(
|
||||||
send_event(user_profile.realm, legacy_event, [user_profile.id])
|
send_event(user_profile.realm, legacy_event, [user_profile.id])
|
||||||
|
|
||||||
|
|
||||||
def do_set_user_display_setting(
|
def do_change_user_setting(
|
||||||
user_profile: UserProfile, setting_name: str, setting_value: Union[bool, str, int]
|
user_profile: UserProfile, setting_name: str, setting_value: Union[bool, str, int]
|
||||||
) -> None:
|
) -> None:
|
||||||
if setting_name == "timezone":
|
if setting_name == "timezone":
|
||||||
|
|
|
@ -2,7 +2,7 @@ from typing import Any, Dict
|
||||||
|
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from zerver.lib.actions import do_set_user_display_setting
|
from zerver.lib.actions import do_change_user_setting
|
||||||
from zerver.lib.exceptions import JsonableError
|
from zerver.lib.exceptions import JsonableError
|
||||||
from zerver.models import UserProfile
|
from zerver.models import UserProfile
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
|
||||||
switch_command=switch_command,
|
switch_command=switch_command,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
do_set_user_display_setting(
|
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
|
||||||
)
|
)
|
||||||
return msg
|
return msg
|
||||||
|
|
|
@ -49,6 +49,7 @@ from zerver.lib.actions import (
|
||||||
do_change_subscription_property,
|
do_change_subscription_property,
|
||||||
do_change_user_delivery_email,
|
do_change_user_delivery_email,
|
||||||
do_change_user_role,
|
do_change_user_role,
|
||||||
|
do_change_user_setting,
|
||||||
do_create_default_stream_group,
|
do_create_default_stream_group,
|
||||||
do_create_multiuse_invite_link,
|
do_create_multiuse_invite_link,
|
||||||
do_create_user,
|
do_create_user,
|
||||||
|
@ -82,7 +83,6 @@ from zerver.lib.actions import (
|
||||||
do_set_realm_notifications_stream,
|
do_set_realm_notifications_stream,
|
||||||
do_set_realm_property,
|
do_set_realm_property,
|
||||||
do_set_realm_signup_notifications_stream,
|
do_set_realm_signup_notifications_stream,
|
||||||
do_set_user_display_setting,
|
|
||||||
do_set_zoom_token,
|
do_set_zoom_token,
|
||||||
do_unmute_topic,
|
do_unmute_topic,
|
||||||
do_unmute_user,
|
do_unmute_user,
|
||||||
|
@ -2061,7 +2061,7 @@ class NormalActionsTest(BaseAction):
|
||||||
|
|
||||||
def test_display_setting_event_not_sent(self) -> None:
|
def test_display_setting_event_not_sent(self) -> None:
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
lambda: do_set_user_display_setting(
|
lambda: do_change_user_setting(
|
||||||
self.user_profile,
|
self.user_profile,
|
||||||
"default_view",
|
"default_view",
|
||||||
"all_messages",
|
"all_messages",
|
||||||
|
@ -2169,7 +2169,7 @@ class RealmPropertyActionTest(BaseAction):
|
||||||
|
|
||||||
|
|
||||||
class UserDisplayActionTest(BaseAction):
|
class UserDisplayActionTest(BaseAction):
|
||||||
def do_set_user_display_settings_test(self, setting_name: str) -> None:
|
def do_change_user_settings_test(self, setting_name: str) -> None:
|
||||||
"""Test updating each setting in UserProfile.property_types dict."""
|
"""Test updating each setting in UserProfile.property_types dict."""
|
||||||
|
|
||||||
test_changes: Dict[str, Any] = dict(
|
test_changes: Dict[str, Any] = dict(
|
||||||
|
@ -2195,19 +2195,19 @@ class UserDisplayActionTest(BaseAction):
|
||||||
|
|
||||||
for value in values:
|
for value in values:
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
lambda: do_set_user_display_setting(self.user_profile, setting_name, value),
|
lambda: do_change_user_setting(self.user_profile, setting_name, value),
|
||||||
num_events=num_events,
|
num_events=num_events,
|
||||||
)
|
)
|
||||||
|
|
||||||
check_user_settings_update("events[0]", events[0])
|
check_user_settings_update("events[0]", events[0])
|
||||||
check_update_display_settings("events[1]", events[1])
|
check_update_display_settings("events[1]", events[1])
|
||||||
|
|
||||||
def test_set_user_display_settings(self) -> None:
|
def test_change_user_settings(self) -> None:
|
||||||
for prop in UserProfile.property_types:
|
for prop in UserProfile.property_types:
|
||||||
# Notification settings have a separate test suite, which
|
# Notification settings have a separate test suite, which
|
||||||
# handles their separate legacy event type.
|
# handles their separate legacy event type.
|
||||||
if prop not in UserProfile.notification_settings_legacy:
|
if prop not in UserProfile.notification_settings_legacy:
|
||||||
self.do_set_user_display_settings_test(prop)
|
self.do_change_user_settings_test(prop)
|
||||||
|
|
||||||
def test_set_user_timezone(self) -> None:
|
def test_set_user_timezone(self) -> None:
|
||||||
values = ["America/Denver", "Pacific/Pago_Pago", "Pacific/Galapagos", ""]
|
values = ["America/Denver", "Pacific/Pago_Pago", "Pacific/Galapagos", ""]
|
||||||
|
@ -2215,7 +2215,7 @@ class UserDisplayActionTest(BaseAction):
|
||||||
|
|
||||||
for value in values:
|
for value in values:
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
lambda: do_set_user_display_setting(self.user_profile, "timezone", value),
|
lambda: do_change_user_setting(self.user_profile, "timezone", value),
|
||||||
num_events=num_events,
|
num_events=num_events,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2347,7 +2347,7 @@ class SubscribeActionTest(BaseAction):
|
||||||
|
|
||||||
class DraftActionTest(BaseAction):
|
class DraftActionTest(BaseAction):
|
||||||
def do_enable_drafts_synchronization(self, user_profile: UserProfile) -> None:
|
def do_enable_drafts_synchronization(self, user_profile: UserProfile) -> None:
|
||||||
do_set_user_display_setting(user_profile, "enable_drafts_synchronization", True)
|
do_change_user_setting(user_profile, "enable_drafts_synchronization", True)
|
||||||
|
|
||||||
def test_draft_create_event(self) -> None:
|
def test_draft_create_event(self) -> None:
|
||||||
self.do_enable_drafts_synchronization(self.user_profile)
|
self.do_enable_drafts_synchronization(self.user_profile)
|
||||||
|
|
|
@ -13,10 +13,10 @@ from markdown import Markdown
|
||||||
from zerver.lib.actions import (
|
from zerver.lib.actions import (
|
||||||
change_user_is_active,
|
change_user_is_active,
|
||||||
do_add_alert_words,
|
do_add_alert_words,
|
||||||
|
do_change_user_setting,
|
||||||
do_create_realm,
|
do_create_realm,
|
||||||
do_remove_realm_emoji,
|
do_remove_realm_emoji,
|
||||||
do_set_realm_property,
|
do_set_realm_property,
|
||||||
do_set_user_display_setting,
|
|
||||||
)
|
)
|
||||||
from zerver.lib.alert_words import get_alert_word_automaton
|
from zerver.lib.alert_words import get_alert_word_automaton
|
||||||
from zerver.lib.camo import get_camo_url
|
from zerver.lib.camo import get_camo_url
|
||||||
|
@ -436,7 +436,7 @@ class MarkdownTest(ZulipTestCase):
|
||||||
if test.get("translate_emoticons", False):
|
if test.get("translate_emoticons", False):
|
||||||
# Create a userprofile and send message with it.
|
# Create a userprofile and send message with it.
|
||||||
user_profile = self.example_user("othello")
|
user_profile = self.example_user("othello")
|
||||||
do_set_user_display_setting(user_profile, "translate_emoticons", True)
|
do_change_user_setting(user_profile, "translate_emoticons", True)
|
||||||
msg = Message(sender=user_profile, sending_client=get_client("test"))
|
msg = Message(sender=user_profile, sending_client=get_client("test"))
|
||||||
rendering_result = render_markdown(msg, test["input"])
|
rendering_result = render_markdown(msg, test["input"])
|
||||||
converted = rendering_result.rendered_content
|
converted = rendering_result.rendered_content
|
||||||
|
@ -1219,7 +1219,7 @@ class MarkdownTest(ZulipTestCase):
|
||||||
|
|
||||||
def test_no_translate_emoticons_if_off(self) -> None:
|
def test_no_translate_emoticons_if_off(self) -> None:
|
||||||
user_profile = self.example_user("othello")
|
user_profile = self.example_user("othello")
|
||||||
do_set_user_display_setting(user_profile, "translate_emoticons", False)
|
do_change_user_setting(user_profile, "translate_emoticons", False)
|
||||||
msg = Message(sender=user_profile, sending_client=get_client("test"))
|
msg = Message(sender=user_profile, sending_client=get_client("test"))
|
||||||
|
|
||||||
content = ":)"
|
content = ":)"
|
||||||
|
|
|
@ -38,9 +38,9 @@ from zerver.lib.actions import (
|
||||||
do_activate_mirror_dummy_user,
|
do_activate_mirror_dummy_user,
|
||||||
do_change_full_name,
|
do_change_full_name,
|
||||||
do_change_password,
|
do_change_password,
|
||||||
|
do_change_user_setting,
|
||||||
do_create_realm,
|
do_create_realm,
|
||||||
do_create_user,
|
do_create_user,
|
||||||
do_set_user_display_setting,
|
|
||||||
lookup_default_stream_groups,
|
lookup_default_stream_groups,
|
||||||
)
|
)
|
||||||
from zerver.lib.email_validation import email_allowed_for_realm, validate_email_not_already_in_realm
|
from zerver.lib.email_validation import email_allowed_for_realm, validate_email_not_already_in_realm
|
||||||
|
@ -420,7 +420,7 @@ def accounts_register(
|
||||||
do_activate_mirror_dummy_user(user_profile, acting_user=user_profile)
|
do_activate_mirror_dummy_user(user_profile, acting_user=user_profile)
|
||||||
do_change_password(user_profile, password)
|
do_change_password(user_profile, password)
|
||||||
do_change_full_name(user_profile, full_name, user_profile)
|
do_change_full_name(user_profile, full_name, user_profile)
|
||||||
do_set_user_display_setting(user_profile, "timezone", timezone)
|
do_change_user_setting(user_profile, "timezone", timezone)
|
||||||
# TODO: When we clean up the `do_activate_mirror_dummy_user` code path,
|
# TODO: When we clean up the `do_activate_mirror_dummy_user` code path,
|
||||||
# make it respect invited_as_admin / is_realm_admin.
|
# make it respect invited_as_admin / is_realm_admin.
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ from zerver.lib.actions import (
|
||||||
do_change_notification_settings,
|
do_change_notification_settings,
|
||||||
do_change_password,
|
do_change_password,
|
||||||
do_change_user_delivery_email,
|
do_change_user_delivery_email,
|
||||||
|
do_change_user_setting,
|
||||||
do_regenerate_api_key,
|
do_regenerate_api_key,
|
||||||
do_set_user_display_setting,
|
|
||||||
do_start_email_change_process,
|
do_start_email_change_process,
|
||||||
get_available_notification_sounds,
|
get_available_notification_sounds,
|
||||||
)
|
)
|
||||||
|
@ -266,7 +266,7 @@ def json_change_settings(
|
||||||
}
|
}
|
||||||
for k, v in list(request_settings.items()):
|
for k, v in list(request_settings.items()):
|
||||||
if v is not None and getattr(user_profile, k) != v:
|
if v is not None and getattr(user_profile, k) != v:
|
||||||
do_set_user_display_setting(user_profile, k, v)
|
do_change_user_setting(user_profile, k, v)
|
||||||
|
|
||||||
req_vars = {
|
req_vars = {
|
||||||
k: v for k, v in list(locals().items()) if k in user_profile.notification_setting_types
|
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)
|
do_change_notification_settings(user_profile, k, v, acting_user=user_profile)
|
||||||
|
|
||||||
if timezone is not None and user_profile.timezone != timezone:
|
if timezone is not None and user_profile.timezone != timezone:
|
||||||
do_set_user_display_setting(user_profile, "timezone", timezone)
|
do_change_user_setting(user_profile, "timezone", timezone)
|
||||||
|
|
||||||
# TODO: Do this more generally.
|
# TODO: Do this more generally.
|
||||||
from zerver.lib.request import RequestNotes
|
from zerver.lib.request import RequestNotes
|
||||||
|
|
Loading…
Reference in New Issue