Adds deactivation date to user model
Also fixes django admin around saved lists
This commit is contained in:
39
bookwyrm/migrations/0094_auto_20210911_1550.py
Normal file
39
bookwyrm/migrations/0094_auto_20210911_1550.py
Normal file
@ -0,0 +1,39 @@
|
||||
# Generated by Django 3.2.4 on 2021-09-11 15:50
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.db.models import F, Value, CharField
|
||||
|
||||
|
||||
def set_deactivate_date(apps, schema_editor):
|
||||
"""best-guess for deactivation date"""
|
||||
db_alias = schema_editor.connection.alias
|
||||
apps.get_model("bookwyrm", "User").objects.using(db_alias).filter(
|
||||
is_active=False
|
||||
).update(deactivation_date=models.F("last_active_date"))
|
||||
|
||||
|
||||
def reverse_func(apps, schema_editor):
|
||||
"""noop"""
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bookwyrm", "0093_alter_sitesettings_instance_short_description"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="user",
|
||||
name="deactivation_date",
|
||||
field=models.DateTimeField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="user",
|
||||
name="saved_lists",
|
||||
field=models.ManyToManyField(
|
||||
blank=True, related_name="saved_lists", to="bookwyrm.List"
|
||||
),
|
||||
),
|
||||
migrations.RunPython(set_deactivate_date, reverse_func),
|
||||
]
|
Reference in New Issue
Block a user