diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 6b2855053bed379d0dd7ba30daa7029fb0668bf6..20cfd37b61ce883451e2ed30ed85b7ca52dad2b1 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -1150,6 +1150,21 @@ class Compound(AutoFillableModel): else None ) + @property + def sameas_urls(self): + urls = [] + if self.pubchem_id: + urls.append(self.pubchem_url) + if self.chembl_id: + urls.append(self.chembl_url) + if self.chemspider_id: + urls.append(self.chemspider_url) + if self.ligand_id: + urls.append(self.pdbligand_url) + if self.drugbank_id: + urls.append(self.drugbank_url) + return urls + def clean(self): """ Perform additional checks: diff --git a/ippisite/ippidb/templates/compound_card.html b/ippisite/ippidb/templates/compound_card.html index ba4c780e21e99b8d548938ff6cac2299508f071f..f2a4df839b27259cc946973af498132d604f4556 100644 --- a/ippisite/ippidb/templates/compound_card.html +++ b/ippisite/ippidb/templates/compound_card.html @@ -572,20 +572,8 @@ "smiles": [ "{{ compound.canonical_smile }}" ], -{% if compound.pubchem_id %} -"sameAs": "{{ compound.pubchem_url }}", -{% endif %} -{% if compound.chembl_id %} -"sameAs": "{{ compound.chembl_url }}", -{% endif %} -{% if compound.chemspider_id %} -"sameAs": "{{ compound.chemspider_url }}", -{% endif %} -{% if compound.ligand_id %} -"sameAs": "{{ compound.pdbligand_url }}", -{% endif %} -{% if compound.drugbank_id %} -"sameAs": "{{ compound.drugbank_url }}", +{% if compound.sameas_urls %} +"sameAs": {{ compound.sameas_urls|safe }}, {% endif %} "@context": "http://schema.org" }