From b6be915678ab9310670c5d3f3ff70ed6a5dfd2ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20M=C3=A9nager?= <herve.menager@pasteur.fr>
Date: Sat, 2 May 2020 20:41:39 +0200
Subject: [PATCH] add documentation and minor corrections to ippidb.models

---
 ippisite/ippidb/models.py | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py
index b7722d9b..d340d1ab 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):
-- 
GitLab