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

Forandret litt på Book.to_dict.

Setter hvert felt eksplisitt istedenfor å ha en løkke med magi, for
noen av feltene trenger litt spesialbehandling.
This commit is contained in:
Øystein Ingmar Skartsæterhagen 2011-03-06 15:44:05 +00:00
parent 0c2130db3e
commit 8eafa21103
1 changed files with 14 additions and 5 deletions

View File

@ -68,11 +68,20 @@ class Book(models.Model):
def to_dict(self):
dict = {}
dict['action'] = 'edit-book'
for field in book_fields:
try:
dict[field[0]] = eval('self.'+field[0])
except AttributeError:
dict[field[0]] = ' '
dict['isbn'] = self.isbn
dict['title'] = self.title
dict['category'] = self.category.id
dict['subtitle'] = self.subtitle
dict['publisher'] = self.publisher
dict['published_year'] = self.published_year
dict['edition'] = self.edition
dict['num_pages'] = self.num_pages
if self.series:
dict['series'] = self.series.id
else:
dict['series'] = ''
dict['description'] = self.description
people = self.persons.all()
dict['persons'] = {}