Import von authors.yml verbessert
- möglichst aktualisieren statt neu anlegen - "inherits" legt zweite Identität am Original an
This commit is contained in:
@@ -21,6 +21,7 @@ Wir entwickeln auf Python 3.14. Python 3.12+ funktioniert, ältere haben zuminde
|
||||
|
||||
- Datenbank (SQLite) anlegen: `python3 manage.py makemigrations quellen; python3 manage.py migrate`
|
||||
- Admin anlegen: `python3 manage.py createsuperuser`
|
||||
- ggf. Liederquelle-Daten laden: `python3 manage.py loaddata ../fixtures/fixture.yaml`
|
||||
- Server starten: `python3 manage.py runserver`
|
||||
- Öffne http://localhost:8080/admin im Browser
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
Import für `authors.yml` aus `lilypond-song-includes`
|
||||
|
||||
TODO:
|
||||
- inherits (sollte 2. Identität für eine Person anlegen)
|
||||
- details_secret
|
||||
- aktualisieren statt neu anlegen
|
||||
- Import direkt aus dem git
|
||||
- Keine Lösung für trail_name_native_spelling (sehr selten)
|
||||
- Tags
|
||||
@@ -59,35 +57,49 @@ class Command(BaseCommand):
|
||||
author.update(data[key])
|
||||
if not author['name'] and author['trail_name']:
|
||||
author['name'] = author['trail_name']
|
||||
p = Person(
|
||||
name = author['name'],
|
||||
full_name = author['full_name'],
|
||||
name_native = author['name_native_spelling'],
|
||||
birth_name = author['birth_name'],
|
||||
details_secret = False,
|
||||
birth_year = author['birth_year'],
|
||||
death_year = author['death_year'],
|
||||
remarks = author['comment'],
|
||||
)
|
||||
p.save()
|
||||
pi = Identity(
|
||||
if 'inherits' in author:
|
||||
self.stdout.write('\terbt von %s' % author['inherits'])
|
||||
oi = Identity.objects.get(author_id = author['inherits'])
|
||||
orig = data[author['inherits']]
|
||||
p = oi.person
|
||||
for akey in self.default_author.keys():
|
||||
if not author[akey] and akey in orig:
|
||||
author[akey] = orig[akey]
|
||||
else:
|
||||
try:
|
||||
p, created = Person.objects.update_or_create(
|
||||
name = author['name'],
|
||||
full_name = author['full_name'],
|
||||
name_native = author['name_native_spelling'],
|
||||
birth_name = author['birth_name'],
|
||||
details_secret = False,
|
||||
birth_year = author['birth_year'],
|
||||
death_year = author['death_year'],
|
||||
remarks = author['comment'],
|
||||
)
|
||||
except Person.MultipleObjectsReturned as e:
|
||||
ps = Person.objects.filter(name = author['name'])
|
||||
self.stdout.write("\tist doppelt:")
|
||||
self.stdout.write(str(author))
|
||||
self.stdout.write(str(ps))
|
||||
p = ps[0]
|
||||
#raise e
|
||||
pi, created = Identity.objects.update_or_create(
|
||||
person = p,
|
||||
author_id = key,
|
||||
alias = author['trail_name'],
|
||||
organization = author['organization'],
|
||||
)
|
||||
pi.save()
|
||||
for service in 'gnd isni orcid viaf wiki discogs lied brainz'.split():
|
||||
dbkey = service
|
||||
if service=='wiki':
|
||||
dbkey = 'wikidata'
|
||||
if dbkey in author and author[dbkey]:
|
||||
pai = AuthorID(
|
||||
pai, created = AuthorID.objects.update_or_create(
|
||||
person = p,
|
||||
key = AuthorID.IDs.__dict__[service.upper()],
|
||||
value = author[dbkey],
|
||||
)
|
||||
pai.save()
|
||||
|
||||
|
||||
# for poll_id in options["poll_ids"]:
|
||||
|
||||
Reference in New Issue
Block a user