settings: Migrate twenty_four_hour_time setting to RealmUserDefault.

This commit removes the existing default_twenty_four_hour_time field in
Realm table which was used to set the twenty_four_hour_time setting of
new user on joining and instead we now use the twenty_four_hour_time
field of RealmUserDefault table for the same.

With some tweaks by tabbott to clarify the documentation.
This commit is contained in:
Sahil Batra
2021-09-17 21:41:37 +05:30
committed by Tim Abbott
parent 0ef5cb4813
commit c233ee9935
22 changed files with 123 additions and 80 deletions

View File

@@ -29,9 +29,7 @@ def copy_default_settings(
#
# Note that this function will do at least one save() on target_profile.
for settings_name in UserBaseSettings.property_types:
if settings_name in ["default_language", "twenty_four_hour_time"] and isinstance(
settings_source, RealmUserDefault
):
if settings_name == "default_language" and isinstance(settings_source, RealmUserDefault):
continue
value = getattr(settings_source, settings_name)
setattr(target_profile, settings_name, value)
@@ -110,7 +108,6 @@ def create_user_profile(
enter_sends=enter_sends,
onboarding_steps=orjson.dumps([]).decode(),
default_language=realm.default_language,
twenty_four_hour_time=realm.default_twenty_four_hour_time,
delivery_email=email,
**extra_kwargs,
)