From 00df8a593d3abfe127369f15ba9457b1009ef48e Mon Sep 17 00:00:00 2001 From: Kislay Verma Date: Fri, 14 Jun 2024 00:10:05 +0530 Subject: [PATCH] user_settings: Add field `web_suggest_update_timezone`. This field tracks whether the user should be shown an alert offering to update their profile time zone to the time zone of the browser in case they differ. The field is added to RealmUserDefault and UserProfile models with a default value of True. Fixes part of #16957 --- api_docs/changelog.md | 8 ++++ version.py | 2 +- web/src/user_settings.ts | 1 + .../0641_web_suggest_update_time_zone.py | 22 ++++++++++ zerver/models/users.py | 2 + zerver/openapi/zulip.yaml | 41 +++++++++++++++++++ zerver/views/realm.py | 1 + zerver/views/user_settings.py | 1 + 8 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 zerver/migrations/0641_web_suggest_update_time_zone.py diff --git a/api_docs/changelog.md b/api_docs/changelog.md index e695b66bab..e58229f043 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -20,6 +20,14 @@ format used by the Zulip server that they are interacting with. ## Changes in Zulip 10.0 +**Feature level 329** + +* [`PATCH /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults), + [`POST /register`](/api/register-queue), [`PATCH /settings`](/api/update-settings): + Added new `web_suggest_update_timezone` option to decide whether the user should be + shown an alert offering to update their profile time zone to the time zone of the + browser in case they differ. + **Feature level 328** * [`GET /messages`](/api/get-messages), [`GET /events`](/api/get-events): diff --git a/version.py b/version.py index 88c00389fd..ce03df69b3 100644 --- a/version.py +++ b/version.py @@ -34,7 +34,7 @@ DESKTOP_WARNING_VERSION = "5.9.3" # new level means in api_docs/changelog.md, as well as "**Changes**" # entries in the endpoint's documentation in `zulip.yaml`. -API_FEATURE_LEVEL = 328 # Last bumped for removing `user` dictionary from `reactions` object. +API_FEATURE_LEVEL = 329 # Last bumped for adding field web_suggest_update_timezone # 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/web/src/user_settings.ts b/web/src/user_settings.ts index ced203991e..f3cb097489 100644 --- a/web/src/user_settings.ts +++ b/web/src/user_settings.ts @@ -81,6 +81,7 @@ export const user_settings_schema = stream_notification_settings_schema web_mark_read_on_scroll_policy: z.number(), web_navigate_to_sent_message: z.boolean(), web_stream_unreads_count_display_policy: z.number(), + web_suggest_update_timezone: z.boolean(), }); export type UserSettings = z.infer; diff --git a/zerver/migrations/0641_web_suggest_update_time_zone.py b/zerver/migrations/0641_web_suggest_update_time_zone.py new file mode 100644 index 0000000000..06758228c7 --- /dev/null +++ b/zerver/migrations/0641_web_suggest_update_time_zone.py @@ -0,0 +1,22 @@ +# Generated by Django 5.0.6 on 2024-06-13 18:35 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("zerver", "0640_merge_20241211_1953"), + ] + + operations = [ + migrations.AddField( + model_name="realmuserdefault", + name="web_suggest_update_timezone", + field=models.BooleanField(default=True), + ), + migrations.AddField( + model_name="userprofile", + name="web_suggest_update_timezone", + field=models.BooleanField(default=True), + ), + ] diff --git a/zerver/models/users.py b/zerver/models/users.py index 443acc968d..a4f1657a58 100644 --- a/zerver/models/users.py +++ b/zerver/models/users.py @@ -68,6 +68,7 @@ class UserBaseSettings(models.Model): display_emoji_reaction_users = models.BooleanField(default=True) twenty_four_hour_time = models.BooleanField(default=False) starred_message_counts = models.BooleanField(default=True) + web_suggest_update_timezone = models.BooleanField(default=True) COLOR_SCHEME_AUTOMATIC = 1 COLOR_SCHEME_DARK = 2 COLOR_SCHEME_LIGHT = 3 @@ -357,6 +358,7 @@ class UserBaseSettings(models.Model): web_font_size_px=int, web_line_height_percent=int, web_navigate_to_sent_message=bool, + web_suggest_update_timezone=bool, ) modern_notification_settings: dict[str, Any] = dict( diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 068fff884b..13280c64d7 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -11863,6 +11863,14 @@ paths: only options to disable sending typing notifications. type: boolean example: true + web_suggest_update_timezone: + description: | + Whether the user should be shown an alert offering to update their profile time zone + to the time zone of the browser in case they differ. + + **Changes**: New in Zulip 10.0 (feature level 329). + type: boolean + example: true fluid_layout_width: description: | Whether to use the [maximum available screen width](/help/enable-full-width-display) @@ -12353,6 +12361,8 @@ paths: contentType: application/json receives_typing_notifications: contentType: application/json + web_suggest_update_timezone: + contentType: application/json fluid_layout_width: contentType: application/json high_contrast_mode: @@ -15197,6 +15207,13 @@ paths: **Changes**: New in Zulip 9.0 (feature level 253). Previously, there were only options to disable sending typing notifications. + web_suggest_update_timezone: + type: boolean + description: | + Whether the user should be shown an alert offering to update their profile time zone + to the time zone of the browser in case they differ. + + **Changes**: New in Zulip 10.0 (feature level 329). fluid_layout_width: type: boolean description: | @@ -16305,6 +16322,13 @@ paths: **Changes**: New in Zulip 9.0 (feature level 253). Previously, there were only options to disable sending typing notifications. + web_suggest_update_timezone: + type: boolean + description: | + Whether the user should be shown an alert offering to update their profile time zone + to the time zone of the browser in case they differ. + + **Changes**: New in Zulip 10.0 (feature level 329). enter_sends: deprecated: true type: boolean @@ -17721,6 +17745,13 @@ paths: **Changes**: New in Zulip 9.0 (feature level 253). Previously, there were only options to disable sending typing notifications. + web_suggest_update_timezone: + type: boolean + description: | + Whether the user should be shown an alert offering to update their profile time zone + to the time zone of the browser in case they differ. + + **Changes**: New in Zulip 10.0 (feature level 329). fluid_layout_width: type: boolean description: | @@ -18876,6 +18907,14 @@ paths: options to disable sending typing notifications. type: boolean example: true + web_suggest_update_timezone: + type: boolean + description: | + Whether the user should be shown an alert offering to update their profile time zone + to the time zone of the browser in case they differ. + + **Changes**: New in Zulip 10.0 (feature level 329). + example: true fluid_layout_width: description: | Whether to use the [maximum available screen width](/help/enable-full-width-display) @@ -19467,6 +19506,8 @@ paths: contentType: application/json receives_typing_notifications: contentType: application/json + web_suggest_update_timezone: + contentType: application/json fluid_layout_width: contentType: application/json high_contrast_mode: diff --git a/zerver/views/realm.py b/zerver/views/realm.py index 4d9bfca488..fcb9afbde5 100644 --- a/zerver/views/realm.py +++ b/zerver/views/realm.py @@ -632,6 +632,7 @@ def update_realm_user_settings_defaults( ] | None = None, web_navigate_to_sent_message: Json[bool] | None = None, + web_suggest_update_timezone: Json[bool] | None = None, ) -> HttpResponse: if notification_sound is not None or email_notifications_batching_period_seconds is not None: check_settings_values(notification_sound, email_notifications_batching_period_seconds) diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index 5c1319536a..8fba459ab2 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -328,6 +328,7 @@ def json_change_settings( ] | None = None, web_navigate_to_sent_message: Json[bool] | None = None, + web_suggest_update_timezone: Json[bool] | None = None, ) -> HttpResponse: # UserProfile object is being refetched here to make sure that we # do not use stale object from cache which can happen when a