From 9d1c131dc6c4eeda72fe4f6adcd3f40053dc01c8 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Bodas Date: Fri, 10 Feb 2023 19:03:24 +0530 Subject: [PATCH] muted users: Make file naming consistent. This makes the names of the relevant files consistant with the database model name as well as the frontend JS files. --- zerver/actions/message_send.py | 2 +- zerver/actions/muted_users.py | 2 +- zerver/lib/events.py | 2 +- zerver/lib/{user_mutes.py => muted_users.py} | 0 zerver/tests/test_events.py | 2 +- .../{test_muting_users.py => test_muted_users.py} | 10 +++++----- zerver/tests/test_read_receipts.py | 2 +- zerver/views/{user_mutes.py => muted_users.py} | 2 +- zproject/urls.py | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) rename zerver/lib/{user_mutes.py => muted_users.py} (100%) rename zerver/tests/{test_muting_users.py => test_muted_users.py} (97%) rename zerver/views/{user_mutes.py => muted_users.py} (96%) diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.py index eea8be8152..c2634ce903 100644 --- a/zerver/actions/message_send.py +++ b/zerver/actions/message_send.py @@ -51,6 +51,7 @@ from zerver.lib.message import ( truncate_topic, wildcard_mention_allowed, ) +from zerver.lib.muted_users import get_muting_users from zerver.lib.notification_data import UserMessageNotificationsData, get_user_group_mentions_data from zerver.lib.queue import queue_json_publish from zerver.lib.recipient_users import recipient_for_user_profiles @@ -65,7 +66,6 @@ from zerver.lib.timestamp import timestamp_to_datetime from zerver.lib.topic import filter_by_exact_message_topic from zerver.lib.url_preview.types import UrlEmbedData from zerver.lib.user_message import UserMessageLite, bulk_insert_ums -from zerver.lib.user_mutes import get_muting_users from zerver.lib.validator import check_widget_content from zerver.lib.widget import do_widget_post_save_actions from zerver.models import ( diff --git a/zerver/actions/muted_users.py b/zerver/actions/muted_users.py index e496916e3f..ed7540631c 100644 --- a/zerver/actions/muted_users.py +++ b/zerver/actions/muted_users.py @@ -5,7 +5,7 @@ import orjson from django.utils.timezone import now as timezone_now from zerver.actions.message_flags import do_mark_muted_user_messages_as_read -from zerver.lib.user_mutes import add_user_mute, get_user_mutes +from zerver.lib.muted_users import add_user_mute, get_user_mutes from zerver.models import MutedUser, RealmAuditLog, UserProfile from zerver.tornado.django_api import send_event diff --git a/zerver/lib/events.py b/zerver/lib/events.py index d0132b23c0..e231dc65a6 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -34,6 +34,7 @@ from zerver.lib.message import ( get_starred_message_ids, remove_message_id_from_unread_mgs, ) +from zerver.lib.muted_users import get_user_mutes from zerver.lib.narrow import check_supported_events_narrow_filter, read_stop_words from zerver.lib.presence import get_presence_for_user, get_presences_for_realm from zerver.lib.push_notifications import push_notifications_enabled @@ -48,7 +49,6 @@ from zerver.lib.timestamp import datetime_to_timestamp from zerver.lib.timezone import canonicalize_timezone from zerver.lib.topic import TOPIC_NAME from zerver.lib.user_groups import user_groups_in_realm_serialized -from zerver.lib.user_mutes import get_user_mutes from zerver.lib.user_status import get_user_status_dict from zerver.lib.user_topics import get_topic_mutes, get_user_topics from zerver.lib.users import get_cross_realm_dicts, get_raw_user_data, is_administrator_role diff --git a/zerver/lib/user_mutes.py b/zerver/lib/muted_users.py similarity index 100% rename from zerver/lib/user_mutes.py rename to zerver/lib/muted_users.py diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 584449e2f0..7e57e4b4ff 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -189,6 +189,7 @@ from zerver.lib.events import ( ) from zerver.lib.mention import MentionBackend, MentionData from zerver.lib.message import render_markdown +from zerver.lib.muted_users import get_mute_object from zerver.lib.test_classes import ZulipTestCase from zerver.lib.test_helpers import ( create_dummy_file, @@ -200,7 +201,6 @@ from zerver.lib.test_helpers import ( from zerver.lib.topic import TOPIC_NAME from zerver.lib.types import ProfileDataElementUpdateDict from zerver.lib.user_groups import create_user_group -from zerver.lib.user_mutes import get_mute_object from zerver.models import ( Attachment, CustomProfileField, diff --git a/zerver/tests/test_muting_users.py b/zerver/tests/test_muted_users.py similarity index 97% rename from zerver/tests/test_muting_users.py rename to zerver/tests/test_muted_users.py index a9803f2f50..5cee610123 100644 --- a/zerver/tests/test_muting_users.py +++ b/zerver/tests/test_muted_users.py @@ -5,9 +5,9 @@ import orjson from zerver.actions.users import do_deactivate_user from zerver.lib.cache import cache_get, get_muting_users_cache_key +from zerver.lib.muted_users import get_mute_object, get_muting_users, get_user_mutes from zerver.lib.test_classes import ZulipTestCase from zerver.lib.timestamp import datetime_to_timestamp -from zerver.lib.user_mutes import get_mute_object, get_muting_users, get_user_mutes from zerver.models import RealmAuditLog, UserMessage, UserProfile @@ -21,7 +21,7 @@ class MutedUsersTests(ZulipTestCase): self.assertEqual(muted_users, []) mute_time = datetime(2021, 1, 1, tzinfo=timezone.utc) - with mock.patch("zerver.views.user_mutes.timezone_now", return_value=mute_time): + with mock.patch("zerver.views.muted_users.timezone_now", return_value=mute_time): url = f"/api/v1/users/me/muted_users/{cordelia.id}" result = self.api_post(hamlet, url) self.assert_json_success(result) @@ -80,7 +80,7 @@ class MutedUsersTests(ZulipTestCase): # IntegrityError we'll get with a race between two processes # trying to mute the user. To do this, we patch the # get_mute_object function to always return None. - with mock.patch("zerver.views.user_mutes.get_mute_object", return_value=None): + with mock.patch("zerver.views.muted_users.get_mute_object", return_value=None): result = self.api_post(hamlet, url) self.assert_json_error(result, "User already muted") @@ -93,7 +93,7 @@ class MutedUsersTests(ZulipTestCase): if deactivate_user: do_deactivate_user(cordelia, acting_user=None) - with mock.patch("zerver.views.user_mutes.timezone_now", return_value=mute_time): + with mock.patch("zerver.views.muted_users.timezone_now", return_value=mute_time): url = f"/api/v1/users/me/muted_users/{cordelia.id}" result = self.api_post(hamlet, url) self.assert_json_success(result) @@ -147,7 +147,7 @@ class MutedUsersTests(ZulipTestCase): if deactivate_user: do_deactivate_user(cordelia, acting_user=None) - with mock.patch("zerver.views.user_mutes.timezone_now", return_value=mute_time): + with mock.patch("zerver.views.muted_users.timezone_now", return_value=mute_time): url = f"/api/v1/users/me/muted_users/{cordelia.id}" result = self.api_post(hamlet, url) self.assert_json_success(result) diff --git a/zerver/tests/test_read_receipts.py b/zerver/tests/test_read_receipts.py index 073e1827ca..62b1e0de16 100644 --- a/zerver/tests/test_read_receipts.py +++ b/zerver/tests/test_read_receipts.py @@ -5,8 +5,8 @@ from zerver.actions.create_user import do_reactivate_user from zerver.actions.realm_settings import do_set_realm_property from zerver.actions.user_settings import do_change_user_setting from zerver.actions.users import do_deactivate_user +from zerver.lib.muted_users import add_user_mute, get_mute_object from zerver.lib.test_classes import ZulipTestCase -from zerver.lib.user_mutes import add_user_mute, get_mute_object from zerver.models import UserMessage, UserProfile diff --git a/zerver/views/user_mutes.py b/zerver/views/muted_users.py similarity index 96% rename from zerver/views/user_mutes.py rename to zerver/views/muted_users.py index dbac2f4fe7..fbaba07359 100644 --- a/zerver/views/user_mutes.py +++ b/zerver/views/muted_users.py @@ -6,7 +6,7 @@ from django.utils.translation import gettext as _ from zerver.actions.muted_users import do_mute_user, do_unmute_user from zerver.lib.exceptions import JsonableError from zerver.lib.response import json_success -from zerver.lib.user_mutes import get_mute_object +from zerver.lib.muted_users import get_mute_object from zerver.lib.users import access_user_by_id from zerver.models import UserProfile diff --git a/zproject/urls.py b/zproject/urls.py index b918aa1ec3..b175d3199d 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -79,6 +79,7 @@ from zerver.views.message_flags import ( update_message_flags_for_narrow, ) from zerver.views.message_send import render_message_backend, send_message_backend, zcommand_backend +from zerver.views.muted_users import mute_user, unmute_user from zerver.views.presence import ( get_presence_backend, get_statuses_for_realm, @@ -182,7 +183,6 @@ from zerver.views.user_groups import ( update_subgroups_of_user_group, update_user_group_backend, ) -from zerver.views.user_mutes import mute_user, unmute_user from zerver.views.user_settings import ( confirm_email_change, delete_avatar_backend,