Skip to content

Commit

Permalink
give department approvers user permissions for child projects
Browse files Browse the repository at this point in the history
  • Loading branch information
claire-peters committed Oct 16, 2024
1 parent 5bc4781 commit a0ab227
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 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 coldfront.core.department.models import DepartmentProject
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,14 @@ 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
department = DepartmentProject.objects.get(project=self).department
for parent_department in department.parents.filter(org_tree='Research Computing Storage Billing'):
if user in parent_department.useraffiliation_set.filter(role='approver'):
permissions.append(ProjectPermission.USER)

return permissions

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

0 comments on commit a0ab227

Please sign in to comment.