diff --git a/coldfront/core/allocation/models.py b/coldfront/core/allocation/models.py index b89826b2c..df5e00e8c 100644 --- a/coldfront/core/allocation/models.py +++ b/coldfront/core/allocation/models.py @@ -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. @@ -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.