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

add documentation and minor corrections to ippidb.models

parent c18b1e6d
Pipeline #29638 passed with stages
in 13 minutes and 23 seconds
......@@ -35,8 +35,8 @@ from .ws import (
class AutoFillableModel(models.Model):
"""
AutoFillableModel makes it possible to automatically fill model fields from
external sources in the autofill() method
AutoFillableModel abstract model to enable automated model fields
filling from external sources in the autofill() method.
The save method allows to either include autofill or not. in autofill kwarg
is set to True, save() will first call autofill(), otherwise it won't
"""
......@@ -60,19 +60,21 @@ class AutoFillableModel(models.Model):
def autofill_post_save(self):
"""
method called after the save is done, usefull for setting m2m
relations
:return:
Method called automatically after the save is done,
usefull for setting m2m relations
"""
pass
def is_autofill_done(self):
"""
test whether or not the model has been already autofilled
"""
return True
class Bibliography(AutoFillableModel):
"""
Bibliography references
Bibliography reference
(publications or patents)
"""
......@@ -127,10 +129,15 @@ class Bibliography(AutoFillableModel):
return self.source == "PM" or self.source == "DO"
def get_external_url(self):
"""
Get URL to the publication
"""
if self.source == "PM":
return "https://www.ncbi.nlm.nih.gov/pubmed/" + str(self.id_source)
if self.source == "DO":
return "https://doi.org/" + str(self.id_source)
return f"https://www.ncbi.nlm.nih.gov/pubmed/{self.id_source}"
elif self.source == "DO":
return f"https://doi.org/{self.id_source}"
elif self.source == "PT":
return f"https://patentscope.wipo.int/search/en/detail.jsf?docId={self.id_source}"
@staticmethod
def validate_source_id(id_source, source):
......
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