moviewyrm/bookwyrm/migrations/0142_auto_20220227_1752.py

69 lines
2 KiB
Python
Raw Permalink Normal View History

2022-02-27 18:00:50 +00:00
# Generated by Django 3.2.12 on 2022-02-27 17:52
2022-02-26 20:43:27 +00:00
from django.db import migrations, models
import django.db.models.deletion
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")
2022-02-26 21:38:45 +00:00
theme_model.objects.using(db_alias).create(
name="BookWyrm Light",
2022-02-27 18:46:01 +00:00
path="css/themes/bookwyrm-light.scss",
2022-02-26 21:38:45 +00:00
)
theme_model.objects.using(db_alias).create(
name="BookWyrm Dark",
2022-02-27 18:46:01 +00:00
path="css/themes/bookwyrm-dark.scss",
2022-02-26 20:43:27 +00:00
)
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0141_alter_report_status"),
]
operations = [
migrations.CreateModel(
name="Theme",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_date", models.DateTimeField(auto_now_add=True)),
2022-02-26 21:38:45 +00:00
("name", models.CharField(max_length=50, unique=True)),
2022-02-27 18:00:50 +00:00
("path", models.CharField(max_length=50, unique=True)),
2022-02-26 20:43:27 +00:00
],
),
migrations.AddField(
model_name="sitesettings",
name="default_theme",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="bookwyrm.theme",
),
),
2022-02-26 21:38:45 +00:00
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",
),
),
2022-02-26 20:43:27 +00:00
migrations.RunPython(
2022-02-26 21:38:45 +00:00
add_default_themes, reverse_code=migrations.RunPython.noop
2022-02-26 20:43:27 +00:00
),
]