From ec91ece6eddae567a59086624fdf90bb940cc6c1 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Wed, 15 Jan 2014 17:30:36 -0500 Subject: [PATCH] Remove "Create new stream" UI for restricted users. If a user is not allowed to create new streams, then do not show the "Create new stream" UI at the top of the settings page. (imported from commit b97626938d8b612317c2189f7eca0d4bd27fc274) --- static/js/subs.js | 6 +++++- static/templates/subscription_table_body.handlebars | 2 ++ zerver/views/__init__.py | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/static/js/subs.js b/static/js/subs.js index eb63e5ccf5..b1b1bffb16 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -420,7 +420,11 @@ exports.setup_page = function () { }); $('#subscriptions_table').empty(); - var rendered = templates.render('subscription_table_body', {subscriptions: sub_rows}); + var template_data = { + can_create_streams: page_params.can_create_streams, + subscriptions: sub_rows + }; + var rendered = templates.render('subscription_table_body', template_data); $('#subscriptions_table').append(rendered); _.each(sub_rows, function (row) { diff --git a/static/templates/subscription_table_body.handlebars b/static/templates/subscription_table_body.handlebars index 5448af6258..f38fe2dbda 100644 --- a/static/templates/subscription_table_body.handlebars +++ b/static/templates/subscription_table_body.handlebars @@ -1,3 +1,4 @@ +{{#if can_create_streams}}
@@ -8,6 +9,7 @@
+{{/if}} {{#each subscriptions}} {{partial "subscription"}} diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index d0936e45e0..7231b09f81 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -852,6 +852,7 @@ def home(request): muted_topics = register_ret['muted_topics'], realm_filters = register_ret['realm_filters'], is_admin = user_profile.is_admin(), + can_create_streams = user_profile.can_create_streams(), notify_for_streams_by_default = notify_for_streams_by_default(user_profile), name_changes_disabled = settings.NAME_CHANGES_DISABLED, has_mobile_devices = num_push_devices_for_user(user_profile) > 0,