Use selected theme

This commit is contained in:
Mouse Reeve
2022-02-26 13:38:45 -08:00
parent e15193e100
commit 43269429ac
6 changed files with 50 additions and 26 deletions

View File

@ -1,4 +1,4 @@
# Generated by Django 3.2.12 on 2022-02-26 20:24
# Generated by Django 3.2.12 on 2022-02-26 20:47
import django.core.validators
from django.db import migrations, models
@ -9,17 +9,13 @@ def add_default_themes(apps, schema_editor):
"""add light and dark themes"""
db_alias = schema_editor.connection.alias
theme_model = apps.get_model("bookwyrm", "Theme")
theme_model.objects.using(db_alias).bulk_create(
[
theme_model.objects.using(db_alias)(
name="BookWyrm Light",
path="bookwyrm-light.scss",
),
theme_model.objects.using(db_alias)(
name="BookWyrm Dark",
path="bookwyrm-dark.scss",
),
]
theme_model.objects.using(db_alias).create(
name="BookWyrm Light",
path="bookwyrm-light.scss",
)
theme_model.objects.using(db_alias).create(
name="BookWyrm Dark",
path="bookwyrm-dark.scss",
)
@ -43,10 +39,11 @@ class Migration(migrations.Migration):
),
),
("created_date", models.DateTimeField(auto_now_add=True)),
("name", models.CharField(max_length=10, unique=True)),
("name", models.CharField(max_length=50, unique=True)),
(
"theme_file",
models.FileField(
null=True,
upload_to="css/",
validators=[
django.core.validators.FileExtensionValidator(
@ -55,6 +52,7 @@ class Migration(migrations.Migration):
],
),
),
("path", models.CharField(blank=True, max_length=50, null=True)),
],
),
migrations.AddField(
@ -67,7 +65,17 @@ class Migration(migrations.Migration):
to="bookwyrm.theme",
),
),
migrations.AddField(
model_name="user",
name="theme",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="bookwyrm.theme",
),
),
migrations.RunPython(
add_default_themes, reversed_code=migrations.RunPython.noop
add_default_themes, reverse_code=migrations.RunPython.noop
),
]