Makes shelbook user required
This commit is contained in:
30
bookwyrm/migrations/0044_auto_20210207_1924.py
Normal file
30
bookwyrm/migrations/0044_auto_20210207_1924.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Generated by Django 3.0.7 on 2021-02-07 19:24
|
||||
|
||||
import bookwyrm.models.fields
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
import django.db.models.deletion
|
||||
|
||||
def set_user(app_registry, schema_editor):
|
||||
db_alias = schema_editor.connection.alias
|
||||
shelfbook = app_registry.get_model('bookwyrm', 'ShelfBook')
|
||||
for item in shelfbook.objects.using(db_alias).filter(user__isnull=True):
|
||||
item.user = item.shelf.user
|
||||
item.save(broadcast=False)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bookwyrm', '0043_auto_20210204_2223'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(set_user),
|
||||
migrations.AlterField(
|
||||
model_name='shelfbook',
|
||||
name='user',
|
||||
field=bookwyrm.models.fields.ForeignKey(default=2, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user