From 5ed2572cf64cab6990e0f3445fffc05ea1a592dd Mon Sep 17 00:00:00 2001 From: oysteini Date: Fri, 4 Mar 2011 13:37:00 +0000 Subject: [PATCH] =?UTF-8?q?Fikset=20noen=20rare=20ting=20ang=C3=A5ende=20i?= =?UTF-8?q?d-feltet=20til=20bok.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/web/library/models.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/python/web/library/models.py b/python/web/library/models.py index 1b50871..05189e1 100644 --- a/python/web/library/models.py +++ b/python/web/library/models.py @@ -46,22 +46,15 @@ class Book(models.Model): print '%-15s: %50s' % (field[1], '') def getid(self): - try: + if self.id: return self.id.id - except Id.DoesNotExist: - return None + return None def setid(self,newid): - try: - id = self.id - id.delete() - newid = Id(book=self,id=newid) - newid.save() - - except Id.DoesNotExist: - id=Id(id=newid,book=self) - id.save() -# return Book.get(isbn=self.isbn) + if self.id: + self.id.delete() + newid = Id(book=self,id=newid) + newid.save() def get_authors(self): people = self.persons.all()