Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collaborative analysis workspaces #400

Merged
merged 37 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c702c08
Add a new collab_anlaysis app
amstilp Dec 4, 2023
a563f29
Rename app to collaborative_analysis
amstilp Dec 5, 2023
2b545fe
Add collaborative_analysis to installed apps
amstilp Dec 5, 2023
2cf8fd3
Add a new CollaborativeAnalysisWorkspace model
amstilp Dec 5, 2023
13f9a70
Add a purpose field to the CollaborativeAnalysis model
amstilp Dec 5, 2023
4c46b51
Rearrange field definitions
amstilp Dec 5, 2023
dbd0af1
Add a form for CollaborativeAnalysisWorkspaces
amstilp Dec 5, 2023
dd3caa5
Fix form widget for source_workspaces
amstilp Dec 5, 2023
f7e30be
Add autocomplete for custodian in CollaborativeAnalysis form
amstilp Dec 5, 2023
1b9fe6a
Remove commented out code
amstilp Dec 5, 2023
15bd439
Add and register a basic adapter for collab analysis workspaces
amstilp Dec 5, 2023
f616aec
Use a custom template for CollaborativeAnalysisWorkspaces
amstilp Dec 5, 2023
30fca54
Add custom tables for CollaborativeAnalysisWorkspaces
amstilp Dec 6, 2023
6df653e
Add an analyst_group foreign key to CollabAnalysisWorkspaces
amstilp Dec 7, 2023
921ded1
Add dataclasses for CollaborativeAnalsyisWorkspace audit results
amstilp Dec 7, 2023
1bd2943
Add skeleton audit for CollaborativeAnalysisWorkspaces
amstilp Dec 7, 2023
469b54d
Start writing audit functions with simple checks
amstilp Dec 7, 2023
1388c75
Finish unit tests for the main auditing method
amstilp Dec 14, 2023
259f927
Add tests for the _audit_workspace method
amstilp Dec 14, 2023
ba358d1
Handle checking groups for collaborative analysis audits
amstilp Dec 14, 2023
9661173
Allow audit to only run on a specific workspace queryset
amstilp Dec 14, 2023
27c7d16
Script to add test data for collab analysis workspaces
amstilp Dec 15, 2023
139f61d
Create related objects with similar names in workspace factories
amstilp Jan 24, 2024
d44a29f
Add an audit view for collaborative analysis workspaces
amstilp Jan 24, 2024
ef12d32
Add link to audit on detail page for staff
amstilp Jan 24, 2024
72eb2e8
Ignore PRIMED CC groups in the audit
amstilp Jan 24, 2024
404c099
Handle CC_MEMBERS and CC_WRITERS groups differently in audit
amstilp Jan 25, 2024
ecbfe25
Add a view that audits all collaborative analysis workspaces
amstilp Jan 25, 2024
ee4f730
Fix page titles for collaborative analysis workspaces
amstilp Jan 25, 2024
64ed238
Register CollaborativeAnalysisWorkspace in the admin
amstilp Jan 25, 2024
225d980
Add debugging print statements
amstilp Jan 25, 2024
8920bc1
Fix debugging print statements
amstilp Jan 25, 2024
5f021a2
Fix collab analysis create/import tests for mysql
amstilp Jan 25, 2024
be3fa7f
Include checkboxes showing access in collab workspace audit
amstilp Jan 25, 2024
7cf6745
Add collab analysis links to navbar
amstilp Jan 25, 2024
29eb488
Do not grant PRIMED_CC_MEMBERS access to collab analysis workspaces
amstilp Jan 29, 2024
eb73ada
Update language on collab workspace audit template
amstilp Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions add_collaborative_analysis_example_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
"""Temporary script to create some example data for the collaborative_analysis app.

Run with: python manage.py shell < add_collaborative_analysis_example_data.py
"""

from anvil_consortium_manager.tests.factories import (
AccountFactory,
BillingProjectFactory,
GroupAccountMembershipFactory,
GroupGroupMembershipFactory,
ManagedGroupFactory,
)

from primed.cdsa.tests.factories import CDSAWorkspaceFactory
from primed.collaborative_analysis.tests.factories import (
CollaborativeAnalysisWorkspaceFactory,
)
from primed.dbgap.tests.factories import dbGaPWorkspaceFactory
from primed.miscellaneous_workspaces.tests.factories import OpenAccessWorkspaceFactory

billing_project = BillingProjectFactory.create(name="test_collab")

# Create some collaborative analysis workspace.
# Workspace 1
collaborative_analysis_workspace_1 = CollaborativeAnalysisWorkspaceFactory.create(
workspace__name="collab_1_open_access", workspace__billing_project=billing_project
)
source_workspace_1_1 = OpenAccessWorkspaceFactory.create(
workspace__name="source_1_open_access", workspace__billing_project=billing_project
)
collaborative_analysis_workspace_1.source_workspaces.add(source_workspace_1_1.workspace)

# Workspace 2
collaborative_analysis_workspace_2 = CollaborativeAnalysisWorkspaceFactory.create(
workspace__name="collab_2_dbgap_and_cdsa",
workspace__billing_project=billing_project,
)
source_workspace_2_1 = dbGaPWorkspaceFactory.create(
workspace__name="source_2_dbgap", workspace__billing_project=billing_project
)
collaborative_analysis_workspace_2.source_workspaces.add(source_workspace_2_1.workspace)
source_workspace_2_2 = CDSAWorkspaceFactory.create(
workspace__name="source_2_cdsa", workspace__billing_project=billing_project
)
collaborative_analysis_workspace_2.source_workspaces.add(source_workspace_2_2.workspace)

# Workspace 3 - with an error
collaborative_analysis_workspace_3 = CollaborativeAnalysisWorkspaceFactory.create(
workspace__name="collab_3_with_error", workspace__billing_project=billing_project
)
source_workspace_3_1 = OpenAccessWorkspaceFactory.create(
workspace__name="source_3_open_access", workspace__billing_project=billing_project
)
collaborative_analysis_workspace_3.source_workspaces.add(source_workspace_3_1.workspace)


# Add accounts to the auth domains.
account_1 = AccountFactory.create(
user__name="Adrienne", verified=True, email="[email protected]"
)
account_2 = AccountFactory.create(
user__name="Ben", verified=True, email="[email protected]"
)
account_3 = AccountFactory.create(
user__name="Matt", verified=True, email="[email protected]"
)
account_4 = AccountFactory.create(
user__name="Stephanie", verified=True, email="[email protected]"
)

# Set up collab analysis workspace one
# analyst group
GroupAccountMembershipFactory.create(
account=account_1, group=collaborative_analysis_workspace_1.analyst_group
)
GroupAccountMembershipFactory.create(
account=account_2, group=collaborative_analysis_workspace_1.analyst_group
)
# auth domains
GroupAccountMembershipFactory.create(
account=account_1,
group=collaborative_analysis_workspace_1.workspace.authorization_domains.first(),
)

# Set up collab analysis workspace two
# analyst group
GroupAccountMembershipFactory.create(
account=account_3, group=collaborative_analysis_workspace_2.analyst_group
)
GroupAccountMembershipFactory.create(
account=account_4, group=collaborative_analysis_workspace_2.analyst_group
)
# auth domains
GroupAccountMembershipFactory.create(
account=account_3,
group=collaborative_analysis_workspace_2.workspace.authorization_domains.first(),
)
GroupAccountMembershipFactory.create(
account=account_3,
group=source_workspace_2_1.workspace.authorization_domains.first(),
)
GroupAccountMembershipFactory.create(
account=account_3,
group=source_workspace_2_2.workspace.authorization_domains.first(),
)
GroupAccountMembershipFactory.create(
account=account_4,
group=source_workspace_2_1.workspace.authorization_domains.first(),
)

# Set up collab analysis workspace three
# Managed group to show an error
managed_group = ManagedGroupFactory.create(name="test-error")
GroupGroupMembershipFactory.create(
parent_group=collaborative_analysis_workspace_3.workspace.authorization_domains.first(),
child_group=managed_group,
)
2 changes: 2 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"primed.miscellaneous_workspaces",
"primed.duo",
"primed.cdsa",
"primed.collaborative_analysis",
]

# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
Expand Down Expand Up @@ -376,6 +377,7 @@
"primed.miscellaneous_workspaces.adapters.SimulatedDataWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.ResourceWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.ConsortiumDevelWorkspaceAdapter",
"primed.collaborative_analysis.adapters.CollaborativeAnalysisWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.TemplateWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.DataPrepWorkspaceAdapter",
]
Expand Down
6 changes: 6 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
path("dbgap/", include("primed.dbgap.urls", namespace="dbgap")),
path("duo/", include("primed.duo.urls", namespace="duo")),
path("cdsa/", include("primed.cdsa.urls", namespace="cdsa")),
path(
"collaborative_analysis/",
include(
"primed.collaborative_analysis.urls", namespace="collaborative_analysis"
),
),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Expand Down
4 changes: 3 additions & 1 deletion primed/cdsa/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def authorization_domains(self, create, extracted, **kwargs):
return

# Create an authorization domain.
auth_domain = ManagedGroupFactory.create()
auth_domain = ManagedGroupFactory.create(
name="auth_{}".format(self.workspace.name)
)
self.workspace.authorization_domains.add(auth_domain)

class Meta:
Expand Down
Empty file.
20 changes: 20 additions & 0 deletions primed/collaborative_analysis/adapters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from anvil_consortium_manager.adapters.workspace import BaseWorkspaceAdapter
from anvil_consortium_manager.forms import WorkspaceForm

from . import forms, models, tables


class CollaborativeAnalysisWorkspaceAdapter(BaseWorkspaceAdapter):
"""Adapter for CollaborativeAnalysisWorkspace."""

type = "collab_analysis"
name = "Collaborative Analysis workspace"
description = "Workspaces used for collaborative analyses"
list_table_class_staff_view = tables.CollaborativeAnalysisWorkspaceStaffTable
list_table_class_view = tables.CollaborativeAnalysisWorkspaceUserTable
workspace_form_class = WorkspaceForm
workspace_data_model = models.CollaborativeAnalysisWorkspace
workspace_data_form_class = forms.CollaborativeAnalysisWorkspaceForm
workspace_detail_template_name = (
"collaborative_analysis/collaborativeanalysisworkspace_detail.html"
)
21 changes: 21 additions & 0 deletions primed/collaborative_analysis/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.contrib import admin
from simple_history.admin import SimpleHistoryAdmin

from . import models


@admin.register(models.CollaborativeAnalysisWorkspace)
class CollaborativeAnalysisWorkspaceAdmin(SimpleHistoryAdmin):
"""Admin class for the `CollaborativeAnalysisWorkspace` model."""

list_display = (
"id",
"workspace",
"custodian",
)
list_filter = ("proposal_id",)
sortable_by = (
"id",
"workspace",
"custodian",
)
6 changes: 6 additions & 0 deletions primed/collaborative_analysis/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class CollabAnalysisConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "primed.collaborative_analysis"
Loading
Loading