Skip to content

Commit

Permalink
Merge pull request #707 from UW-GAC/deploy/stage
Browse files Browse the repository at this point in the history
Deploy to prod
  • Loading branch information
amstilp authored Aug 9, 2024
2 parents 304e52d + e252ade commit dd84092
Show file tree
Hide file tree
Showing 18 changed files with 402 additions and 47 deletions.
6 changes: 2 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
interval: "daily"

# Enable version updates for Python/Pip - Production
- package-ecosystem: "pip"
Expand All @@ -14,8 +13,7 @@ updates:
directory: "/"
# Check for updates to GitHub Actions every weekday
schedule:
interval: "weekly"
day: "sunday"
interval: "daily"
allow:
# Allow only direct dependencies - should be ok with pip-sync?
- dependency-type: "direct"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pip-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
pull_request:
branches: [ "main" ]

permissions:
pull-requests: write
contents: write

jobs:
update-requirements-files:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.1
rev: v0.5.6
hooks:
# Run the linter.
- id: ruff
Expand Down
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@
"primed.miscellaneous_workspaces.adapters.DataPrepWorkspaceAdapter",
]
ANVIL_ACCOUNT_ADAPTER = "primed.primed_anvil.adapters.AccountAdapter"
ANVIL_MANAGED_GROUP_ADAPTER = "primed.primed_anvil.adapters.ManagedGroupAdapter"

# Specify the URL name that AccountLink and AccountLinkVerify redirect to.
ANVIL_ACCOUNT_LINK_REDIRECT = "users:redirect"
Expand Down
25 changes: 16 additions & 9 deletions primed/cdsa/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,11 @@ class MemberAgreementDetail(viewmixins.SignedAgreementViewPermissionMixin, Singl
model = models.MemberAgreement

def get_table(self):
return UserAccountSingleGroupMembershipTable(
access_group_table = UserAccountSingleGroupMembershipTable(
self.object.signed_agreement.accessors.all(), managed_group=self.object.signed_agreement.anvil_access_group
)
access_group_table.columns["is_group_member"].column.verbose_name = "In access group?"
return access_group_table

def get_object(self, queryset=None):
"""Look up the agreement by CDSA cc_id."""
Expand Down Expand Up @@ -438,14 +440,17 @@ class DataAffiliateAgreementDetail(viewmixins.SignedAgreementViewPermissionMixin
model = models.DataAffiliateAgreement

def get_tables(self):
access_group_table = UserAccountSingleGroupMembershipTable(
self.object.signed_agreement.accessors.all(), managed_group=self.object.signed_agreement.anvil_access_group
)
access_group_table.columns["is_group_member"].column.verbose_name = "In access group?"
upload_group_table = UserAccountSingleGroupMembershipTable(
self.object.uploaders.all(), managed_group=self.object.anvil_upload_group
)
upload_group_table.columns["is_group_member"].column.verbose_name = "In upload group?"
return (
UserAccountSingleGroupMembershipTable(
self.object.signed_agreement.accessors.all(),
managed_group=self.object.signed_agreement.anvil_access_group,
),
UserAccountSingleGroupMembershipTable(
self.object.uploaders.all(), managed_group=self.object.anvil_upload_group
),
access_group_table,
upload_group_table,
)

def get_object(self, queryset=None):
Expand Down Expand Up @@ -519,9 +524,11 @@ class NonDataAffiliateAgreementDetail(viewmixins.SignedAgreementViewPermissionMi
model = models.NonDataAffiliateAgreement

def get_table(self):
return UserAccountSingleGroupMembershipTable(
access_group_table = UserAccountSingleGroupMembershipTable(
self.object.signed_agreement.accessors.all(), managed_group=self.object.signed_agreement.anvil_access_group
)
access_group_table.columns["is_group_member"].column.verbose_name = "In access group?"
return access_group_table

def get_object(self, queryset=None):
"""Look up the agreement by CDSA cc_id."""
Expand Down
8 changes: 5 additions & 3 deletions primed/dbgap/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,13 @@ def get_latest_snapshot(self):
return None

def get_tables(self):
access_group_table = UserAccountSingleGroupMembershipTable(
self.object.collaborators.all(), managed_group=self.object.anvil_access_group
)
access_group_table.columns["is_group_member"].column.verbose_name = "In access group?"
return (
tables.dbGaPDataAccessSnapshotTable(self.object.dbgapdataaccesssnapshot_set.all()),
UserAccountSingleGroupMembershipTable(
self.object.collaborators.all(), managed_group=self.object.anvil_access_group
),
access_group_table,
)

def get_context_data(self, *args, **kwargs):
Expand Down
51 changes: 51 additions & 0 deletions primed/primed_anvil/adapters.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from anvil_consortium_manager.adapters.account import BaseAccountAdapter
from anvil_consortium_manager.adapters.managed_group import BaseManagedGroupAdapter
from anvil_consortium_manager.models import (
GroupGroupMembership,
ManagedGroup,
WorkspaceGroupSharing,
)
from anvil_consortium_manager.tables import ManagedGroupStaffTable
from django.conf import settings
from django.db.models import Q

Expand Down Expand Up @@ -77,3 +79,52 @@ def after_anvil_create(self, workspace):
can_compute=True,
)
sharing.anvil_create_or_update()

def after_anvil_import(self, workspace):
super().after_anvil_import(workspace)
# # Check if the workspace is already shared with the ADMINs group.
try:
admins_group = ManagedGroup.objects.get(name=settings.ANVIL_CC_ADMINS_GROUP_NAME)
except ManagedGroup.DoesNotExist:
return
try:
sharing = WorkspaceGroupSharing.objects.get(
workspace=workspace,
group=admins_group,
)
except WorkspaceGroupSharing.DoesNotExist:
sharing = WorkspaceGroupSharing.objects.create(
workspace=workspace,
group=admins_group,
access=WorkspaceGroupSharing.OWNER,
can_compute=True,
)
sharing.save()
sharing.anvil_create_or_update()
else:
# If the existing sharing record exists, make sure it has the correct permissions.
if not sharing.can_compute or sharing.access != WorkspaceGroupSharing.OWNER:
sharing.can_compute = True
sharing.access = WorkspaceGroupSharing.OWNER
sharing.save()
sharing.anvil_create_or_update()


class ManagedGroupAdapter(BaseManagedGroupAdapter):
"""Adapter for ManagedGroups."""

list_table_class = ManagedGroupStaffTable

def after_anvil_create(self, managed_group):
super().after_anvil_create(managed_group)
# Add the ADMINs group as an admin of the auth domain.
try:
admins_group = ManagedGroup.objects.get(name=settings.ANVIL_CC_ADMINS_GROUP_NAME)
except ManagedGroup.DoesNotExist:
return
membership = GroupGroupMembership.objects.create(
parent_group=managed_group,
child_group=admins_group,
role=GroupGroupMembership.ADMIN,
)
membership.anvil_create()
2 changes: 1 addition & 1 deletion primed/primed_anvil/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class UserAccountSingleGroupMembershipTable(UserAccountTable):
class Meta(UserAccountTable.Meta):
pass

is_group_member = tables.BooleanColumn(verbose_name="Has access?", default=False)
is_group_member = tables.BooleanColumn(default=False)

def __init__(self, *args, managed_group=None, **kwargs):
if managed_group is None:
Expand Down
Loading

0 comments on commit dd84092

Please sign in to comment.