From f1aa17cf1db7c00fe2ad4583f0cb000179662fb6 Mon Sep 17 00:00:00 2001 From: Waseem Daher Date: Fri, 21 Sep 2012 17:22:15 -0400 Subject: [PATCH] Change some URLs associated with subscriptions. Put all the 'API'-ish URLs in the /json/ namespace so that /subscriptions and /subscriptions/add, etc. can be real user-facing URLs if we want them to be. (imported from commit 1455a32d27e44547ab1874b6289243cb40c85dde) --- humbug/urls.py | 6 +++--- templates/zephyr/subscriptions.html | 4 ++-- zephyr/static/js/zephyr.js | 4 ++-- zephyr/tests.py | 4 ++-- zephyr/views.py | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/humbug/urls.py b/humbug/urls.py index bbb3539637..ae1c235a55 100644 --- a/humbug/urls.py +++ b/humbug/urls.py @@ -19,9 +19,9 @@ urlpatterns = patterns('', url(r'^settings/manage/$', 'zephyr.views.manage_settings', name='manage_settings'), url(r'^settings/change/$', 'zephyr.views.change_settings', name='change_settings'), url(r'^subscriptions/$', 'zephyr.views.subscriptions', name='subscriptions'), - url(r'^json/subscriptions/$', 'zephyr.views.json_subscriptions', name='json_subscriptions'), - url(r'^subscriptions/remove$', 'zephyr.views.remove_subscription', name='remove_subscription'), - url(r'^subscriptions/add$', 'zephyr.views.add_subscription', name='add_subscription'), + url(r'^json/subscriptions/list$', 'zephyr.views.json_list_subscriptions', name='list_subscriptions'), + url(r'^json/subscriptions/remove$', 'zephyr.views.json_remove_subscription', name='remove_subscription'), + url(r'^json/subscriptions/add$', 'zephyr.views.json_add_subscription', name='add_subscription'), url(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': os.path.join(settings.SITE_ROOT, '..', 'zephyr', 'static/')}), url(r'^subscriptions/exists/(?P.*)$', 'zephyr.views.class_exists', name='class_exists'), diff --git a/templates/zephyr/subscriptions.html b/templates/zephyr/subscriptions.html index 2df1aaca01..f6f46838a6 100644 --- a/templates/zephyr/subscriptions.html +++ b/templates/zephyr/subscriptions.html @@ -4,11 +4,11 @@

Subscriptions

-
{% csrf_token %} + {% csrf_token %}
-
{% csrf_token %} + {% csrf_token %}
diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 6a5dc8f37e..16bb2c5822 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -42,7 +42,7 @@ $(function () { $('#sidebar a[href="#subscriptions"]').click(function () { $.ajax({ type: 'GET', - url: 'json/subscriptions/', + url: 'json/subscriptions/list', dataType: 'json', timeout: 10*1000, success: function (data) { @@ -85,7 +85,7 @@ $.ajaxSetup({ function sub(zephyr_class) { // TODO: check the return value and handle an error condition - $.post('/subscriptions/add', {new_subscription: zephyr_class}); + $.post('/json/subscriptions/add', {new_subscription: zephyr_class}); } function compose_button() { diff --git a/zephyr/tests.py b/zephyr/tests.py index d92e96a258..7d7211ecc4 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -94,8 +94,8 @@ class PublicURLTest(TestCase): """ urls = {200: ["/accounts/home/", "/accounts/login/", "/accounts/logout/", "/accounts/register/"], - 302: ["/", "/zephyr/", "/subscriptions/", - "/subscriptions/remove", "/subscriptions/add"] + 302: ["/", "/zephyr/", "/json/subscriptions/list", + "/json/subscriptions/remove", "/json/subscriptions/add"] } for status_code, url_set in urls.iteritems(): self.fetch(url_set, status_code) diff --git a/zephyr/views.py b/zephyr/views.py index 18f4a701ff..662b1fab6b 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -304,14 +304,14 @@ def subscriptions(request): context_instance=RequestContext(request)) @login_required -def json_subscriptions(request): +def json_list_subscriptions(request): subs = gather_subscriptions(UserProfile.objects.get(user=request.user)) return HttpResponse(content=simplejson.dumps({"subscriptions": subs}), mimetype='application/json', status=200) @login_required @require_post -def remove_subscription(request): +def json_remove_subscription(request): user_profile = UserProfile.objects.get(user=request.user) if 'subscription' not in request.POST: return json_error("Missing subscriptions") @@ -329,7 +329,7 @@ def remove_subscription(request): @login_required @require_post -def add_subscription(request): +def json_add_subscription(request): user_profile = UserProfile.objects.get(user=request.user) if "new_subscription" not in request.POST: