mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
events: Add demo_organization_scheduled_deletion_date to /register.
This commit adds `demo_organization_scheduled_deletion_date` to the `realm` section of the `/register` response so that it is available to clients when enabled. This is a part of #19523.
This commit is contained in:
@@ -11,6 +11,10 @@ below features are supported.
|
|||||||
|
|
||||||
## Changes in Zulip 5.0
|
## Changes in Zulip 5.0
|
||||||
|
|
||||||
|
**Feature level 94**
|
||||||
|
* [`POST /register`](/api/register-queue): Added
|
||||||
|
`demo_organization_scheduled_deletion_date` field to realm data.
|
||||||
|
|
||||||
**Feature level 93**
|
**Feature level 93**
|
||||||
|
|
||||||
* [`POST /register`](/api/register-queue), [`GET /user_groups`](/api/get-user-groups),
|
* [`POST /register`](/api/register-queue), [`GET /user_groups`](/api/get-user-groups),
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
|
|||||||
# Changes should be accompanied by documentation explaining what the
|
# Changes should be accompanied by documentation explaining what the
|
||||||
# new level means in templates/zerver/api/changelog.md, as well as
|
# new level means in templates/zerver/api/changelog.md, as well as
|
||||||
# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.
|
# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.
|
||||||
API_FEATURE_LEVEL = 93
|
API_FEATURE_LEVEL = 94
|
||||||
|
|
||||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
# 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
|
# only when going from an old version of the code to a newer version. Bump
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ from zerver.lib.realm_icon import realm_icon_url
|
|||||||
from zerver.lib.realm_logo import get_realm_logo_source, get_realm_logo_url
|
from zerver.lib.realm_logo import get_realm_logo_source, get_realm_logo_url
|
||||||
from zerver.lib.soft_deactivation import reactivate_user_if_soft_deactivated
|
from zerver.lib.soft_deactivation import reactivate_user_if_soft_deactivated
|
||||||
from zerver.lib.stream_subscription import handle_stream_notifications_compatibility
|
from zerver.lib.stream_subscription import handle_stream_notifications_compatibility
|
||||||
|
from zerver.lib.timestamp import datetime_to_timestamp
|
||||||
from zerver.lib.topic import TOPIC_NAME
|
from zerver.lib.topic import TOPIC_NAME
|
||||||
from zerver.lib.topic_mutes import get_topic_mutes
|
from zerver.lib.topic_mutes import get_topic_mutes
|
||||||
from zerver.lib.user_groups import user_groups_in_realm_serialized
|
from zerver.lib.user_groups import user_groups_in_realm_serialized
|
||||||
@@ -321,6 +322,10 @@ def fetch_initial_state_data(
|
|||||||
state["max_stream_description_length"] = Stream.MAX_DESCRIPTION_LENGTH
|
state["max_stream_description_length"] = Stream.MAX_DESCRIPTION_LENGTH
|
||||||
state["max_topic_length"] = MAX_TOPIC_NAME_LENGTH
|
state["max_topic_length"] = MAX_TOPIC_NAME_LENGTH
|
||||||
state["max_message_length"] = settings.MAX_MESSAGE_LENGTH
|
state["max_message_length"] = settings.MAX_MESSAGE_LENGTH
|
||||||
|
if realm.demo_organization_scheduled_deletion_date is not None:
|
||||||
|
state["demo_organization_scheduled_deletion_date"] = datetime_to_timestamp(
|
||||||
|
realm.demo_organization_scheduled_deletion_date
|
||||||
|
)
|
||||||
|
|
||||||
if want("realm_domains"):
|
if want("realm_domains"):
|
||||||
state["realm_domains"] = get_realm_domains(realm)
|
state["realm_domains"] = get_realm_domains(realm)
|
||||||
|
|||||||
@@ -8419,6 +8419,17 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
description: |
|
description: |
|
||||||
The name of the custom profile field type.
|
The name of the custom profile field type.
|
||||||
|
demo_organization_scheduled_deletion_date:
|
||||||
|
type: integer
|
||||||
|
description: |
|
||||||
|
Present if the realm is a demo organization.
|
||||||
|
|
||||||
|
The UNIX timestamp (UTC) when the demo organization will be
|
||||||
|
automatically deleted. Clients should use this to display a
|
||||||
|
prominent warning to the user that the organization will be
|
||||||
|
deleted at the indicated time.
|
||||||
|
|
||||||
|
**Changes**: New in Zulip 5.0 (feature level 94).
|
||||||
drafts:
|
drafts:
|
||||||
type: array
|
type: array
|
||||||
description: |
|
description: |
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import calendar
|
import calendar
|
||||||
|
import datetime
|
||||||
import urllib
|
import urllib
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@@ -272,6 +273,33 @@ class HomeTest(ZulipTestCase):
|
|||||||
realm_bots_actual_keys = sorted(str(key) for key in page_params["realm_bots"][0].keys())
|
realm_bots_actual_keys = sorted(str(key) for key in page_params["realm_bots"][0].keys())
|
||||||
self.assertEqual(realm_bots_actual_keys, realm_bots_expected_keys)
|
self.assertEqual(realm_bots_actual_keys, realm_bots_expected_keys)
|
||||||
|
|
||||||
|
def test_home_demo_organization(self) -> None:
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
|
||||||
|
# We construct a scheduled deletion date that's definitely in
|
||||||
|
# the future, regardless of how long ago the Zulip realm was
|
||||||
|
# created.
|
||||||
|
realm.demo_organization_scheduled_deletion_date = timezone_now() + datetime.timedelta(
|
||||||
|
days=1
|
||||||
|
)
|
||||||
|
realm.save()
|
||||||
|
self.login("hamlet")
|
||||||
|
|
||||||
|
# Verify succeeds once logged-in
|
||||||
|
flush_per_request_caches()
|
||||||
|
with queries_captured():
|
||||||
|
with patch("zerver.lib.cache.cache_set"):
|
||||||
|
result = self._get_home_page(stream="Denmark")
|
||||||
|
self.check_rendered_logged_in_app(result)
|
||||||
|
|
||||||
|
page_params = self._get_page_params(result)
|
||||||
|
actual_keys = sorted(str(k) for k in page_params.keys())
|
||||||
|
expected_keys = self.expected_page_params_keys + [
|
||||||
|
"demo_organization_scheduled_deletion_date"
|
||||||
|
]
|
||||||
|
|
||||||
|
self.assertEqual(set(actual_keys), set(expected_keys))
|
||||||
|
|
||||||
def test_logged_out_home(self) -> None:
|
def test_logged_out_home(self) -> None:
|
||||||
result = self.client_get("/")
|
result = self.client_get("/")
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|||||||
Reference in New Issue
Block a user