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.

navbar: Add gear menu advertisement for sponsoring zulip.

Vishnu KS051dab58eaee
diff --git a/templates/zerver/app/navbar.html b/templates/zerver/app/navbar.html
index 0fc12c140e4..de7f9c66ab8 100644
--- a/templates/zerver/app/navbar.html
+++ b/templates/zerver/app/navbar.html
@@ -136,6 +136,13 @@
</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">
diff --git a/zerver/lib/home.py b/zerver/lib/home.py
index 7afff294167..b3729d18f50 100644
--- a/zerver/lib/home.py
+++ b/zerver/lib/home.py
@@ -101,6 +101,15 @@ def get_bot_types(user_profile: Optional[UserProfile]) -> List[Dict[str, object]
return bot_types
+def promote_sponsoring_zulip_in_realm(realm: Realm) -> bool:
+ if not settings.PROMOTE_SPONSORING_ZULIP:
+ return False
+
+ # If PROMOTE_SPONSORING_ZULIP is enabled, advertise sponsoring
+ # Zulip in the gear menu of non-paying organizations.
+ return realm.plan_type in [Realm.STANDARD_FREE, Realm.SELF_HOSTED]
+
+
def get_billing_info(user_profile: UserProfile) -> BillingInfo:
show_billing = False
show_plans = False
@@ -118,7 +127,10 @@ def get_billing_info(user_profile: UserProfile) -> BillingInfo:
if not user_profile.is_guest and user_profile.realm.plan_type == Realm.LIMITED:
show_plans = True
- return BillingInfo(show_billing=show_billing, show_plans=show_plans)
+ return BillingInfo(
+ show_billing=show_billing,
+ show_plans=show_plans,
+ )
def get_user_permission_info(user_profile: Optional[UserProfile]) -> UserPermissionInfo:
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index 170f81f8d53..7d4fcc5b573 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -805,6 +805,30 @@ class HomeTest(ZulipTestCase):
result_html = self._get_home_page().content.decode("utf-8")
self.assertNotIn("Plans", result_html)
+ def test_show_support_zulip(self) -> None:
+ realm = get_realm("zulip")
+
+ self.login("hamlet")
+
+ result_html = self._get_home_page().content.decode("utf-8")
+ self.assertIn("Support Zulip", result_html)
+
+ do_change_plan_type(realm, Realm.STANDARD_FREE, acting_user=None)
+ result_html = self._get_home_page().content.decode("utf-8")
+ self.assertIn("Support Zulip", result_html)
+
+ with self.settings(PROMOTE_SPONSORING_ZULIP=False):
+ result_html = self._get_home_page().content.decode("utf-8")
+ self.assertNotIn("Support Zulip", result_html)
+
+ do_change_plan_type(realm, Realm.LIMITED, acting_user=None)
+ result_html = self._get_home_page().content.decode("utf-8")
+ self.assertNotIn("Support Zulip", result_html)
+
+ do_change_plan_type(realm, Realm.STANDARD, acting_user=None)
+ result_html = self._get_home_page().content.decode("utf-8")
+ self.assertNotIn("Support Zulip", result_html)
+
def test_desktop_home(self) -> None:
self.login("hamlet")
result = self.client_get("/desktop_home")
diff --git a/zerver/views/home.py b/zerver/views/home.py
index c487edbb32a..e049bc20402 100644
--- a/zerver/views/home.py
+++ b/zerver/views/home.py
@@ -16,6 +16,7 @@ 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.push_notifications import num_push_devices_for_user
from zerver.lib.streams import access_stream_by_name
@@ -231,6 +232,7 @@ 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,
diff --git a/zproject/default_settings.py b/zproject/default_settings.py
index a8d726d8d53..5a28357ecf6 100644
--- a/zproject/default_settings.py
+++ b/zproject/default_settings.py
@@ -180,6 +180,7 @@ PASSWORD_MIN_GUESSES = 10000
PUSH_NOTIFICATION_BOUNCER_URL: Optional[str] = None
PUSH_NOTIFICATION_REDACT_CONTENT = False
SUBMIT_USAGE_STATISTICS = True
+PROMOTE_SPONSORING_ZULIP = True
RATE_LIMITING = True
RATE_LIMITING_AUTHENTICATE = True
SEND_LOGIN_EMAILS = True
diff --git a/zproject/prod_settings_template.py b/zproject/prod_settings_template.py
index a73b41ba764..a6d4efab5b7 100644
--- a/zproject/prod_settings_template.py
+++ b/zproject/prod_settings_template.py
@@ -611,6 +611,9 @@ SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {
## Defaults to True if and only if the Mobile Push Notifications Service is enabled.
# SUBMIT_USAGE_STATISTICS = True
+## Whether to lightly advertise sponsoring Zulip in the gear menu.
+# PROMOTE_SPONSORING_ZULIP = True
+
## Controls whether session cookies expire when the browser closes
SESSION_EXPIRE_AT_BROWSER_CLOSE = False