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.

settings: Add realm setting for Zulip communities directory.

Lauryn Menard44c9b788f9b1
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js
index 792759a79ba..1be02e65cb7 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -384,6 +384,9 @@ run_test("realm settings", ({override}) => {
event = event_fixtures.realm__update__invite_to_realm_policy;
test_realm_integer(event, "realm_invite_to_realm_policy");
+ event = event_fixtures.realm__update__want_advertise_in_communities_directory;
+ test_realm_boolean(event, "realm_want_advertise_in_communities_directory");
+
event = event_fixtures.realm__update__name;
test_electron_dispatch(event, (key, val) => {
diff --git a/frontend_tests/node_tests/lib/events.js b/frontend_tests/node_tests/lib/events.js
index 4168509c8a3..f552baae93c 100644
--- a/frontend_tests/node_tests/lib/events.js
+++ b/frontend_tests/node_tests/lib/events.js
@@ -356,6 +356,13 @@ exports.fixtures = {
value: 41,
},
+ realm__update__want_advertise_in_communities_directory: {
+ type: "realm",
+ op: "update",
+ property: "want_advertise_in_communities_directory",
+ value: false,
+ },
+
realm__update_dict__default: {
type: "realm",
op: "update_dict",
diff --git a/static/js/admin.js b/static/js/admin.js
index 5e1dd389d6d..a19e5d0ceb9 100644
--- a/static/js/admin.js
+++ b/static/js/admin.js
@@ -17,6 +17,10 @@ import * as settings_sections from "./settings_sections";
import * as settings_toggle from "./settings_toggle";
const admin_settings_label = {
+ // Organization profile
+ realm_want_advertise_in_communities_directory: $t({
+ defaultMessage: "Advertise organization in the Zulip communities directory",
+ }),
// Organization settings
realm_allow_edit_history: $t({defaultMessage: "Enable message edit history"}),
realm_mandatory_topics: $t({defaultMessage: "Require topics in stream messages"}),
@@ -164,6 +168,10 @@ export function build_page() {
can_sort_by_email: settings_data.show_email(),
realm_push_notifications_enabled: page_params.realm_push_notifications_enabled,
realm_org_type_values: settings_org.get_org_type_dropdown_options(),
+ realm_want_advertise_in_communities_directory:
+ page_params.realm_want_advertise_in_communities_directory,
+ disable_want_advertise_in_communities_directory:
+ !page_params.server_web_public_streams_enabled,
};
if (options.realm_logo_source !== "D" && options.realm_night_logo_source === "D") {
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index 5ff2601852b..707d158ef6a 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -224,6 +224,7 @@ export function dispatch_normal_event(event) {
video_chat_provider: compose.update_video_chat_button_display,
giphy_rating: giphy.update_giphy_rating,
waiting_period_threshold: noop,
+ want_advertise_in_communities_directory: noop,
wildcard_mention_policy: noop,
};
switch (event.op) {
diff --git a/static/templates/settings/organization_profile_admin.hbs b/static/templates/settings/organization_profile_admin.hbs
index 66c141925bb..735cc6077b4 100644
--- a/static/templates/settings/organization_profile_admin.hbs
+++ b/static/templates/settings/organization_profile_admin.hbs
@@ -25,6 +25,13 @@
{{> dropdown_options_widget option_values=realm_org_type_values}}
</select>
</div>
+ {{> settings_checkbox
+ setting_name="realm_want_advertise_in_communities_directory"
+ prefix="id_"
+ is_checked=realm_want_advertise_in_communities_directory
+ is_disabled=disable_want_advertise_in_communities_directory
+ label=admin_settings_label.realm_want_advertise_in_communities_directory
+ help_link="/help/communities-directory"}}
<div class="input-group admin-realm">
<label for="realm_description">{{t "Organization description" }}</label>
<textarea id="id_realm_description" name="realm_description" class="admin-realm-description setting-widget prop-element"
diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md
index 932d6d485c0..e64280804f8 100644
--- a/templates/zerver/api/changelog.md
+++ b/templates/zerver/api/changelog.md
@@ -20,6 +20,13 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 6.0
+**Feature level 129**
+
+* [`POST /register`](/api/register-queue),
+ [`GET/events`](/api/get-events), `PATCH /realm`: Added realm setting
+ `want_advertise_in_communities_directory` for organizations to give
+ permission to be advertised in the Zulip communities directory.
+
**Feature level 128**
* [`POST /register`](/api/register-queue), [`GET
diff --git a/templates/zerver/help/communities-directory.md b/templates/zerver/help/communities-directory.md
new file mode 100644
index 00000000000..186937435fa
--- /dev/null
+++ b/templates/zerver/help/communities-directory.md
@@ -0,0 +1,42 @@
+# Zulip communities directory
+
+{!communities-directory-intro.md!}
+
+In order to be eligible for listing in the communities directory, an
+organization must be open to the public. Your organization is eligible if users are
+allowed [join without an invitation][join-without-invite] and/or the [public
+access option](/help/public-access-option) is enabled.
+
+The directory will be organized by [organization type](/help/organization-type),
+so it is highly recommended that you make sure the appropriate category is
+selected.
+
+To prevent spam, Zulip reserves the right to use editorial discretion. Giving
+Zulip permission to promote your organization in the communities directory does
+not guarantee that it will be listed.
+
+If you administer a self-hosted Zulip community that you would like to be
+listed, please contact [Zulip support](mailto:[email protected]).
+
+[join-without-invite]: /help/restrict-account-creation#set-whether-invitations-are-required-to-join
+[communities-directory-permission]: /help/communities-directory#give-permission-to-be-in-the-zulip-communities-directory
+
+## Change whether your organization may be listed in the Zulip communities directory
+
+{!admin-only.md!}
+
+{!communities-directory-instructions.md!}
+
+!!! tip ""
+
+ Organizations that are not open to the public will not be listed at this time.
+ If you administer a non-public organization, please check the box to request
+ to be listed in the future.
+
+## Related topics
+
+* [Create your organization profile](/help/create-your-organization-profile)
+* [Public access option](/help/public-access-option)
+* [Restrict account creation](/help/restrict-account-creation)
+* [Moderating open organizations](/help/moderating-open-organizations)
+* [Organization type](/help/organization-type)
diff --git a/templates/zerver/help/create-your-organization-profile.md b/templates/zerver/help/create-your-organization-profile.md
index 4134192ae8c..e20480c38a3 100644
--- a/templates/zerver/help/create-your-organization-profile.md
+++ b/templates/zerver/help/create-your-organization-profile.md
@@ -12,6 +12,16 @@ registration/login page:
{!edit-organization-profile.md!}
+## Zulip communities directory
+
+{!communities-directory-intro.md!}
+
+### Change whether your organization may be listed in the Zulip communities directory
+
+{!communities-directory-instructions.md!}
+
+For more details, see [Communities directory](/help/communities-directory).
+
## Add a wide logo
{!add-a-wide-logo.md!}
@@ -21,4 +31,5 @@ registration/login page:
* [Setting up your organization](/help/getting-your-organization-started-with-zulip)
* [Customize organization settings](/help/customize-organization-settings)
* [Create streams](/help/create-streams)
+* [Communities directory](/help/communities-directory)
* [Getting started with Zulip](/help/getting-started-with-zulip)
diff --git a/templates/zerver/help/include/communities-directory-instructions.md b/templates/zerver/help/include/communities-directory-instructions.md
new file mode 100644
index 00000000000..b0f19e5d263
--- /dev/null
+++ b/templates/zerver/help/include/communities-directory-instructions.md
@@ -0,0 +1,13 @@
+{start_tabs}
+
+{settings_tab|organization-profile}
+
+1. To be listed in the appropriate category, under **Organization type**, select
+the option that best fits your organization.
+
+1. Toggle **Advertise organization in the Zulip communities
+directory**.
+
+{!save-changes.md!}
+
+{end_tabs}
diff --git a/templates/zerver/help/include/communities-directory-intro.md b/templates/zerver/help/include/communities-directory-intro.md
new file mode 100644
index 00000000000..2b5a46c36ec
--- /dev/null
+++ b/templates/zerver/help/include/communities-directory-intro.md
@@ -0,0 +1,17 @@
+!!! tip ""
+
+ Coming to the [Zulip website](https://zulip.com) summer 2022 —
+ [sign up][communities-directory-instructions] to be listed when it launches!
+
+The Zulip communities directory offers publicly accessible [Zulip Cloud][zulip-cloud]
+organizations an opportunity to be listed on the [Zulip website](https://zulip.com). It's a way
+for open-source projects, research communities, and others to advertise their
+Zulip community and support the Zulip project.
+
+The directory will display your community's name, logo, and a link to you Zulip
+chat. Other information from your [organization
+profile](/help/create-your-organization-profile) and the size of your
+organization may be included as well.
+
+[zulip-cloud]: https://zulip.com/plans/
+[communities-directory-instructions]: /help/communities-directory#change-whether-your-organization-may-be-listed-in-the-zulip-communities-directory
diff --git a/templates/zerver/help/include/sidebar_index.md b/templates/zerver/help/include/sidebar_index.md
index 24cbe88afbf..be239752d71 100755
--- a/templates/zerver/help/include/sidebar_index.md
+++ b/templates/zerver/help/include/sidebar_index.md
@@ -129,6 +129,7 @@
## Organization basics
* [Review your organization's settings](/help/review-your-organization-settings)
* [Organization type](/help/organization-type)
+* [Communities directory](/help/communities-directory)
* [Import from Mattermost](/help/import-from-mattermost)
* [Import from Slack](/help/import-from-slack)
* [Import from Gitter](/help/import-from-gitter)
diff --git a/templates/zerver/help/moderating-open-organizations.md b/templates/zerver/help/moderating-open-organizations.md
index 3c0bde33d11..29c2e2a3c94 100644
--- a/templates/zerver/help/moderating-open-organizations.md
+++ b/templates/zerver/help/moderating-open-organizations.md
@@ -57,7 +57,15 @@ organization's policy choices.
{!web-public-streams-intro.md!}
+## Zulip communities directory
+
+{!communities-directory-intro.md!}
+
+For details on how to get your community listed, see [Communities
+directory](/help/communities-directory).
+
## Related articles
* [Setting up your organization](/help/getting-your-organization-started-with-zulip)
* [Public access option](/help/public-access-option)
+* [Communities directory](/help/communities-directory)
diff --git a/templates/zerver/help/organization-type.md b/templates/zerver/help/organization-type.md
index 4f8c6ddf521..1d0a57a8cc0 100644
--- a/templates/zerver/help/organization-type.md
+++ b/templates/zerver/help/organization-type.md
@@ -22,3 +22,4 @@ your organization.
## Related articles
* [Configure default new user settings](/help/configure-default-new-user-settings)
+* [Communities directory](/help/communities-directory)
diff --git a/version.py b/version.py
index 99345f22bee..2b151b05aa9 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
# Changes should be accompanied by documentation explaining what the
# new level means in templates/zerver/api/changelog.md, as well as
# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.
-API_FEATURE_LEVEL = 128
+API_FEATURE_LEVEL = 129
# Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump
diff --git a/zerver/migrations/0393_realm_want_advertise_in_communities_directory.py b/zerver/migrations/0393_realm_want_advertise_in_communities_directory.py
new file mode 100644
index 00000000000..c6d70dbe46b
--- /dev/null
+++ b/zerver/migrations/0393_realm_want_advertise_in_communities_directory.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.12 on 2022-04-22 11:24
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("zerver", "0392_non_nullable_fields"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="realm",
+ name="want_advertise_in_communities_directory",
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/zerver/models.py b/zerver/models.py
index 79e6657ab0c..2ff84b231b9 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -293,6 +293,10 @@ class Realm(models.Model):
# setting also controls API access of web-public streams.
enable_spectator_access: bool = models.BooleanField(default=False)
+ # Whether organization has given permission to be advertised in the
+ # Zulip communities directory.
+ want_advertise_in_communities_directory: bool = models.BooleanField(default=False)
+
# Whether the organization has enabled inline image and URL previews.
inline_image_preview: bool = models.BooleanField(default=True)
inline_url_embed_preview: bool = models.BooleanField(default=False)
@@ -711,6 +715,7 @@ class Realm(models.Model):
user_group_edit_policy=int,
video_chat_provider=int,
waiting_period_threshold=int,
+ want_advertise_in_communities_directory=bool,
wildcard_mention_policy=int,
)
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 552555c3fe6..9ab52df11f7 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -4013,6 +4013,13 @@ paths:
for the purpose of settings that restrict access to new members.
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
+ want_advertise_in_communities_directory:
+ type: boolean
+ description: |
+ Whether the organization has given permission to be advertised in the
+ Zulip [communities directory](/help/communities-directory).
+
+ **Changes**: New in Zulip 6.0 (feature level 129).
wildcard_mention_policy:
type: integer
description: |
@@ -11167,7 +11174,21 @@ paths:
**Changes**: New in Zulip 5.0 (feature level 109).
[server-settings]: https://zulip.readthedocs.io/en/stable/production/settings.html
+ realm_want_advertise_in_communities_directory:
+ type: boolean
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ Whether the organization has given permission to be advertised in the
+ Zulip [communities directory](/help/communities-directory).
+
+ Useful only to clients supporting changing this setting for the
+ organization.
+
+ Giving permission via this setting does not guarantee that an
+ organization will be listed in the Zulip communities directory.
+ **Changes**: New in Zulip 6.0 (feature level 129).
realm_video_chat_provider:
type: integer
description: |
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index 1ade0da3496..a8e0276fbab 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -182,6 +182,7 @@ class HomeTest(ZulipTestCase):
"realm_users",
"realm_video_chat_provider",
"realm_waiting_period_threshold",
+ "realm_want_advertise_in_communities_directory",
"realm_wildcard_mention_policy",
"recent_private_conversations",
"request_language",
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index ed0cba7ad5f..bd30f8f7cd8 100644
--- a/zerver/views/realm.py
+++ b/zerver/views/realm.py
@@ -143,6 +143,9 @@ def update_realm(
),
org_type: Optional[int] = REQ(json_validator=check_int_in(ORG_TYPE_IDS), default=None),
enable_spectator_access: Optional[bool] = REQ(json_validator=check_bool, default=None),
+ want_advertise_in_communities_directory: Optional[bool] = REQ(
+ json_validator=check_bool, default=None
+ ),
) -> HttpResponse:
realm = user_profile.realm