From 6d880c214746c076fd67637c7bd90bb97ba85515 Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Wed, 30 Jan 2013 17:12:23 -0500 Subject: [PATCH] subscriptions: make invite-only checkbox have an effect. (imported from commit 7ee5c5c88efa4ab21395c03012c2921fd3c5192e) --- zephyr/static/js/subs.js | 7 ++++--- zephyr/views.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/zephyr/static/js/subs.js b/zephyr/static/js/subs.js index 047bb518ae..d6128f330c 100644 --- a/zephyr/static/js/subs.js +++ b/zephyr/static/js/subs.js @@ -388,14 +388,15 @@ function ajaxUnsubscribe(stream) { }); } -function ajaxSubscribeForCreation(stream, principals) { +function ajaxSubscribeForCreation(stream, principals, invite_only) { // Subscribe yourself and possible other people to a new stream. $.ajax({ type: "POST", url: "/json/subscriptions/add", dataType: 'json', // This seems to be ignored. We still get back an xhr. data: {"subscriptions": JSON.stringify([stream]), - "principals": JSON.stringify(principals) + "principals": JSON.stringify(principals), + "invite_only": JSON.stringify(invite_only) }, success: function (data) { $("#create_stream_name").val(""); @@ -463,7 +464,7 @@ $(function () { }); // You are always subscribed to streams you create. principals.push(email); - ajaxSubscribeForCreation(stream, principals); + ajaxSubscribeForCreation(stream, principals, $('#invite-only').is(':checked')); }); $("#subscriptions_table").on("click", ".sub_unsub_button", function (e) { diff --git a/zephyr/views.py b/zephyr/views.py index 0f8077a232..4347cbaa4f 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -868,7 +868,8 @@ def get_public_streams_backend(request, user_profile): type=Recipient.STREAM, id__in=subs_filter).values('type_id') streams = sorted(stream.name for stream in Stream.objects.filter(id__in = stream_ids, - realm=user_profile.realm)) + realm=user_profile.realm, + invite_only=False)) return json_success({"streams": streams}) def get_stream_color(sub):