74 lines
2.2 KiB
Python
74 lines
2.2 KiB
Python
|
# Generated by Django 3.2.12 on 2022-02-26 20:24
|
||
|
|
||
|
import django.core.validators
|
||
|
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")
|
||
|
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",
|
||
|
),
|
||
|
]
|
||
|
)
|
||
|
|
||
|
|
||
|
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)),
|
||
|
("name", models.CharField(max_length=10, unique=True)),
|
||
|
(
|
||
|
"theme_file",
|
||
|
models.FileField(
|
||
|
upload_to="css/",
|
||
|
validators=[
|
||
|
django.core.validators.FileExtensionValidator(
|
||
|
["scss", "sass"]
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
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",
|
||
|
),
|
||
|
),
|
||
|
migrations.RunPython(
|
||
|
add_default_themes, reversed_code=migrations.RunPython.noop
|
||
|
),
|
||
|
]
|