moviewyrm/bookwyrm/migrations/0017_auto_20201130_1819.py

302 lines
10 KiB
Python
Raw Permalink Normal View History

2020-11-30 18:32:13 +00:00
# Generated by Django 3.0.7 on 2020-11-30 18:19
import bookwyrm.models.activitypub_mixin
2020-11-30 18:32:13 +00:00
import bookwyrm.models.fields
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
2021-03-08 16:49:10 +00:00
2020-11-30 18:32:13 +00:00
def copy_rsa_keys(app_registry, schema_editor):
db_alias = schema_editor.connection.alias
2021-03-08 16:49:10 +00:00
users = app_registry.get_model("bookwyrm", "User")
keypair = app_registry.get_model("bookwyrm", "KeyPair")
2020-11-30 18:32:13 +00:00
for user in users.objects.using(db_alias):
if user.public_key or user.private_key:
user.key_pair = keypair.objects.create(
2021-03-08 16:49:10 +00:00
remote_id="%s/#main-key" % user.remote_id,
2020-11-30 18:32:13 +00:00
private_key=user.private_key,
2021-03-08 16:49:10 +00:00
public_key=user.public_key,
2020-11-30 18:32:13 +00:00
)
user.save()
2021-03-08 16:49:10 +00:00
2020-11-30 18:32:13 +00:00
class Migration(migrations.Migration):
dependencies = [
2021-03-08 16:49:10 +00:00
("bookwyrm", "0016_auto_20201129_0304"),
2020-11-30 18:32:13 +00:00
]
operations = [
migrations.CreateModel(
2021-03-08 16:49:10 +00:00
name="KeyPair",
2020-11-30 18:32:13 +00:00
fields=[
2021-03-08 16:49:10 +00:00
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_date", models.DateTimeField(auto_now_add=True)),
("updated_date", models.DateTimeField(auto_now=True)),
(
"remote_id",
bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
),
("private_key", models.TextField(blank=True, null=True)),
("public_key", bookwyrm.models.fields.TextField(blank=True, null=True)),
2020-11-30 18:32:13 +00:00
],
options={
2021-03-08 16:49:10 +00:00
"abstract": False,
2020-11-30 18:32:13 +00:00
},
bases=(bookwyrm.models.activitypub_mixin.ActivitypubMixin, models.Model),
2020-11-30 18:32:13 +00:00
),
migrations.AddField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="followers",
field=bookwyrm.models.fields.ManyToManyField(
related_name="following",
through="bookwyrm.UserFollows",
to=settings.AUTH_USER_MODEL,
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="author",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="book",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="connector",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="favorite",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="federatedserver",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="image",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="notification",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="readthrough",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="shelf",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="shelfbook",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="status",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="tag",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="avatar",
field=bookwyrm.models.fields.ImageField(
blank=True, null=True, upload_to="avatars/"
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="bookwyrm_user",
2020-11-30 18:32:13 +00:00
field=bookwyrm.models.fields.BooleanField(default=True),
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="inbox",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
unique=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="local",
2020-11-30 18:32:13 +00:00
field=models.BooleanField(default=False),
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="manually_approves_followers",
2020-11-30 18:32:13 +00:00
field=bookwyrm.models.fields.BooleanField(default=False),
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="name",
field=bookwyrm.models.fields.CharField(
blank=True, max_length=100, null=True
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="outbox",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
unique=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
unique=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="shared_inbox",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="summary",
2020-11-30 18:32:13 +00:00
field=bookwyrm.models.fields.TextField(blank=True, null=True),
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="username",
2020-11-30 18:32:13 +00:00
field=bookwyrm.models.fields.UsernameField(),
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="userblocks",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="userfollowrequest",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="userfollows",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AlterField(
2021-03-08 16:49:10 +00:00
model_name="usertag",
name="remote_id",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
2020-11-30 18:32:13 +00:00
),
migrations.AddField(
2021-03-08 16:49:10 +00:00
model_name="user",
name="key_pair",
field=bookwyrm.models.fields.OneToOneField(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="owner",
to="bookwyrm.KeyPair",
),
2020-11-30 18:32:13 +00:00
),
migrations.RunPython(copy_rsa_keys),
]