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`
|
- Datenbank (SQLite) anlegen: `python3 manage.py makemigrations quellen; python3 manage.py migrate`
|
||||||
- Admin anlegen: `python3 manage.py createsuperuser`
|
- Admin anlegen: `python3 manage.py createsuperuser`
|
||||||
|
- ggf. Liederquelle-Daten laden: `python3 manage.py loaddata ../fixtures/fixture.yaml`
|
||||||
- Server starten: `python3 manage.py runserver`
|
- Server starten: `python3 manage.py runserver`
|
||||||
- Öffne http://localhost:8080/admin im Browser
|
- Öffne http://localhost:8080/admin im Browser
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,7 @@
|
|||||||
Import für `authors.yml` aus `lilypond-song-includes`
|
Import für `authors.yml` aus `lilypond-song-includes`
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
- inherits (sollte 2. Identität für eine Person anlegen)
|
|
||||||
- details_secret
|
- details_secret
|
||||||
- aktualisieren statt neu anlegen
|
|
||||||
- Import direkt aus dem git
|
- Import direkt aus dem git
|
||||||
- Keine Lösung für trail_name_native_spelling (sehr selten)
|
- Keine Lösung für trail_name_native_spelling (sehr selten)
|
||||||
- Tags
|
- Tags
|
||||||
@@ -59,7 +57,17 @@ class Command(BaseCommand):
|
|||||||
author.update(data[key])
|
author.update(data[key])
|
||||||
if not author['name'] and author['trail_name']:
|
if not author['name'] and author['trail_name']:
|
||||||
author['name'] = author['trail_name']
|
author['name'] = author['trail_name']
|
||||||
p = Person(
|
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'],
|
name = author['name'],
|
||||||
full_name = author['full_name'],
|
full_name = author['full_name'],
|
||||||
name_native = author['name_native_spelling'],
|
name_native = author['name_native_spelling'],
|
||||||
@@ -69,25 +77,29 @@ class Command(BaseCommand):
|
|||||||
death_year = author['death_year'],
|
death_year = author['death_year'],
|
||||||
remarks = author['comment'],
|
remarks = author['comment'],
|
||||||
)
|
)
|
||||||
p.save()
|
except Person.MultipleObjectsReturned as e:
|
||||||
pi = Identity(
|
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,
|
person = p,
|
||||||
author_id = key,
|
author_id = key,
|
||||||
alias = author['trail_name'],
|
alias = author['trail_name'],
|
||||||
organization = author['organization'],
|
organization = author['organization'],
|
||||||
)
|
)
|
||||||
pi.save()
|
|
||||||
for service in 'gnd isni orcid viaf wiki discogs lied brainz'.split():
|
for service in 'gnd isni orcid viaf wiki discogs lied brainz'.split():
|
||||||
dbkey = service
|
dbkey = service
|
||||||
if service=='wiki':
|
if service=='wiki':
|
||||||
dbkey = 'wikidata'
|
dbkey = 'wikidata'
|
||||||
if dbkey in author and author[dbkey]:
|
if dbkey in author and author[dbkey]:
|
||||||
pai = AuthorID(
|
pai, created = AuthorID.objects.update_or_create(
|
||||||
person = p,
|
person = p,
|
||||||
key = AuthorID.IDs.__dict__[service.upper()],
|
key = AuthorID.IDs.__dict__[service.upper()],
|
||||||
value = author[dbkey],
|
value = author[dbkey],
|
||||||
)
|
)
|
||||||
pai.save()
|
|
||||||
|
|
||||||
|
|
||||||
# for poll_id in options["poll_ids"]:
|
# for poll_id in options["poll_ids"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user