From e5ab3123afd6e7d76793603393c26264c54cc0f6 Mon Sep 17 00:00:00 2001 From: Amy Liu Date: Mon, 9 Jan 2017 16:23:53 -0800 Subject: [PATCH] Migrate json/set_muted_topics to muting/topics. --- static/js/muting_ui.js | 2 +- zerver/tests/test_muting.py | 4 ++-- zerver/views/muting.py | 7 +++---- zproject/legacy_urls.py | 1 - zproject/urls.py | 3 +++ 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js index 32fb736aa7..3300bf89b2 100644 --- a/static/js/muting_ui.js +++ b/static/js/muting_ui.js @@ -96,7 +96,7 @@ exports.persist_and_rerender = function () { }; last_topic_update = timestamp_ms(); channel.post({ - url: '/json/set_muted_topics', + url: '/json/users/me/subscriptions/muted_topics', idempotent: true, data: data, }); diff --git a/zerver/tests/test_muting.py b/zerver/tests/test_muting.py index 39e4e9e33b..f109fb8d37 100644 --- a/zerver/tests/test_muting.py +++ b/zerver/tests/test_muting.py @@ -16,7 +16,7 @@ class MutedTopicsTests(ZulipTestCase): email = 'hamlet@zulip.com' self.login(email) - url = '/json/set_muted_topics' + url = '/json/users/me/subscriptions/muted_topics' data = {'muted_topics': '[["stream", "topic"]]'} result = self.client_post(url, data) self.assert_json_success(result) @@ -24,7 +24,7 @@ class MutedTopicsTests(ZulipTestCase): user = get_user_profile_by_email(email) self.assertEqual(ujson.loads(user.muted_topics), [["stream", "topic"]]) - url = '/json/set_muted_topics' + url = '/json/users/me/subscriptions/muted_topics' data = {'muted_topics': '[["stream2", "topic2"]]'} result = self.client_post(url, data) self.assert_json_success(result) diff --git a/zerver/views/muting.py b/zerver/views/muting.py index f778556116..9d3456588e 100644 --- a/zerver/views/muting.py +++ b/zerver/views/muting.py @@ -10,11 +10,10 @@ from zerver.lib.response import json_success from zerver.lib.validator import check_string, check_list from zerver.models import UserProfile -@authenticated_json_post_view @has_request_variables -def json_set_muted_topics(request, user_profile, - muted_topics=REQ(validator=check_list( - check_list(check_string, length=2)), default=[])): +def set_muted_topics(request, user_profile, + muted_topics=REQ(validator=check_list( + check_list(check_string, length=2)), default=[])): # type: (HttpRequest, UserProfile, List[List[Text]]) -> HttpResponse do_set_muted_topics(user_profile, muted_topics) return json_success() diff --git a/zproject/legacy_urls.py b/zproject/legacy_urls.py index e220816fbc..78a6a70a6d 100644 --- a/zproject/legacy_urls.py +++ b/zproject/legacy_urls.py @@ -35,5 +35,4 @@ legacy_urls = [ url(r'^json/report_unnarrow_time$', zerver.views.report.json_report_unnarrow_time), url(r'^json/upload_file$', zerver.views.upload.json_upload_file), url(r'^json/messages_in_narrow$', zerver.views.messages.json_messages_in_narrow), - url(r'^json/set_muted_topics$', zerver.views.muting.json_set_muted_topics), ] diff --git a/zproject/urls.py b/zproject/urls.py index d9ce55d67d..23cb8dc6c8 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -340,6 +340,9 @@ v1_api_and_json_patterns = [ 'POST': 'zerver.views.streams.add_subscriptions_backend', 'PATCH': 'zerver.views.streams.update_subscriptions_backend', 'DELETE': 'zerver.views.streams.remove_subscriptions_backend'}), + # muting -> zerver.views.muting + url(r'^users/me/subscriptions/muted_topics$', rest_dispatch, + {'POST': 'zerver.views.muting.set_muted_topics'}), # used to register for an event queue in tornado url(r'^register$', rest_dispatch,