-
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2980 from CSDUMMI/upstream2
Complete Migrations of Bookwyrm Accounts across instances Merging this into `user-migration` branch to enable final work on this within the main Bookwyrm repository. We will pull in the final PR from there into `main` when ready. Thanks to @CSDUMMI and the crew for this huge job.
- Loading branch information
Showing
25 changed files
with
2,819 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Import data from Bookwyrm export files""" | ||
from bookwyrm import settings | ||
from bookwyrm.models.bookwyrm_import_job import BookwyrmImportJob | ||
|
||
|
||
class BookwyrmImporter: | ||
"""Import a Bookwyrm User export JSON file. | ||
This is kind of a combination of an importer and a connector. | ||
""" | ||
|
||
def process_import(self, user, archive_file, settings): | ||
"""import user data from a Bookwyrm export file""" | ||
|
||
required = [k for k in settings if settings.get(k) == "on"] | ||
|
||
job = BookwyrmImportJob.objects.create( | ||
user=user, archive_file=archive_file, required=required | ||
) | ||
return job |
165 changes: 165 additions & 0 deletions
165
bookwyrm/migrations/0179_bookwyrmexportjob_bookwyrmimportjob_childjob_parentjob.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
# Generated by Django 3.2.19 on 2023-08-31 22:57 | ||
|
||
from django.conf import settings | ||
import django.contrib.postgres.fields | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("bookwyrm", "0178_auto_20230328_2132"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="ParentJob", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("task_id", models.UUIDField(blank=True, null=True, unique=True)), | ||
( | ||
"created_date", | ||
models.DateTimeField(default=django.utils.timezone.now), | ||
), | ||
( | ||
"updated_date", | ||
models.DateTimeField(default=django.utils.timezone.now), | ||
), | ||
("complete", models.BooleanField(default=False)), | ||
( | ||
"status", | ||
models.CharField( | ||
choices=[ | ||
("pending", "Pending"), | ||
("active", "Active"), | ||
("complete", "Complete"), | ||
("stopped", "Stopped"), | ||
], | ||
default="pending", | ||
max_length=50, | ||
null=True, | ||
), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="BookwyrmExportJob", | ||
fields=[ | ||
( | ||
"parentjob_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="bookwyrm.parentjob", | ||
), | ||
), | ||
("export_data", models.FileField(null=True, upload_to="")), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
bases=("bookwyrm.parentjob",), | ||
), | ||
migrations.CreateModel( | ||
name="BookwyrmImportJob", | ||
fields=[ | ||
( | ||
"parentjob_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="bookwyrm.parentjob", | ||
), | ||
), | ||
("archive_file", models.FileField(blank=True, null=True, upload_to="")), | ||
("import_data", models.JSONField(null=True)), | ||
( | ||
"required", | ||
django.contrib.postgres.fields.ArrayField( | ||
base_field=models.CharField(blank=True, max_length=50), | ||
blank=True, | ||
size=None, | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
bases=("bookwyrm.parentjob",), | ||
), | ||
migrations.CreateModel( | ||
name="ChildJob", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("task_id", models.UUIDField(blank=True, null=True, unique=True)), | ||
( | ||
"created_date", | ||
models.DateTimeField(default=django.utils.timezone.now), | ||
), | ||
( | ||
"updated_date", | ||
models.DateTimeField(default=django.utils.timezone.now), | ||
), | ||
("complete", models.BooleanField(default=False)), | ||
( | ||
"status", | ||
models.CharField( | ||
choices=[ | ||
("pending", "Pending"), | ||
("active", "Active"), | ||
("complete", "Complete"), | ||
("stopped", "Stopped"), | ||
], | ||
default="pending", | ||
max_length=50, | ||
null=True, | ||
), | ||
), | ||
( | ||
"parent_job", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="child_jobs", | ||
to="bookwyrm.parentjob", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Generated by Django 3.2.19 on 2023-09-05 22:40 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("bookwyrm", "0179_bookwyrmexportjob_bookwyrmimportjob_childjob_parentjob"), | ||
("bookwyrm", "0181_merge_20230806_2302"), | ||
] | ||
|
||
operations = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.