From b1fa0c6fb6d3a19bcdc45918cec23b9d3386ef08 Mon Sep 17 00:00:00 2001 From: almelid Date: Mon, 27 Sep 2010 17:33:51 +0000 Subject: [PATCH] lagt til Book.get_authors() --- python/web/library/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/web/library/models.py b/python/web/library/models.py index 5132062..e24b4f8 100644 --- a/python/web/library/models.py +++ b/python/web/library/models.py @@ -60,7 +60,14 @@ class Book(models.Model): id=Id(id=newid,book=self) id.save() # return Book.get(isbn=self.isbn) - + + def get_authors(self): + people = self.person.all() + authors = [] + for person in people: + if person.relation.name == 'Author': + authors.append(person.person) + return authors def __unicode__(self): return self.title