La til støtte for persons og references i commit av edit-book.
This commit is contained in:
parent
9daecbb4f7
commit
58267e9f82
@ -129,7 +129,27 @@ def perform_action(a):
|
||||
else:
|
||||
b.series = None
|
||||
if 'description' in a: b.description = a['description']
|
||||
# TODO persons, references, pictures
|
||||
if 'persons' in a:
|
||||
for bp in b.persons.all():
|
||||
if bp.person.id not in a['persons'][bp.relation.name]:
|
||||
bp.delete()
|
||||
for rel, person_list in a['persons'].items():
|
||||
for person_id in person_list:
|
||||
if person_id not in map(lambda p: p.id, b.get_persons(rel)):
|
||||
BookPerson(book=b,
|
||||
person=Person.objects.get(id=person_id),
|
||||
relation=Relation.objects.get(name=rel)).save()
|
||||
if 'references' in a:
|
||||
for ref in b.references.all():
|
||||
if ref.text not in a['references'][ref.reference_type]:
|
||||
ref.delete()
|
||||
for reftype, text_list in a['references'].items():
|
||||
for text in text_list:
|
||||
if text not in map(lambda r: r.text, b.references.all()):
|
||||
Reference(book=b,
|
||||
reference_type=ReferenceType.objects.get(name=reftype),
|
||||
text=text).save()
|
||||
# TODO pictures
|
||||
b.save()
|
||||
|
||||
def edit_book_or_person(ids):
|
||||
|
Reference in New Issue
Block a user