Skip to content

Commit

Permalink
Organisation public data - adds flags to API
Browse files Browse the repository at this point in the history
#180

Adds flags to API only

Ideally would add to other data sources - eg spreadsheet downloads
But there is no current place in code to easily do that

can't add to updatedata.py as we are at risk of introducing a circular update path
(we would need to make updates to projects & pipelines also update orgs
but updates to orgs can already also update projects!)

Adding to API for now, as this satisfies immediate user need:
to be able to distingusish in public https://golab.bsg.ox.ac.uk/ website
  • Loading branch information
odscjames committed Sep 7, 2023
1 parent 65c7b3a commit a43c8d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions indigo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions indigo/views_api1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a43c8d2

Please sign in to comment.