Skip to content

Commit

Permalink
ubccr#193: Added the 'ALLOCATION_ATTRIBUTE_VIEW_LIST' variable to the…
Browse files Browse the repository at this point in the history
… core.py file which allows users to decide what attributes they want to use to differentiate allocations
  • Loading branch information
brisco17 committed Jul 9, 2021
1 parent da887b1 commit 9dc16d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 5 additions & 0 deletions coldfront/config/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@

ADMIN_COMMENTS_SHOW_EMPTY = ENV.bool('ADMIN_COMMENTS_SHOW_EMPTY', default=True)

#------------------------------------------------------------------------------
# List of Allocation Attributes to display on view page
#------------------------------------------------------------------------------
ALLOCATION_ATTRIBUTE_VIEW_LIST = ENV.list('ALLOCATION_ATTRIBUTE_VIEW_LIST', default=['slurm_account_name', 'freeipa_group', 'Cloud Account Name', ])

#------------------------------------------------------------------------------
# Enable invoice functionality
#------------------------------------------------------------------------------
Expand Down
12 changes: 3 additions & 9 deletions coldfront/core/allocation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@

logger = logging.getLogger(__name__)


ALLOCATION_ATTRIBUTE_VIEW_LIST = import_from_settings(
'ALLOCATION_ATTRIBUTE_VIEW_LIST', [])
ALLOCATION_FUNCS_ON_EXPIRE = import_from_settings(
'ALLOCATION_FUNCS_ON_EXPIRE', [])
SLURM_ACCOUNT_ATTRIBUTE_NAME = import_from_settings(
'SLURM_ACCOUNT_ATTRIBUTE_NAME', 'slurm_account_name')
XDMOD_CLOUD_PROJECT_ATTRIBUTE_NAME = import_from_settings(
'XDMOD_CLOUD_PROJECT_ATTRIBUTE_NAME', 'Cloud Account Name')
UNIX_GROUP_ATTRIBUTE_NAME = import_from_settings(
'FREEIPA_GROUP_ATTRIBUTE_NAME', 'freeipa_group')


class AllocationStatusChoice(TimeStampedModel):
Expand Down Expand Up @@ -105,8 +100,7 @@ def expires_in(self):
def get_information(self):
html_string = ''
for attribute in self.allocationattribute_set.all():

if attribute.allocation_attribute_type.name in [SLURM_ACCOUNT_ATTRIBUTE_NAME, UNIX_GROUP_ATTRIBUTE_NAME, XDMOD_CLOUD_PROJECT_ATTRIBUTE_NAME,]:
if attribute.allocation_attribute_type.name in ALLOCATION_ATTRIBUTE_VIEW_LIST:
html_string += '%s: %s <br>' % (
attribute.allocation_attribute_type.name, attribute.value)

Expand Down

0 comments on commit 9dc16d7

Please sign in to comment.