Projects/worblehat-old
Projects
/
worblehat-old
Archived
12
0
Fork 0

La til støtte for persons og references i commit av edit-book.

This commit is contained in:
Øystein Ingmar Skartsæterhagen 2011-03-06 18:06:31 +00:00
parent 9daecbb4f7
commit 58267e9f82
1 changed files with 21 additions and 1 deletions

View File

@ -129,7 +129,27 @@ def perform_action(a):
else: else:
b.series = None b.series = None
if 'description' in a: b.description = a['description'] 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() b.save()
def edit_book_or_person(ids): def edit_book_or_person(ids):