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

Proposed fix for Allocation with no resources causing issues #604

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
12 changes: 10 additions & 2 deletions coldfront/core/allocation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ def has_perm(self, user, perm):
return perm in perms

def __str__(self):
return "%s (%s)" % (self.get_parent_resource.name, self.project.pi)
parent_resource = self.get_parent_resource
parent_resource_name = "No Resources"
if parent_resource is not None:
parent_resource_name = parent_resource.name
return "%s (%s)" % (parent_resource_name, self.project.pi)

class AllocationAdminNote(TimeStampedModel):
""" An allocation admin note is a note that an admin makes on an allocation.
Expand Down Expand Up @@ -652,7 +656,11 @@ def get_parent_resource(self):
return self.allocation.resources.filter(is_allocatable=True).first()

def __str__(self):
return "%s (%s)" % (self.get_parent_resource.name, self.allocation.project.pi)
parent_resource = self.get_parent_resource
parent_resource_name = "No Resources"
if parent_resource is not None:
parent_resource_name = parent_resource.name
return "%s (%s)" % (parent_resource_name, self.allocation.project.pi)

class AllocationAttributeChangeRequest(TimeStampedModel):
""" An allocation attribute change request represents a request from a PI/ manager to change their allocation attribute.
Expand Down