Skip to content

Commit

Permalink
This commit fixes issue ubccr#193 and it shows freeipad group/slurmac…
Browse files Browse the repository at this point in the history
…count name
  • Loading branch information
bhatiadheeraj committed Oct 27, 2020
1 parent 91ae1d9 commit 3ea77ee
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion coldfront/core/project/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,29 @@ def __init__(self, request_user, project_pk, *args, **kwargs):
allocation_choices = [(allocation.id, "%s (%s) %s" % (allocation.get_parent_resource.name, allocation.get_parent_resource.resource_type.name,
allocation.description if allocation.description else '')) for allocation in allocation_query_set]
allocation_choices.insert(0, ('__select_all__', 'Select All'))
print(allocation_choices)
allocation_choices_2 = []
# print(type(allocation_choices)) list
# print(type(allocation_choices[1])) tuple
for allocation in allocation_query_set:
allocation_obj = ()
# slurm_account_name
if(allocation.get_attribute("slurm_account_name")):
print(allocation.get_attribute("slurm_account_name"))
allocation_obj = allocation_obj + (allocation.get_attribute("slurm_account_name"),)
else:
with_grp_filter = [x for x in allocation.get_attribute_list("freeipa_group") if x.startswith("grp-")]
allocation_obj = allocation_obj + (with_grp_filter,)
allocation_obj = (allocation.id, "%s (%s) %s %s" %(allocation.get_parent_resource.name,allocation.get_parent_resource.resource_type.name,
allocation.description if allocation.description else '', allocation_obj))

allocation_choices_2.append(allocation_obj)

allocation_choices_2.insert(0, ('__select_all__', 'Select All', ""))
print(allocation_choices_2)

if allocation_query_set:
self.fields['allocation'].choices = allocation_choices
self.fields['allocation'].choices = allocation_choices_2
self.fields['allocation'].help_text = '<br/>Select allocations to add selected users to.'
else:
self.fields['allocation'].widget = forms.HiddenInput()
Expand Down

0 comments on commit 3ea77ee

Please sign in to comment.