SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 17f904c5 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Include children's publications in organization's ones

parent 8efe778b
No related merge requests found
...@@ -88,10 +88,12 @@ class Organization(models.Model): ...@@ -88,10 +88,12 @@ class Organization(models.Model):
return reverse('organizations:organization_details', kwargs = {'pk': self.id}) return reverse('organizations:organization_details', kwargs = {'pk': self.id})
def get_publications(self): def get_publications(self):
org_and_children_ids = [k['id'] for k in list(self.children.all().values('id'))]
org_and_children_ids += [self.id]
return Publication.objects.filter( return Publication.objects.filter(
models.Q(authors__affiliations__in=[self]) | models.Q(authors__affiliations__pk__in=org_and_children_ids) |
models.Q(grants__funder__organization=self) | models.Q(grants__funder__organization__pk__in=org_and_children_ids) |
models.Q(funders_generic__organization=self)).distinct() models.Q(funders_generic__organization__pk__in=org_and_children_ids)).distinct()
def count_publications(self): def count_publications(self):
return self.get_publications().count() return self.get_publications().count()
......
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