Commit b3781892 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

retrieve patent info in Bibliography.save() when relevant

parent cf56ca96
......@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.db import models
from django.forms import ModelForm
from .ws import get_pubmed_info
from .ws import get_pubmed_info, get_epo_info
class Bibliography(models.Model):
"""
......@@ -31,11 +31,14 @@ class Bibliography(models.Model):
return reverse('bibliography-detail', args=[str(self.id)])
def save(self, *args, **kwargs):
pubmed_info = get_pubmed_info(self.id_source)
self.title = pubmed_info['title']
self.journal_name = pubmed_info['journal_name']
self.authors_list = pubmed_info['authors_list']
self.biblio_year = pubmed_info['biblio_year']
if self.source == 'PM':
info = get_pubmed_info(self.id_source)
else:
info = get_epo_info(self.id_source)
self.title = info['title']
self.journal_name = info['journal_name']
self.authors_list = info['authors_list']
self.biblio_year = info['biblio_year']
super(Bibliography, self).save(*args, **kwargs)
class Meta:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment