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

Fikset noen småfeil i Book.to_dict.

This commit is contained in:
Øystein Ingmar Skartsæterhagen 2011-03-05 18:40:17 +00:00
parent 0106cb2453
commit ca4ca01bf9
1 changed files with 6 additions and 5 deletions

View File

@ -76,15 +76,16 @@ class Book(models.Model):
people = self.persons.all() people = self.persons.all()
dict['persons'] = {} dict['persons'] = {}
for person in people: for bookperson in people:
if person.relation.name in dict['persons']: person = bookperson.person
dict['persons'][person.relation.name].append(person.id) if bookperson.relation.name in dict['persons']:
dict['persons'][bookperson.relation.name].append(person.id)
else: else:
dict['persons'][person.relation.name] = [person.id] dict['persons'][bookperson.relation.name] = [person.id]
dict['references'] = {} dict['references'] = {}
for reference in self.references.all(): for reference in self.references.all():
if person.relation.name in dict['references']: if reference.reference_type.name in dict['references']:
dict['references'][reference.reference_type.name].append(reference.text) dict['references'][reference.reference_type.name].append(reference.text)
else: else:
dict['references'][reference.reference_type.name] = [reference.text] dict['references'][reference.reference_type.name] = [reference.text]