fix add_author

pull/1/head
eric 2015-07-27 23:20:30 -04:00
parent 50429e4f1b
commit 088bdff782
1 changed files with 7 additions and 6 deletions

View File

@ -1742,13 +1742,14 @@ class Edition(models.Model):
except Identifier.DoesNotExist:
return None
def add_author(self, author_name):
def add_author(self, author_name, relation='aut'):
if author_name:
try:
author= Author.objects.get(name=author_name)
except Author.DoesNotExist:
author= Author.objects.create(name=author_name)
author.editions.add(self)
author = Author.objects.get_or_create(name=author_name)
relation = Relation.objects.get_or_create(code=relation)
new_relator = Relator.objects.get_or_create(author=author, edition=self)
if new_relator.relation != relation:
new_relator.relation = relation
new_relator.save()
def set_publisher(self,publisher_name):
if publisher_name and publisher_name != '':