Commit 9bbf34f2 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

fix style for models.py

parent 24ca2db5
Pipeline #45760 failed with stages
in 10 minutes and 27 seconds
...@@ -1166,27 +1166,26 @@ class Compound(AutoFillableModel): ...@@ -1166,27 +1166,26 @@ class Compound(AutoFillableModel):
return urls return urls
def get_bioschemas(self, request): def get_bioschemas(self, request):
json_data = { json_data = {"@type": "MolecularEntity", "@context": "http://schema.org"}
"@type": "MolecularEntity", json_data["name"] = str(self)
"@context": "http://schema.org"
}
json_data['name'] = str(self)
if self.pk is not None: if self.pk is not None:
json_data['url'] = request.build_absolute_uri(self.get_absolute_url()) json_data["url"] = request.build_absolute_uri(self.get_absolute_url())
if self.inchi is not None: if self.inchi is not None:
json_data['inChI'] = self.inchi json_data["inChI"] = self.inchi
if self.iupac_name != "": if self.iupac_name != "":
json_data['iupacName'] = self.iupac_name json_data["iupacName"] = self.iupac_name
if self.molecular_weight is not None: if self.molecular_weight is not None:
json_data['molecularWeight'] = self.molecular_weight json_data["molecularWeight"] = self.molecular_weight
if self.inchikey is not None: if self.inchikey is not None:
json_data['inChIKey'] = self.inchikey json_data["inChIKey"] = self.inchikey
if self.chembl_id is not None: if self.chembl_id is not None:
json_data['image'] = f"https://www.ebi.ac.uk/chembl/api/data/image/{ self.chembl_id }.svg" json_data[
"image"
] = f"https://www.ebi.ac.uk/chembl/api/data/image/{ self.chembl_id }.svg"
if self.canonical_smile is not None: if self.canonical_smile is not None:
json_data['smiles'] = self.canonical_smile json_data["smiles"] = self.canonical_smile
if len(self.sameas_urls)>0: if len(self.sameas_urls) > 0:
json_data['sameAs'] = self.sameas_urls json_data["sameAs"] = self.sameas_urls
return json_data return json_data
def clean(self): def clean(self):
...@@ -1668,7 +1667,10 @@ class ContributionManager(models.Manager): ...@@ -1668,7 +1667,10 @@ class ContributionManager(models.Manager):
if current_user.is_anonymous: if current_user.is_anonymous:
qs = qs.exclude(validated=False) qs = qs.exclude(validated=False)
elif not current_user.is_superuser: elif not current_user.is_superuser:
qs = qs.exclude(Q(validated=False), ~Q(contributor=current_user),) qs = qs.exclude(
Q(validated=False),
~Q(contributor=current_user),
)
return qs return qs
def validated(self): def validated(self):
...@@ -1737,7 +1739,10 @@ def update_compound_cached_properties(compounds_queryset=None): ...@@ -1737,7 +1739,10 @@ def update_compound_cached_properties(compounds_queryset=None):
le=Subquery( le=Subquery(
compounds_queryset.filter(id=OuterRef("id")) compounds_queryset.filter(id=OuterRef("id"))
.annotate( .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] .values("_le")[:1]
), ),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment