diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index b7722d9bf6b56982b6d5c67b22dacc71b55ae48a..d340d1abb85f89bad8f88c57f33de5dce7c4db71 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -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):