Commit 53128da8 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

fix bug introduced by removing "validated" from CompoundManager

bug introduced in 0ab38431 and
visible here: https://gitlab.pasteur.fr/ippidb/ippidb-web/-/jobs/46382
WIP on #68
parent 0ab38431
Pipeline #20799 failed with stages
in 9 minutes and 3 seconds
......@@ -479,6 +479,11 @@ class PpiComplex(models.Model):
class CompoundsManager(models.Manager):
def for_user(self, current_user):
"""
Get compounds visible to a given user
i.e. validated or created by the user or
all of them if the user is an admin
"""
qs = self.get_queryset()
if current_user.is_anonymous:
qs = qs.exclude(compoundaction__ppi__contribution__validated=False)
......@@ -489,6 +494,16 @@ class CompoundsManager(models.Manager):
)
return qs
def validated(self):
"""
Get validated compounds
"""
return (
super()
.get_queryset()
.exclude(compoundaction__ppi__contribution__validated=False)
)
class Compound(AutoFillableModel):
"""
......
......@@ -131,8 +131,8 @@ class ContributionViewsTestCase(TestCase):
"Compounds count",
),
(
models.Compound.validated.count,
models.Compound.validated.count(),
models.Compound.objects.validated().count,
models.Compound.objects.validated().count(),
"Validated Compounds count",
),
(
......@@ -164,7 +164,7 @@ class ContributionViewsTestCase(TestCase):
self.assertEqual(fcn(), results, msg=msg)
post_validation_expected_equals = [
(
models.Compound.validated.count,
models.Compound.objects.validated().count,
models.Compound.objects.count(),
"Validated Compounds count",
)
......
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