Skip to content
Snippets Groups Projects
Commit 8e85d2bb authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

correct sameAs syntax in compound cards

FIX #250
parent 174bc6cf
No related branches found
No related tags found
1 merge request!24prepare for v1.0.6
Pipeline #43990 passed
......@@ -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:
......
......@@ -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"
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment