diff --git a/ippisite/ippidb/forms.py b/ippisite/ippidb/forms.py index 4418ebd069e95ed6e1abf4f3d7c9a158c2c2860d..2b2dd98b1045cdf8cdb02f760257bc153c4dd000 100644 --- a/ippisite/ippidb/forms.py +++ b/ippisite/ippidb/forms.py @@ -838,6 +838,11 @@ class CompoundActivityResultForm(ModelForm): "activity": widgets.HiddenInput(), } + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + for f in self.fields.values(): + f.widget.attrs.update({"class": "col-3"}) + def has_changed(self): """ Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and @@ -1035,10 +1040,10 @@ class TestActivityDescriptionForm(forms.ModelForm): super().__init__(*args, **kwargs) self.fields["test_type"].widget.attrs["onchange"] = "test_type_changed(this);" self.fields["test_type"].widget.attrs.update({"class": "col-2"}) - self.fields["test_name"].widget.attrs.update({"class": "col-9"}) + self.fields["test_name"].widget.attrs.update({"class": "col-10"}) self.fields["test_modulation_type"].widget.attrs.update({"class": "col-2"}) self.fields["nb_active_compounds"].widget.attrs.update({"class": "col-3"}) - self.fields["cell_line_name"].widget.attrs.update({"class": "col-6"}) + self.fields["cell_line_name"].widget.attrs.update({"class": "col-7"}) def has_changed(self): """ @@ -1166,6 +1171,11 @@ class CompoundCytotoxicityResultForm(ModelForm): fields = ("compound_name", "toxicity") widgets = {"toxicity": forms.Select(choices=((True, "True"), (False, "False")))} + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + for f in self.fields.values(): + f.widget.attrs.update({"class": "col-3"}) + def has_changed(self): """ Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and @@ -1280,6 +1290,9 @@ class TestCytotoxDescriptionForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["compound_concentration"].required = True + self.fields["cell_line_name"].widget.attrs.update({"class": "col"}) + self.fields["compound_concentration"].widget.attrs.update({"class": "col"}) + self.fields["test_name"].widget.attrs.update({"class": "col"}) def has_changed(self): """ @@ -1378,6 +1391,13 @@ class CompoundPKResultForm(ModelForm): ) } + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + for f in self.fields.values(): + f.widget.attrs.update({"class": "col-3"}) + if isinstance(f, forms.BooleanField) and not isinstance(f.widget, forms.Select): + f.widget.attrs.update({"class": "col-3 mb-4"}) + def has_changed(self): """ Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and @@ -1489,6 +1509,8 @@ class TestPKDescriptionForm(forms.ModelForm): super().__init__(*args, **kwargs) for f in ["administration_mode", "dose"]: self.fields[f].required = True + for f in self.fields.values(): + f.widget.attrs.update({"class": "col-3"}) def has_changed(self): """ diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 3bb8468c323936cb3354b634091fed7007634259..8b536fecec087ef711461e67b587ec82b23a5206 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -1082,6 +1082,59 @@ class Compound(AutoFillableModel): """ return reverse("compound_card", kwargs={"pk": self.pk}) + @property + def pubchem_url(self): + """ + Get absolute URL to the corresponding PubChem entry + """ + return ( + f"https://pubchem.ncbi.nlm.nih.gov/compound/{ self.pubchem_id }" + if self.pubchem_id + else None + ) + + @property + def chembl_url(self): + """ + Get absolute URL to the corresponding Chembl entry + """ + return ( + f"https://www.ebi.ac.uk/chembldb/compound/inspect/{ self.chembl_id }" + if self.chembl_id + else None + ) + + @property + def chemspider_url(self): + """ + Get absolute URL to the corresponding ChemSpider entry + """ + return ( + f"http://www.chemspider.com/Chemical-Structure.{ self.chemspider_id}.html" + if self.chemspider_id + else None + ) + + @property + def pdbligand_url(self): + """ + Get absolute URL to the corresponding PDB ligand entry + """ + return ( + f"https://www.rcsb.org/ligand/{ self.ligand_id}" if self.ligand_id else None + ) + + @property + def drugbank_url(self): + """ + Get absolute URL to the corresponding Drugbank entry + """ + return ( + f"https://www.drugbank.ca/drugs/{ self.drugbank_id}" + if self.drugbank_id + else None + ) + def clean(self): """ Perform additional checks: @@ -1576,20 +1629,13 @@ def update_compound_cached_properties(compounds_queryset=None): le=Subquery( compounds_queryset.filter(id=OuterRef("id")) .annotate( - _le=Cast( - 1.37 * F("best_activity") / F("nb_atom_non_h"), - FloatField(), - ) + _le=Cast(1.37 * F("best_activity") / F("nb_atom_non_h"), FloatField(),) ) .values("_le")[:1] ), lle=Subquery( compounds_queryset.filter(id=OuterRef("id")) - .annotate( - _lle=Cast( - F("best_activity") - F("a_log_p"), FloatField() - ) - ) + .annotate(_lle=Cast(F("best_activity") - F("a_log_p"), FloatField())) .values("_lle")[:1] ), lipinsky_mw=Subquery( diff --git a/ippisite/ippidb/static/css/admin-session.css b/ippisite/ippidb/static/css/admin-session.css index 213f0636fd9c9869746bf5f86ff6c578aac95bbb..3121b87f39cd2c88fe4fdf9630d84327359f478d 100644 --- a/ippisite/ippidb/static/css/admin-session.css +++ b/ippisite/ippidb/static/css/admin-session.css @@ -225,7 +225,7 @@ Description: IPPI-DB Theme .input_field { width: 100%; - margin-right: 2px; + margin-right: 0px; font-family: "BrandonGrotesqueReg"; text-align: left; margin-top: 0px; @@ -268,6 +268,10 @@ Description: IPPI-DB Theme padding-bottom: 1%; } +.form-group.form-check{ + padding-left: 2.25rem; +} + .form-group.form-check, .compound .input_field input { text-align: left; } @@ -356,6 +360,9 @@ Description: IPPI-DB Theme .formset-item .formset-item-delete-host { font-size: initial; text-align: right; + position: absolute; + right: 3em; + margin-top: -4em; } .formset-item-delete-host input { @@ -1352,6 +1359,7 @@ Description: IPPI-DB Theme .test_title { text-align: left; margin-top: 15px; + margin-bottom: 1.5em; } .tests { diff --git a/ippisite/ippidb/static/js/wizard_formset_with_nested_formset.js b/ippisite/ippidb/static/js/wizard_formset_with_nested_formset.js index 83faadc08fd4eed52707d753328f85145a5e0511..08a45863858286c8018588d72bc0a0c6b310a544 100644 --- a/ippisite/ippidb/static/js/wizard_formset_with_nested_formset.js +++ b/ippisite/ippidb/static/js/wizard_formset_with_nested_formset.js @@ -23,7 +23,11 @@ function add_nested_form_to_nested_formset(source, prefix, parent_prefix){ .find(".formset-nested-item")[0] .outerHTML; - current_item_name = $(source).closest(".formset-item").children("input")[0].name; + if($(source).closest(".formset-item").children("input").length>0){ + current_item_name = $(source).closest(".formset-item").children("input")[0].name; + }else{ + current_item_name = $(source).closest(".formset-item").children("div").children("input")[0].name; + } current_item_name = current_item_name.substring(parent_prefix.length+1,current_item_name.indexOf('-',parent_prefix.length+1)); empty_form_as_str = empty_form_as_str.replace( new RegExp(parent_prefix+"-__prefix__","g"), diff --git a/ippisite/ippidb/templates/compound_card.html b/ippisite/ippidb/templates/compound_card.html index 680c2290d679b8b7491aa9b8be85ee8374ae820d..c8a3924b5160908387efbdf4ef796858c748d846 100644 --- a/ippisite/ippidb/templates/compound_card.html +++ b/ippisite/ippidb/templates/compound_card.html @@ -573,8 +573,9 @@ <script id='JSON_LD' type="application/ld+json"> { -"url": "{{ compound.get_absolute_url }}", +"url": "{{ request.build_absolute_uri }}", "inChI": "{{ compound.inchi }}", +"name": "{{ compound.iupac_name }}", "iupacName": "{{ compound.iupac_name }}", "molecularWeight": {{ compound.molecular_weight }}, "identifier": "{{ compound.id }}", @@ -584,6 +585,21 @@ "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 }}", +{% endif %} "@context": "http://schema.org" } diff --git a/ippisite/ippidb/templates/compound_db_links.html b/ippisite/ippidb/templates/compound_db_links.html index 5a0235a9105e4d074d3e05de5538a2e328b0c775..b823487e75dfb5ce52385b7f804414d396846057 100644 --- a/ippisite/ippidb/templates/compound_db_links.html +++ b/ippisite/ippidb/templates/compound_db_links.html @@ -4,35 +4,35 @@ <tr class="row"> <td scope="col" class="col-2 text-center"> {% if compound.pubchem_id %} - <a href="https://pubchem.ncbi.nlm.nih.gov/compound/{{ compound.pubchem_id }}" target="_blank"><img + <a href="{{ compound.pubchem_url }}" target="_blank"><img src="/static/images/Other/Pubchemlogo.png" style="height: 1.5em;" title="PubChem ID: {{ compound.pubchem_id }}" /><br />{{ compound.pubchem_id }}</a> {% endif %} </td> <td scope="col" class="col-2 text-center"> {% if compound.chembl_id %} - <a href="https://www.ebi.ac.uk/chembldb/compound/inspect/{{ compound.chembl_id }}" target="_blank"><img + <a href="{{ compound.chembl_url }}" target="_blank"><img src="/static/images/Other/Chembl_logo.png" style="height: 1.5em;" title="ChEMBL ID: {{ compound.chembl_id }}" /><br />{{ compound.chembl_id }}</a> {% endif %} </td> <td scope="col" class="col-2 text-center"> {% if compound.chemspider_id %} - <a href="http://www.chemspider.com/Chemical-Structure.{{ compound.chemspider_id}}.html" target="_blank"><img + <a href="{{ compound.chemspider_url }}.html" target="_blank"><img src="/static/images/Other/ChemSpider_Logo.png" style="height: 1.5em;" title="ChemSpider ID: {{ compound.chemspider_id }}" /><br />{{ compound.chemspider_id }}</a> {% endif %} </td> <td scope="col" class="col-2 text-center"> {% if compound.ligand_id %} - <a href="https://www.rcsb.org/ligand/{{ compound.ligand_id}}" target="_blank"><img + <a href="{{ compound.pdbligand_url }}" target="_blank"><img src="/static/images/Other/PDBLogo.ico" style="height: 1.5em;" title="PDB Ligand ID: {{ compound.ligand_id }}" /><br />{{ compound.ligand_id }}</a> {% endif %} </td> <td scope="col" class="col-2 text-center"> {% if compound.drugbank_id %} - <a href="https://www.drugbank.ca/drugs/{{ compound.drugbank_id}}" target="_blank"><img + <a href="{{ compound.drugbank_url }}" target="_blank"><img src="/static/images/Other/DrugBankLogo.ico" style="height: 1.5em;" title="DrugBank ID: {{ compound.drugbank_id }}" /><br />{{ compound.drugbank_id }}</a> {% endif %} diff --git a/ippisite/ippidb/templates/form_with_nested_formset.html b/ippisite/ippidb/templates/form_with_nested_formset.html index 7b128ba2caa9bc752fa6338e19bfe34b90255667..b355d3f1bb9b642accac434714347da44563c3fe 100644 --- a/ippisite/ippidb/templates/form_with_nested_formset.html +++ b/ippisite/ippidb/templates/form_with_nested_formset.html @@ -11,7 +11,7 @@ </script> {% endblock extra_js %} -<div class="formset-item"> +<div class="formset-item mb-4"> <h3 class="test_title">Test description</h3> <div class="row"> {{ form|bootstrap}} @@ -20,15 +20,19 @@ {{ form.nested.management_form }} {{ form.nested.non_form_errors|bootstrap }} {% if nested_form %} - <div class="formset-nested-item formset-item-inline-grid"> + <div class="formset-nested-item "> <h3 class="test_title">Test results</h3> - {{ nested_form|bootstrap }} + <div class="row"> + {{ nested_form|bootstrap }} + </div> </div> {% endif %} {% for nested_form in nested_forms %} - <div class="formset-nested-item formset-item-inline-grid"> + <div class="formset-nested-item"> <h3 class="test_title">Test results</h3> - {{ nested_form|bootstrap }} + <div class="row"> + {{ nested_form|bootstrap }} + </div> </div> {% endfor %} <div class="form_div"> diff --git a/ippisite/ippidb/templates/index.html b/ippisite/ippidb/templates/index.html index ead7713e06f6fbb9b5cf2a2329edc54529c9d00c..5d86cf89a0b51f88949db17130c7ab427aabdc67 100644 --- a/ippisite/ippidb/templates/index.html +++ b/ippisite/ippidb/templates/index.html @@ -232,7 +232,7 @@ "@type": "schema:Dataset", "schema:url": "https://ippidb.pasteur.fr", "schema:includedInDataCatalog": "https://ippidb.pasteur.fr", - "schema:license": "Creative Commons Attribution-Share Alike 3.0 Unported License", + "schema:license": "https://creativecommons.org/licenses/by-sa/3.0/deed.en_GB", "@id": "https://ippidb.pasteur.fr", "schema:name": "iPPI-DB", "schema:description": "a database of modulators of protein-protein interactions. It contains exclusively small molecules and therefore no peptides. The data are retrieved from the literature either peer reviewed scientific articles or world patents. A large variety of data is stored within IPPI-DB: structural, pharmacological, binding and activity profile, pharmacokinetic and cytotoxicity when available, as well as some data about the PPI targets themselves.", diff --git a/ippisite/ippidb/templatetags/customtags.py b/ippisite/ippidb/templatetags/customtags.py index 95b5acec9edac8846b1ad0a588144001f13eb89f..6c1b2c14d73c10ac8a1e846126166abe4c796ef6 100644 --- a/ippisite/ippidb/templatetags/customtags.py +++ b/ippisite/ippidb/templatetags/customtags.py @@ -84,13 +84,23 @@ def bootstrap_core(object): # HACK : If the field is the DELETE button of the formset attrs["onchange"] = "delete_button_clicked(this);" field.label = ugettext("DELETE_label") - wrapping_classes += " formset-item-delete-host delete-btn" + wrapping_classes += " formset-item-delete-host delete-btn col order-1" css_classes.add("formset-item-delete") # HACK: if the css_class is a bootstrap column layout, transfer it to container element for css_class in css_classes: - if css_class.startswith("col-"): + if css_class.startswith("col") or css_class.startswith("order-") or css_class.startswith("mb-"): wrapping_classes += f" {css_class}" - css_classes = set([css_class for css_class in css_classes if not(css_class.startswith('col-'))]) + css_classes = set( + [ + css_class + for css_class in css_classes + if not ( + css_class.startswith("col") + or css_class.startswith("order-") + or css_class.startswith("mb-") + ) + ] + ) # overwrite the css classes attrs["class"] = " ".join(css_classes) diff --git a/ippisite/ippidb/tests/tests.py b/ippisite/ippidb/tests/tests.py index 4a074c47f9e31bf5972890ffb47b53f7ebd23733..5a4f4e49fcb604bb4e3aba5280baf1065dcd8a4a 100644 --- a/ippisite/ippidb/tests/tests.py +++ b/ippisite/ippidb/tests/tests.py @@ -601,7 +601,6 @@ class TestGetUniprotInfo(TestCase): "GO_0005886", "GO_0005905", "GO_0010008", - "GO_0012505", "GO_0030665", "GO_0031253", "GO_0042470", @@ -616,8 +615,8 @@ class TestGetUniprotInfo(TestCase): ) exp_biological_processes = [ "GO_0000281", - "GO_0006886", "GO_0008104", + "GO_0015031", "GO_0016197", "GO_0019882", "GO_0031175",