-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- modified entity form and filter set for person - parler works but migrations are buggy; needed some editing - post_save signal to save translations/transliterations automatically ONLY on create - management command to transliterate all Person names - modified querysets for work and instances to show author name - according to the selected language - TODO: Use HistoryGenericTable and fix the bug accessing translated field there (currently using tables.table)
- Loading branch information
Showing
16 changed files
with
373 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.contrib import admin | ||
from parler.admin import TranslatableAdmin | ||
|
||
from .models import Person | ||
|
||
|
||
@admin.register(Person) | ||
class PersonAdmin(TranslatableAdmin): | ||
# TODO: allow editing the translations here? | ||
list_display = ["name", "all_languages_column"] | ||
pass |
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
26 changes: 26 additions & 0 deletions
26
apis_ontology/management/commands/support_tibetan_script_001.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 @@ | ||
import pyewts | ||
from django.core.management.base import BaseCommand | ||
from tqdm.auto import tqdm | ||
from apis_ontology.models import Person | ||
from tqdm.auto import tqdm | ||
|
||
TIBETAN = "es" | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "add Tibetan transliterations for Person - names" | ||
|
||
def handle(self, *args, **options): | ||
converter = pyewts.pyewts() | ||
|
||
for p in tqdm(Person.objects.all()): | ||
tibetan_name = converter.toUnicode(p.name_latin) | ||
p.set_current_language(TIBETAN) | ||
p.name = tibetan_name | ||
p.save() | ||
|
||
self.stdout.write( | ||
self.style.SUCCESS( | ||
f"{len(Person.objects.all())} names were successfully transliterated into Tibetan." | ||
) | ||
) |
Empty file.
74 changes: 74 additions & 0 deletions
74
apis_ontology/migrations/0032_rename_name_person_name_latin_and_more.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,74 @@ | ||
# Generated by Django 5.1.3 on 2024-11-17 00:11 | ||
|
||
import django.db.models.deletion | ||
import parler.fields | ||
import parler.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("apis_ontology", "0031_versioninstancecopiedwrittendownatplace_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name="person", | ||
old_name="name", | ||
new_name="name_latin", | ||
), | ||
migrations.RenameField( | ||
model_name="versionperson", | ||
old_name="name", | ||
new_name="name_latin", | ||
), | ||
migrations.CreateModel( | ||
name="PersonTranslation", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"language_code", | ||
models.CharField( | ||
db_index=True, max_length=15, verbose_name="Language" | ||
), | ||
), | ||
( | ||
"name", | ||
models.CharField( | ||
blank=True, default="", max_length=255, verbose_name="Name" | ||
), | ||
), | ||
( | ||
"master", | ||
parler.fields.TranslationsForeignKey( | ||
editable=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="translations", | ||
to="apis_ontology.person", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "person Translation", | ||
"db_table": "apis_ontology_person_translation", | ||
"db_tablespace": "", | ||
"managed": True, | ||
"default_permissions": (), | ||
"unique_together": {("language_code", "master")}, | ||
}, | ||
bases=(parler.models.TranslatableModel, models.Model), | ||
), | ||
migrations.RunSQL( | ||
"INSERT INTO apis_ontology_person_translation(language_code, name , master_id) SELECT 'en', name_latin, rootobject_ptr_id FROM apis_ontology_person;" | ||
), | ||
] |
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,5 @@ | ||
from parler.managers import TranslatableQuerySet | ||
|
||
|
||
class PersonQuerySet(TranslatableQuerySet): | ||
pass |
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.