-
Notifications
You must be signed in to change notification settings - Fork 11
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 #625 from projectcaluma/fix-document-model
fix!: make document title and description not localized
- Loading branch information
Showing
11 changed files
with
147 additions
and
166 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
22 changes: 22 additions & 0 deletions
22
alexandria/core/management/commands/migrate_document_title_and_description.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,22 @@ | ||
from django.core.management.base import BaseCommand | ||
from pghstore import loads | ||
from tqdm import tqdm | ||
|
||
from alexandria.core.models import Document | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Migrate document title and description from localized to unlocalized." | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument("source_language") | ||
|
||
def handle(self, *args, **options): | ||
source_language = options["source_language"] | ||
for document in tqdm(Document.objects.all()): | ||
try: | ||
document.title = loads(document.title)[source_language] | ||
document.description = loads(document.description)[source_language] | ||
document.save() | ||
except ValueError: | ||
pass |
26 changes: 26 additions & 0 deletions
26
alexandria/core/migrations/0018_alter_document_description_alter_document_title.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,26 @@ | ||
# Generated by Django 4.2.15 on 2024-08-29 07:51 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("alexandria_core", "0017_file_vector"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="document", | ||
name="description", | ||
field=models.TextField( | ||
blank=True, null=True, verbose_name="document description" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="document", | ||
name="title", | ||
field=models.CharField( | ||
blank=True, null=True, verbose_name="document title" | ||
), | ||
), | ||
] |
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
202 changes: 57 additions & 145 deletions
202
alexandria/core/tests/__snapshots__/test_viewsets.ambr
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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