Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
portico: Remove orgs who haven't set their own description.
Aman Agrawalb8b7938eb9c5
diff --git a/corporate/views/portico.py b/corporate/views/portico.pyindex 7f9e2709b8e..dfff11d004a 100644--- a/corporate/views/portico.py+++ b/corporate/views/portico.py@@ -120,9 +120,16 @@ def hello_view(request: HttpRequest) -> HttpResponse:def communities_view(request: HttpRequest) -> HttpResponse:eligible_realms = []unique_org_type_ids = set()- want_to_be_advertised_realms = Realm.objects.filter(- want_advertise_in_communities_directory=True- ).order_by("name")+ want_to_be_advertised_realms = (+ Realm.objects.filter(+ want_advertise_in_communities_directory=True,+ )+ .exclude(+ # Filter out realms who haven't changed their description from the default.+ description="",+ )+ .order_by("name")+ )for realm in want_to_be_advertised_realms:open_to_public = not realm.invite_required and not realm.emails_restricted_to_domainsif realm.allow_web_public_streams_access() or open_to_public:@@ -143,8 +150,8 @@ def communities_view(request: HttpRequest) -> HttpResponse:)unique_org_type_ids.add(realm.org_type)- # Custom list of org types to show.- ORG_TYPES_TO_SHOW = [+ # Custom list of org filters to show.+ CATEGORIES_TO_OFFER = ["opensource","research","community",@@ -152,16 +159,18 @@ def communities_view(request: HttpRequest) -> HttpResponse:# Remove org_types for which there are no open organizations.org_types = dict()- for org_type in ORG_TYPES_TO_SHOW:+ for org_type in CATEGORIES_TO_OFFER:if Realm.ORG_TYPES[org_type]["id"] in unique_org_type_ids:org_types[org_type] = Realm.ORG_TYPES[org_type]- # Remove `Unspecified` ORG_TYPE- org_types.pop("unspecified", None)+ # This code is not required right bot could be useful in future.+ # If we ever decided to show all the ORG_TYPES.+ # Remove `Unspecified` ORG_TYPE+ # org_types.pop("unspecified", None)# Change display name of non-profit orgs.- if org_types.get("nonprofit"): # nocoverage- org_types["nonprofit"]["name"] = "Non-profit"+ # if org_types.get("nonprofit"): # nocoverage+ # org_types["nonprofit"]["name"] = "Non-profit"return TemplateResponse(request,diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.pyindex 1a16c112e11..c594bef07b9 100644--- a/zerver/tests/test_docs.py+++ b/zerver/tests/test_docs.py@@ -295,7 +295,26 @@ class DocPageTest(ZulipTestCase):realm = get_realm("zulip")realm.want_advertise_in_communities_directory = Truerealm.save()- self._test("/communities/", ["Open communities directory", *zulip_dev_info])++ realm.description = ""+ realm.save()+ result = self.client_get("/communities/")+ # Not shown because the realm has default description set.+ self.assert_not_in_success_response(["Zulip Dev"], result)++ realm.description = "Some description"+ realm.save()+ self._test("/communities/", ["Open communities directory", "Zulip Dev", "Some description"])++ # No org with research type so research category not displayed.+ result = self.client_get("/communities/")+ self.assert_not_in_success_response(['data-category="research"'], result)++ realm.org_type = Realm.ORG_TYPES["research"]["id"]+ realm.save()+ self._test(+ "/communities/", ["Open communities directory", "Zulip Dev", 'data-category="research"']+ )def test_integration_doc_endpoints(self) -> None:self._test(