diff --git a/indigo/models.py b/indigo/models.py index 7cba638..99901c5 100755 --- a/indigo/models.py +++ b/indigo/models.py @@ -82,6 +82,24 @@ class Meta: class Organisation(BaseModel): type_id = TYPE_ORGANISATION_PUBLIC_ID + def is_in_any_public_projects(self): + """Note this includes if the organisation reference is private but the project is public. + https://github.com/INDIGO-Initiative/database-app/issues/180""" + return bool( + self.included_by_projects.filter( + project__status_public=True, in_current_data=True + ) + ) + + def is_in_any_public_pipelines(self): + """Note this includes if the organisation reference is private but the pipeline is public. + https://github.com/INDIGO-Initiative/database-app/issues/180""" + return bool( + self.included_by_pipelines.filter( + pipeline__status_public=True, in_current_data=True + ) + ) + class ProjectManager(models.Manager): def filter_by_admin_user_can_access(self, user): diff --git a/indigo/views_api1.py b/indigo/views_api1.py index c2c0828..23602be 100755 --- a/indigo/views_api1.py +++ b/indigo/views_api1.py @@ -76,6 +76,8 @@ def api1_organisation_index(request, public_id): "organisation": { "id": organisation.public_id, "data": organisation.data_public, + "is_in_any_public_projects": organisation.is_in_any_public_projects(), + "is_in_any_public_pipelines": organisation.is_in_any_public_pipelines(), } } return JsonResponse(data)