mirror of https://github.com/zulip/zulip.git
zcommand: Rename night->dark and day->light in the color scheme backend.
As a follow up forf49a11c810
, this commit standardizes the naming of the day and night themes to light and dark, respectively in the backend. This makes the backend consistent with the naming used in the frontend and UI. This also solves a regression introduced inf49a11c810
, where the frontend was sending "/light" and "/dark" commands to the backend, but the backend was expecting "/day" and "/night" commands.
This commit is contained in:
parent
12b367cc74
commit
073b116c55
|
@ -26,18 +26,18 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
|
|||
|
||||
if command == "ping":
|
||||
return {}
|
||||
elif command == "night":
|
||||
if user_profile.color_scheme == UserProfile.COLOR_SCHEME_NIGHT:
|
||||
elif command == "dark":
|
||||
if user_profile.color_scheme == UserProfile.COLOR_SCHEME_DARK:
|
||||
return dict(msg="You are still in dark theme.")
|
||||
return dict(
|
||||
msg=change_mode_setting(
|
||||
setting_name="dark theme",
|
||||
switch_command="light",
|
||||
setting="color_scheme",
|
||||
setting_value=UserProfile.COLOR_SCHEME_NIGHT,
|
||||
setting_value=UserProfile.COLOR_SCHEME_DARK,
|
||||
)
|
||||
)
|
||||
elif command == "day":
|
||||
elif command == "light":
|
||||
if user_profile.color_scheme == UserProfile.COLOR_SCHEME_LIGHT:
|
||||
return dict(msg="You are still in light theme.")
|
||||
return dict(
|
||||
|
|
|
@ -73,9 +73,9 @@ class UserBaseSettings(models.Model):
|
|||
twenty_four_hour_time = models.BooleanField(default=False)
|
||||
starred_message_counts = models.BooleanField(default=True)
|
||||
COLOR_SCHEME_AUTOMATIC = 1
|
||||
COLOR_SCHEME_NIGHT = 2
|
||||
COLOR_SCHEME_DARK = 2
|
||||
COLOR_SCHEME_LIGHT = 3
|
||||
COLOR_SCHEME_CHOICES = [COLOR_SCHEME_AUTOMATIC, COLOR_SCHEME_NIGHT, COLOR_SCHEME_LIGHT]
|
||||
COLOR_SCHEME_CHOICES = [COLOR_SCHEME_AUTOMATIC, COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT]
|
||||
color_scheme = models.PositiveSmallIntegerField(default=COLOR_SCHEME_AUTOMATIC)
|
||||
|
||||
# Information density is established through
|
||||
|
|
|
@ -474,11 +474,11 @@ class ChangeSettingsTest(ZulipTestCase):
|
|||
self.login("hamlet")
|
||||
|
||||
result = self.client_patch(
|
||||
"/json/settings/display", dict(color_scheme=UserProfile.COLOR_SCHEME_NIGHT)
|
||||
"/json/settings/display", dict(color_scheme=UserProfile.COLOR_SCHEME_DARK)
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
hamlet = self.example_user("hamlet")
|
||||
self.assertEqual(hamlet.color_scheme, UserProfile.COLOR_SCHEME_NIGHT)
|
||||
self.assertEqual(hamlet.color_scheme, UserProfile.COLOR_SCHEME_DARK)
|
||||
|
||||
def test_changing_setting_using_notification_setting_endpoint(self) -> None:
|
||||
"""
|
||||
|
|
|
@ -1298,7 +1298,7 @@ class UserProfileTest(ZulipTestCase):
|
|||
do_change_user_setting(cordelia, "emojiset", "twitter", acting_user=None)
|
||||
do_change_user_setting(cordelia, "timezone", "America/Phoenix", acting_user=None)
|
||||
do_change_user_setting(
|
||||
cordelia, "color_scheme", UserProfile.COLOR_SCHEME_NIGHT, acting_user=None
|
||||
cordelia, "color_scheme", UserProfile.COLOR_SCHEME_DARK, acting_user=None
|
||||
)
|
||||
do_change_user_setting(
|
||||
cordelia, "enable_offline_email_notifications", False, acting_user=None
|
||||
|
@ -1342,8 +1342,8 @@ class UserProfileTest(ZulipTestCase):
|
|||
self.assertEqual(cordelia.timezone, "America/Phoenix")
|
||||
self.assertEqual(hamlet.timezone, "")
|
||||
|
||||
self.assertEqual(iago.color_scheme, UserProfile.COLOR_SCHEME_NIGHT)
|
||||
self.assertEqual(cordelia.color_scheme, UserProfile.COLOR_SCHEME_NIGHT)
|
||||
self.assertEqual(iago.color_scheme, UserProfile.COLOR_SCHEME_DARK)
|
||||
self.assertEqual(cordelia.color_scheme, UserProfile.COLOR_SCHEME_DARK)
|
||||
self.assertEqual(hamlet.color_scheme, UserProfile.COLOR_SCHEME_AUTOMATIC)
|
||||
|
||||
self.assertEqual(iago.enable_offline_email_notifications, False)
|
||||
|
|
|
@ -27,7 +27,7 @@ class ZcommandTest(ZulipTestCase):
|
|||
user.color_scheme = UserProfile.COLOR_SCHEME_LIGHT
|
||||
user.save()
|
||||
|
||||
payload = dict(command="/night")
|
||||
payload = dict(command="/dark")
|
||||
result = self.client_post("/json/zcommand", payload)
|
||||
response_dict = self.assert_json_success(result)
|
||||
self.assertIn("Changed to dark theme", response_dict["msg"])
|
||||
|
@ -39,10 +39,10 @@ class ZcommandTest(ZulipTestCase):
|
|||
def test_day_zcommand(self) -> None:
|
||||
self.login("hamlet")
|
||||
user = self.example_user("hamlet")
|
||||
user.color_scheme = UserProfile.COLOR_SCHEME_NIGHT
|
||||
user.color_scheme = UserProfile.COLOR_SCHEME_DARK
|
||||
user.save()
|
||||
|
||||
payload = dict(command="/day")
|
||||
payload = dict(command="/light")
|
||||
result = self.client_post("/json/zcommand", payload)
|
||||
response_dict = self.assert_json_success(result)
|
||||
self.assertIn("Changed to light theme", response_dict["msg"])
|
||||
|
|
Loading…
Reference in New Issue