Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

gear_menu: Extract the gear menu as a handlebars template.

Riken Shahb2ab448b71bb
diff --git a/static/js/gear_menu.js b/static/js/gear_menu.js
index 7fb9e7954b5..2cc729e2255 100644
--- a/static/js/gear_menu.js
+++ b/static/js/gear_menu.js
@@ -1,5 +1,7 @@
import $ from "jquery";
+import render_gear_menu from "../templates/gear_menu.hbs";
+
import * as hashchange from "./hashchange";
import {$t} from "./i18n";
import * as message_viewport from "./message_viewport";
@@ -96,6 +98,8 @@ export function update_org_settings_menu_item() {
}
export function initialize() {
+ const rendered_gear_menu = render_gear_menu({page_params});
+ $("#navbar-buttons").html(rendered_gear_menu);
update_org_settings_menu_item();
$('#gear-menu a[data-toggle="tab"]').on("show", (e) => {
diff --git a/static/templates/gear_menu.hbs b/static/templates/gear_menu.hbs
new file mode 100644
index 00000000000..cb62434d2f0
--- /dev/null
+++ b/static/templates/gear_menu.hbs
@@ -0,0 +1,129 @@
+<ul class="nav" role="navigation">
+ <li class="dropdown actual-dropdown-menu" id="gear-menu">
+ <a id="settings-dropdown" href="#" role="button" class="dropdown-toggle" data-target="nada" data-toggle="dropdown" title="{{t 'Menu' }} (g)">
+ <i class="fa fa-cog settings-dropdown-cog" aria-hidden="true"></i>
+ </a>
+ <ul class="dropdown-menu" role="menu" aria-labelledby="settings-dropdown">
+ {{!-- It is quite ingrained in our frontend code that your Home
+ view is a Bootstrap nav tab, even though we don't show the tab
+ anymore --}}
+ <li class="invisible" style="display:none;" role="presentation"><a href="#message_feed_container" data-toggle="tab"></a></li>
+ <li role="presentation">
+ <a href="#streams/subscribed" role="menuitem">
+ <i class="fa fa-exchange" aria-hidden="true"></i> {{t 'Manage streams' }}
+ </a>
+ </li>
+ <li role="presentation">
+ <a href="#settings" role="menuitem">
+ <i class="fa fa-wrench" aria-hidden="true"></i> {{t 'Settings' }}
+ </a>
+ </li>
+ <li class="admin-menu-item" role="presentation">
+ <a href="#organization" role="menuitem">
+ <i class="fa fa-bolt" aria-hidden="true"></i>
+ <span>{{t 'Manage organization' }}</span>
+ </a>
+ </li>
+ {{#unless page_params.is_guest}}
+ <li role="presentation">
+ <a href="/stats" target="_blank" rel="noopener noreferrer" role="menuitem">
+ <i class="fa fa-bar-chart" aria-hidden="true"></i>
+ <span>{{t 'Usage statistics' }}</span>
+ </a>
+ </li>
+ {{/unless}}
+ <li class="divider" role="presentation"></li>
+ <li role="presentation">
+ <a href="/help" target="_blank" rel="noopener noreferrer" role="menuitem">
+ <i class="fa fa-question-circle" aria-hidden="true"></i> {{t 'Help center' }}
+ </a>
+ </li>
+ <li role="presentation">
+ <a tabindex="0" role="menuitem" data-overlay-trigger="keyboard-shortcuts">
+ <i class="fa fa-keyboard-o" aria-hidden="true"></i> {{t 'Keyboard shortcuts' }} <span class="hotkey-hint">(?)</span>
+ </a>
+ </li>
+ <li role="presentation">
+ <a tabindex="0" role="menuitem" data-overlay-trigger="message-formatting">
+ <i class="fa fa-pencil" aria-hidden="true"></i> {{t 'Message formatting' }}
+ </a>
+ </li>
+ <li role="presentation">
+ <a tabindex="0" role="menuitem" data-overlay-trigger="search-operators">
+ <i class="fa fa-search" aria-hidden="true"></i> {{t 'Search operators' }}
+ </a>
+ </li>
+ <li role="presentation" id="gear_menu_about_zulip">
+ <a href="#about-zulip" role="menuitem" class="menuitem-version">
+ <span class="white_zulip_icon_without_text"></span>
+ <span class="about_zulip_text">{{t "About Zulip" }}</span>
+ </a>
+ </li>
+ {{#if page_params.corporate_enabled}}
+ <li role="presentation">
+ <a href="/help/contact-support" target="_blank" rel="noopener noreferrer" role="menuitem">
+ <i class="fa fa-envelope" aria-hidden="true"></i> {{t 'Contact support' }}
+ </a>
+ </li>
+ {{/if}}
+ <li class="divider" role="presentation"></li>
+ <li role="presentation">
+ <a href="{{ page_params.apps_page_url }}" target="_blank" rel="noopener noreferrer" role="menuitem">
+ <i class="fa fa-desktop" aria-hidden="true"></i> {{t 'Desktop & mobile apps' }}
+ </a>
+ </li>
+ <li role="presentation">
+ <a href="/integrations" target="_blank" rel="noopener noreferrer" role="menuitem">
+ <i class="fa fa-github" aria-hidden="true"></i> {{t 'Integrations' }}
+ </a>
+ </li>
+ <li role="presentation">
+ <a href="/api" target="_blank" rel="noopener noreferrer" role="menuitem">
+ <i class="fa fa-sitemap" aria-hidden="true"></i> {{t 'API documentation' }}
+ </a>
+ </li>
+ {{#if page_params.show_billing}}
+ <li role="presentation">
+ <a href="/billing" target="_blank" rel="noopener noreferrer" role="menuitem">
+ <i class="fa fa-credit-card" aria-hidden="true"></i> {{t 'Billing' }}
+ </a>
+ </li>
+ {{/if}}
+ {{#if page_params.promote_sponsoring_zulip }}
+ <li role="presentation">
+ <a href="https://github.com/sponsors/zulip" target="_blank" role="menuitem">
+ <i class="fa fa-heart" aria-hidden="true"></i> {{t 'Support Zulip' }}
+ </a>
+ </li>
+ {{/if}}
+ {{#if page_params.show_plans}}
+ <li role="presentation">
+ <a href="/plans" target="_blank" rel="noopener noreferrer" role="menuitem">
+ <i class="fa fa-rocket" aria-hidden="true"></i> {{t 'Plans and pricing' }}
+ </a>
+ </li>
+ {{/if}}
+ <li class="divider" role="presentation"></li>
+ {{#if page_params.show_invites}}
+ <li role="presentation">
+ <a href="#invite" role="menuitem">
+ <i class="fa fa-user-plus" aria-hidden="true"></i> {{t 'Invite users' }}
+ </a>
+ </li>
+ <li class="divider" role="presentation"></li>
+ {{/if}}
+ {{#if page_params.show_webathena}}
+ <li title="{{t 'Grant Zulip the Kerberos tickets needed to run your Zephyr mirror via Webathena' }}" id="webathena_login_menu" role="presentation">
+ <a href="#webathena" class="webathena_login" role="menuitem">
+ <i class="fa fa-bolt" aria-hidden="true"></i>{{t 'Link with Webathena' }}
+ </a>
+ </li>
+ {{/if}}
+ <li role="presentation">
+ <a href="#logout" class="logout_button" role="menuitem">
+ <i class="fa fa-power-off" aria-hidden="true"></i> {{t 'Log out' }}
+ </a>
+ </li>
+ </ul>
+ </li>
+</ul>
diff --git a/templates/zerver/app/navbar.html b/templates/zerver/app/navbar.html
index b3419df4b60..cee54af21cb 100644
--- a/templates/zerver/app/navbar.html
+++ b/templates/zerver/app/navbar.html
@@ -48,137 +48,6 @@
</a>
</div>
<div id="navbar-buttons" {%if embedded %} style="visibility: hidden"{% endif %}>
- <ul class="nav" role="navigation">
- <li class="dropdown actual-dropdown-menu" id="gear-menu">
- <a id="settings-dropdown" href="#" role="button" class="dropdown-toggle" data-target="nada" data-toggle="dropdown" title="{{ _('Menu') }} (g)">
- <i class="fa fa-cog settings-dropdown-cog" aria-hidden="true"></i>
- </a>
- <ul class="dropdown-menu" role="menu" aria-labelledby="settings-dropdown">
- {#
- It is quite ingrained in our frontend code that your Home
- view is a Bootstrap nav tab, even though we don't show the tab
- anymore
- #}
- <li class="invisible" style="display:none;" role="presentation"><a href="#message_feed_container" data-toggle="tab"></a></li>
- <li role="presentation">
- <a href="#streams/subscribed" role="menuitem">
- <i class="fa fa-exchange" aria-hidden="true"></i> {{ _('Manage streams') }}
- </a>
- </li>
- <li role="presentation">
- <a href="#settings" role="menuitem">
- <i class="fa fa-wrench" aria-hidden="true"></i> {{ _('Settings') }}
- </a>
- </li>
- <li class="admin-menu-item" role="presentation">
- <a href="#organization" role="menuitem">
- <i class="fa fa-bolt" aria-hidden="true"></i>
- <span>{{ _('Manage organization') }}</span>
- </a>
- </li>
- {% if not is_guest %}
- <li role="presentation">
- <a href="/stats" target="_blank" rel="noopener noreferrer" role="menuitem">
- <i class="fa fa-bar-chart" aria-hidden="true"></i>
- <span>{{ _('Usage statistics') }}</span>
- </a>
- </li>
- {% endif %}
- <li class="divider" role="presentation"></li>
- <li role="presentation">
- <a href="/help" target="_blank" rel="noopener noreferrer" role="menuitem">
- <i class="fa fa-question-circle" aria-hidden="true"></i> {{ _('Help center') }}
- </a>
- </li>
- <li role="presentation">
- <a tabindex="0" role="menuitem" data-overlay-trigger="keyboard-shortcuts">
- <i class="fa fa-keyboard-o" aria-hidden="true"></i> {{ _('Keyboard shortcuts') }} <span class="hotkey-hint">(?)</span>
- </a>
- </li>
- <li role="presentation">
- <a tabindex="0" role="menuitem" data-overlay-trigger="message-formatting">
- <i class="fa fa-pencil" aria-hidden="true"></i> {{ _('Message formatting') }}
- </a>
- </li>
- <li role="presentation">
- <a tabindex="0" role="menuitem" data-overlay-trigger="search-operators">
- <i class="fa fa-search" aria-hidden="true"></i> {{ _('Search operators') }}
- </a>
- </li>
- <li role="presentation" id="gear_menu_about_zulip">
- <a href="#about-zulip" role="menuitem" class="menuitem-version">
- <span class="white_zulip_icon_without_text"></span>
- <span class="about_zulip_text">{{ _("About Zulip") }}</span>
- </a>
- </li>
- {% if corporate_enabled %}
- <li role="presentation">
- <a href="/help/contact-support" target="_blank" rel="noopener noreferrer" role="menuitem">
- <i class="fa fa-envelope" aria-hidden="true"></i> {{ _('Contact support') }}
- </a>
- </li>
- {% endif %}
- <li class="divider" role="presentation"></li>
- <li role="presentation">
- <a href="{{ apps_page_url }}" target="_blank" rel="noopener noreferrer" role="menuitem">
- <i class="fa fa-desktop" aria-hidden="true"></i> {{ _('Desktop & mobile apps') }}
- </a>
- </li>
- <li role="presentation">
- <a href="/integrations" target="_blank" rel="noopener noreferrer" role="menuitem">
- <i class="fa fa-github" aria-hidden="true"></i> {{ _('Integrations') }}
- </a>
- </li>
- <li role="presentation">
- <a href="/api" target="_blank" rel="noopener noreferrer" role="menuitem">
- <i class="fa fa-sitemap" aria-hidden="true"></i> {{ _('API documentation') }}
- </a>
- </li>
- {% if show_billing %}
- <li role="presentation">
- <a href="/billing" target="_blank" rel="noopener noreferrer" role="menuitem">
- <i class="fa fa-credit-card" aria-hidden="true"></i> {{ _('Billing') }}
- </a>
- </li>
- {% endif %}
- {% if promote_sponsoring_zulip %}
- <li role="presentation">
- <a href="https://github.com/sponsors/zulip" target="_blank" role="menuitem">
- <i class="fa fa-heart" aria-hidden="true"></i> {{ _('Support Zulip') }}
- </a>
- </li>
- {% endif %}
- {% if show_plans %}
- <li role="presentation">
- <a href="/plans" target="_blank" rel="noopener noreferrer" role="menuitem">
- <i class="fa fa-rocket" aria-hidden="true"></i> {{ _('Plans and pricing') }}
- </a>
- </li>
- {% endif %}
- <li class="divider" role="presentation"></li>
- {% if show_invites %}
- <li role="presentation">
- <a href="#invite" role="menuitem">
- <i class="fa fa-user-plus" aria-hidden="true"></i> {{ _('Invite users') }}
- </a>
- </li>
- <li class="divider" role="presentation"></li>
- {% endif %}
- {% if show_webathena %}
- <li title="{% trans %}Grant Zulip the Kerberos tickets needed to run your Zephyr mirror via Webathena{% endtrans %}" id="webathena_login_menu" role="presentation">
- <a href="#webathena" class="webathena_login" role="menuitem">
- <i class="fa fa-bolt" aria-hidden="true"></i>{{ _('Link with Webathena') }}
- </a>
- </li>
- {% endif %}
- <li role="presentation">
- <a href="#logout" class="logout_button" role="menuitem">
- <i class="fa fa-power-off" aria-hidden="true"></i> {{ _('Log out') }}
- </a>
- </li>
- </ul>
- </li>
- </ul>
</div>
</div>
</nav>
diff --git a/zerver/lib/home.py b/zerver/lib/home.py
index 0df0b1df98e..dd280cf13c6 100644
--- a/zerver/lib/home.py
+++ b/zerver/lib/home.py
@@ -9,6 +9,7 @@ from django.utils import translation
from two_factor.utils import default_device
from version import ZULIP_MERGE_BASE
+from zerver.context_processors import get_apps_page_url
from zerver.lib.events import do_events_register
from zerver.lib.i18n import (
get_and_set_request_language,
@@ -17,6 +18,7 @@ from zerver.lib.i18n import (
get_language_name,
get_language_translation_data,
)
+from zerver.lib.users import compute_show_invites_and_add_streams
from zerver.models import Message, Realm, Stream, UserProfile
from zerver.views.message_flags import get_latest_update_message_flag_activity
@@ -178,6 +180,9 @@ def build_page_params_for_home_page_load(
)
two_fa_enabled = settings.TWO_FACTOR_AUTHENTICATION_ENABLED and user_profile is not None
+ billing_info = get_billing_info(user_profile)
+ show_invites, _ = compute_show_invites_and_add_streams(user_profile)
+ user_permission_info = get_user_permission_info(user_profile)
# Pass parameters to the client-side JavaScript code.
# These end up in a JavaScript Object named 'page_params'.
@@ -201,6 +206,12 @@ def build_page_params_for_home_page_load(
furthest_read_time=furthest_read_time,
bot_types=get_bot_types(user_profile),
two_fa_enabled=two_fa_enabled,
+ apps_page_url=get_apps_page_url(),
+ show_billing=billing_info.show_billing,
+ promote_sponsoring_zulip=promote_sponsoring_zulip_in_realm(realm),
+ show_plans=billing_info.show_plans,
+ show_invites=show_invites,
+ show_webathena=user_permission_info.show_webathena,
# Adding two_fa_enabled as condition saves us 3 queries when
# 2FA is not enabled.
two_fa_enabled_user=two_fa_enabled and bool(default_device(user_profile)),
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index e7bf24b90ba..27dcfb87f85 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -19,7 +19,11 @@ from zerver.lib.actions import (
)
from zerver.lib.compatibility import LAST_SERVER_UPGRADE_TIME, is_outdated_server
from zerver.lib.events import add_realm_logo_fields
-from zerver.lib.home import get_furthest_read_time
+from zerver.lib.home import (
+ get_billing_info,
+ get_furthest_read_time,
+ promote_sponsoring_zulip_in_realm,
+)
from zerver.lib.soft_deactivation import do_soft_deactivate_users
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import get_user_messages, override_settings, queries_captured
@@ -46,6 +50,7 @@ class HomeTest(ZulipTestCase):
# Keep this list sorted!!!
expected_page_params_keys = [
"alert_words",
+ "apps_page_url",
"available_notification_sounds",
"avatar_source",
"avatar_url",
@@ -55,6 +60,7 @@ class HomeTest(ZulipTestCase):
"can_invite_others_to_realm",
"can_subscribe_other_users",
"color_scheme",
+ "corporate_enabled",
"cross_realm_bots",
"custom_profile_field_types",
"custom_profile_fields",
@@ -73,7 +79,6 @@ class HomeTest(ZulipTestCase):
"enable_digest_emails",
"enable_login_emails",
"enable_marketing_emails",
- "enable_marketing_emails_enabled",
"enable_offline_email_notifications",
"enable_offline_push_notifications",
"enable_online_push_notifications",
@@ -129,6 +134,7 @@ class HomeTest(ZulipTestCase):
"pm_content_in_desktop_notifications",
"presence_enabled",
"presences",
+ "promote_sponsoring_zulip",
"prompt_for_invites",
"queue_id",
"realm_add_emoji_by_admins_only",
@@ -216,6 +222,10 @@ class HomeTest(ZulipTestCase):
"server_needs_upgrade",
"server_timestamp",
"settings_send_digest_emails",
+ "show_billing",
+ "show_invites",
+ "show_plans",
+ "show_webathena",
"starred_message_counts",
"starred_messages",
"stop_words",
@@ -248,7 +258,6 @@ class HomeTest(ZulipTestCase):
"Exclude messages with topic",
"Keyboard shortcuts",
"Loading...",
- "Manage streams",
"Narrow to topic",
"Next message",
"Filter streams",
@@ -718,17 +727,18 @@ class HomeTest(ZulipTestCase):
self.assertEqual(get_realm("zulip").invite_to_realm_policy, Realm.POLICY_MEMBERS_ONLY)
self.assertNotInHomePage("Invite more users")
- def test_show_billing(self) -> None:
- customer = Customer.objects.create(realm=get_realm("zulip"), stripe_customer_id="cus_id")
+ def test_get_billing_info(self) -> None:
user = self.example_user("desdemona")
-
- # realm owner, but no CustomerPlan -> no billing link
user.role = UserProfile.ROLE_REALM_OWNER
user.save(update_fields=["role"])
- self.login_user(user)
- self.assertNotInHomePage("Billing")
+ # realm owner, but no CustomerPlan and realm plan_type SELF_HOSTED -> neither billing link or plans
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertFalse(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
- # realm owner, with inactive CustomerPlan -> show billing link
+ # realm owner, with inactive CustomerPlan and realm plan_type SELF_HOSTED -> show only billing link
+ customer = Customer.objects.create(realm=get_realm("zulip"), stripe_customer_id="cus_id")
CustomerPlan.objects.create(
customer=customer,
billing_cycle_anchor=timezone_now(),
@@ -737,83 +747,112 @@ class HomeTest(ZulipTestCase):
tier=CustomerPlan.STANDARD,
status=CustomerPlan.ENDED,
)
- self.assertInHomePage("Billing")
-
- # realm admin, with CustomerPlan -> no billing link
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertTrue(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
+
+ # realm owner, with inactive CustomerPlan and realm plan_type LIMITED -> show billing link and plans
+ do_change_plan_type(user.realm, Realm.LIMITED, acting_user=None)
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertTrue(billing_info.show_billing)
+ self.assertTrue(billing_info.show_plans)
+
+ # Always false without CORPORATE_ENABLED
+ with self.settings(CORPORATE_ENABLED=False):
+ billing_info = get_billing_info(user)
+ self.assertFalse(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
+
+ # Always false without a UserProfile
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(None)
+ self.assertFalse(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
+
+ # realm admin, with CustomerPlan and realm plan_type LIMITED -> show only billing plans
user.role = UserProfile.ROLE_REALM_ADMINISTRATOR
user.save(update_fields=["role"])
- self.assertNotInHomePage("Billing")
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertFalse(billing_info.show_billing)
+ self.assertTrue(billing_info.show_plans)
- # billing admin, with CustomerPlan -> show billing link
+ # billing admin, with CustomerPlan and realm plan_type STANDARD -> show only billing link
user.role = UserProfile.ROLE_MEMBER
user.is_billing_admin = True
+ do_change_plan_type(user.realm, Realm.STANDARD, acting_user=None)
user.save(update_fields=["role", "is_billing_admin"])
- self.assertInHomePage("Billing")
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertTrue(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
- # member, with CustomerPlan -> no billing link
+ # member, with CustomerPlan and realm plan_type STANDARD -> neither billing link or plans
user.is_billing_admin = False
user.save(update_fields=["is_billing_admin"])
- self.assertNotInHomePage("Billing")
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertFalse(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
- # guest, with CustomerPlan -> no billing link
+ # guest, with CustomerPlan and realm plan_type SELF_HOSTED -> neither billing link or plans
user.role = UserProfile.ROLE_GUEST
user.save(update_fields=["role"])
- self.assertNotInHomePage("Billing")
+ do_change_plan_type(user.realm, Realm.SELF_HOSTED, acting_user=None)
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertFalse(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
- # billing admin, but no CustomerPlan -> no billing link
+ # billing admin, but no CustomerPlan and realm plan_type SELF_HOSTED -> neither billing link or plans
user.role = UserProfile.ROLE_MEMBER
user.is_billing_admin = True
user.save(update_fields=["role", "is_billing_admin"])
CustomerPlan.objects.all().delete()
- self.assertNotInHomePage("Billing")
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertFalse(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
- # billing admin, with sponsorship pending -> show billing link
+ # billing admin, with sponsorship pending and relam plan_type SELF_HOSTED -> show only billing link
customer.sponsorship_pending = True
customer.save(update_fields=["sponsorship_pending"])
- self.assertInHomePage("Billing")
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertTrue(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
- # billing admin, no customer object -> make sure it doesn't crash
+ # billing admin, no customer object and relam plan_type SELF_HOSTED -> neither billing link or plans
customer.delete()
- result = self._get_home_page()
- self.check_rendered_logged_in_app(result)
-
- def test_show_plans(self) -> None:
- realm = get_realm("zulip")
-
- # Don't show plans to guest users
- self.login("polonius")
- do_change_plan_type(realm, Realm.LIMITED, acting_user=None)
- self.assertNotInHomePage("Plans")
-
- # Show plans link to all other users if plan_type is LIMITED
- self.login("hamlet")
- self.assertInHomePage("Plans")
-
- # Show plans link to no one, including admins, if SELF_HOSTED or STANDARD
- do_change_plan_type(realm, Realm.SELF_HOSTED, acting_user=None)
- self.assertNotInHomePage("Plans")
-
- do_change_plan_type(realm, Realm.STANDARD, acting_user=None)
- self.assertNotInHomePage("Plans")
+ with self.settings(CORPORATE_ENABLED=True):
+ billing_info = get_billing_info(user)
+ self.assertFalse(billing_info.show_billing)
+ self.assertFalse(billing_info.show_plans)
- def test_show_support_zulip(self) -> None:
+ def test_promote_sponsoring_zulip_in_realm(self) -> None:
realm = get_realm("zulip")
- self.login("hamlet")
-
- self.assertInHomePage("Support Zulip")
-
do_change_plan_type(realm, Realm.STANDARD_FREE, acting_user=None)
- self.assertInHomePage("Support Zulip")
+ promote_zulip = promote_sponsoring_zulip_in_realm(realm)
+ self.assertTrue(promote_zulip)
with self.settings(PROMOTE_SPONSORING_ZULIP=False):
- self.assertNotInHomePage("Support Zulip")
+ promote_zulip = promote_sponsoring_zulip_in_realm(realm)
+ self.assertFalse(promote_zulip)
+
+ do_change_plan_type(realm, Realm.STANDARD_FREE, acting_user=None)
+ promote_zulip = promote_sponsoring_zulip_in_realm(realm)
+ self.assertTrue(promote_zulip)
do_change_plan_type(realm, Realm.LIMITED, acting_user=None)
- self.assertNotInHomePage("Support Zulip")
+ promote_zulip = promote_sponsoring_zulip_in_realm(realm)
+ self.assertFalse(promote_zulip)
do_change_plan_type(realm, Realm.STANDARD, acting_user=None)
- self.assertNotInHomePage("Support Zulip")
+ promote_zulip = promote_sponsoring_zulip_in_realm(realm)
+ self.assertFalse(promote_zulip)
def test_desktop_home(self) -> None:
self.login("hamlet")
diff --git a/zerver/views/home.py b/zerver/views/home.py
index 08b1b6c15c5..3388212ebd5 100644
--- a/zerver/views/home.py
+++ b/zerver/views/home.py
@@ -13,12 +13,7 @@ from zerver.decorator import web_public_view, zulip_login_required
from zerver.forms import ToSForm
from zerver.lib.actions import do_change_tos_version, realm_user_count
from zerver.lib.compatibility import is_outdated_desktop_app, is_unsupported_browser
-from zerver.lib.home import (
- build_page_params_for_home_page_load,
- get_billing_info,
- get_user_permission_info,
- promote_sponsoring_zulip_in_realm,
-)
+from zerver.lib.home import build_page_params_for_home_page_load, get_user_permission_info
from zerver.lib.streams import access_stream_by_name
from zerver.lib.subdomains import get_subdomain
from zerver.lib.users import compute_show_invites_and_add_streams
@@ -208,8 +203,6 @@ def home_real(request: HttpRequest) -> HttpResponse:
show_invites, show_add_streams = compute_show_invites_and_add_streams(user_profile)
- billing_info = get_billing_info(user_profile)
-
request._log_data["extra"] = "[{}]".format(queue_id)
csp_nonce = secrets.token_hex(24)
@@ -228,16 +221,11 @@ def home_real(request: HttpRequest) -> HttpResponse:
"search_pills_enabled": settings.SEARCH_PILLS_ENABLED,
"show_invites": show_invites,
"show_add_streams": show_add_streams,
- "promote_sponsoring_zulip": promote_sponsoring_zulip_in_realm(realm),
- "show_billing": billing_info.show_billing,
- "corporate_enabled": settings.CORPORATE_ENABLED,
- "show_plans": billing_info.show_plans,
"is_owner": user_permission_info.is_realm_owner,
"is_admin": user_permission_info.is_realm_admin,
"is_guest": user_permission_info.is_guest,
"color_scheme": user_permission_info.color_scheme,
"navbar_logo_url": navbar_logo_url,
- "show_webathena": user_permission_info.show_webathena,
"embedded": narrow_stream is not None,
"max_file_upload_size_mib": settings.MAX_FILE_UPLOAD_SIZE,
},