Skip to content

Commit

Permalink
Merge pull request #346 from fasrc/cp_deptmanagerpermissions
Browse files Browse the repository at this point in the history
give department approvers user permissions for child projects
  • Loading branch information
claire-peters authored Dec 10, 2024
2 parents f83f3c9 + e61f48b commit 0a3d63f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions coldfront/core/project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from model_utils.models import TimeStampedModel
from simple_history.models import HistoricalRecords

from ifxuser.models import Organization
from coldfront.core.field_of_science.models import FieldOfScience
from coldfront.core.utils.common import import_from_settings

Expand Down Expand Up @@ -214,6 +215,17 @@ def user_permissions(self, user):

if self.pi.id == user.id:
permissions.append(ProjectPermission.PI)

# if the user is an approver in a department connected to the project,
# give them user permissions
departments = Organization.objects.filter(
org_tree='Research Computing Storage Billing'
)
proj_departments = [d for d in departments if self in d.get_projects()]
for department in proj_departments:
if user in department.useraffiliation_set.filter(role='approver'):
permissions.append(ProjectPermission.USER)

return permissions

def has_perm(self, user, perm):
Expand Down

0 comments on commit 0a3d63f

Please sign in to comment.