mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
Adds deactivation date to user model
Also fixes django admin around saved lists
This commit is contained in:
parent
84b90db4bb
commit
430554444f
2 changed files with 41 additions and 1 deletions
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),
|
||||||
|
]
|
|
@ -105,7 +105,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
related_name="blocked_by",
|
related_name="blocked_by",
|
||||||
)
|
)
|
||||||
saved_lists = models.ManyToManyField(
|
saved_lists = models.ManyToManyField(
|
||||||
"List", symmetrical=False, related_name="saved_lists"
|
"List", symmetrical=False, related_name="saved_lists", blank=True
|
||||||
)
|
)
|
||||||
favorites = models.ManyToManyField(
|
favorites = models.ManyToManyField(
|
||||||
"Status",
|
"Status",
|
||||||
|
@ -136,6 +136,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
deactivation_reason = models.CharField(
|
deactivation_reason = models.CharField(
|
||||||
max_length=255, choices=DeactivationReason.choices, null=True, blank=True
|
max_length=255, choices=DeactivationReason.choices, null=True, blank=True
|
||||||
)
|
)
|
||||||
|
deactivation_date = models.DateTimeField(null=True, blank=True)
|
||||||
confirmation_code = models.CharField(max_length=32, default=new_access_code)
|
confirmation_code = models.CharField(max_length=32, default=new_access_code)
|
||||||
|
|
||||||
name_field = "username"
|
name_field = "username"
|
||||||
|
|
Loading…
Reference in a new issue