Skip to content

Commit

Permalink
Merge pull request #400 from UW-GAC/feature/collab-analysis-workspaces
Browse files Browse the repository at this point in the history
Collaborative analysis workspaces
  • Loading branch information
amstilp authored Feb 16, 2024
2 parents 12ac8b7 + eb73ada commit 7d81e7f
Show file tree
Hide file tree
Showing 27 changed files with 3,575 additions and 1 deletion.
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 @@ -122,7 +122,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

0 comments on commit 7d81e7f

Please sign in to comment.