From ba5ec878fab314f255dc31da1fcb4c7fc443c4a9 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 6 Oct 2021 12:19:52 -0700 Subject: [PATCH] Adds language preference to database --- .../0106_user_preferred_language.py | 30 +++++++++++++++++++ bookwyrm/models/user.py | 8 ++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 bookwyrm/migrations/0106_user_preferred_language.py diff --git a/bookwyrm/migrations/0106_user_preferred_language.py b/bookwyrm/migrations/0106_user_preferred_language.py new file mode 100644 index 000000000..a77030a05 --- /dev/null +++ b/bookwyrm/migrations/0106_user_preferred_language.py @@ -0,0 +1,30 @@ +# Generated by Django 3.2.5 on 2021-10-06 19:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0105_alter_connector_connector_file"), + ] + + operations = [ + migrations.AddField( + model_name="user", + name="preferred_language", + field=models.CharField( + blank=True, + choices=[ + ("en-us", "English"), + ("de-de", "German"), + ("es", "Spanish"), + ("fr-fr", "French"), + ("zh-hans", "Simplified Chinese"), + ("zh-hant", "Traditional Chinese"), + ], + max_length=255, + null=True, + ), + ), + ] diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 637baa6ee..d7945843f 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -17,7 +17,7 @@ from bookwyrm.connectors import get_data, ConnectorException from bookwyrm.models.shelf import Shelf from bookwyrm.models.status import Status, Review from bookwyrm.preview_images import generate_user_preview_image_task -from bookwyrm.settings import DOMAIN, ENABLE_PREVIEW_IMAGES, USE_HTTPS +from bookwyrm.settings import DOMAIN, ENABLE_PREVIEW_IMAGES, USE_HTTPS, LANGUAGES from bookwyrm.signatures import create_key_pair from bookwyrm.tasks import app from bookwyrm.utils import regex @@ -133,6 +133,12 @@ class User(OrderedCollectionPageMixin, AbstractUser): default=str(pytz.utc), max_length=255, ) + preferred_language = models.CharField( + choices=LANGUAGES, + null=True, + blank=True, + max_length=255, + ) deactivation_reason = models.CharField( max_length=255, choices=DeactivationReason, null=True, blank=True )