diff --git a/coldfront/core/allocation/templates/allocation/allocation_detail.html b/coldfront/core/allocation/templates/allocation/allocation_detail.html index 4a95a2839..ff8ddaf02 100644 --- a/coldfront/core/allocation/templates/allocation/allocation_detail.html +++ b/coldfront/core/allocation/templates/allocation/allocation_detail.html @@ -461,6 +461,12 @@

Users in Al {% for user in allocation_users %} + {% if user.unit not "CPU Hours" %} + {% user.usage_bytes as userusage %} + {% allocation.usage_exact as allocationusage %} + {% else %} + {% user.usage_bytes as userusage %} + {% endif %} {{ user.user.first_name }} {{ user.user.last_name }} @@ -471,20 +477,22 @@

Users in Al {% else %} {{ user.status.name }} {% endif %} - {% if user.usage_bytes == 0.0 %} - 0 bytes - {% else %} - {{ user.usage|floatformat:1 }}{{ user.unit }} - {% endif %} - {% if allocation.usage_exact == None or allocation.usage_exact == 0 %} - 0 + + {% if userusage is None %} + 0 {{ user.unit }} + {% else %} + {{ user.usage|floatformat:1 }}{{ user.unit }} + {% endif %} + + {% if allocationusage == None or allocationusage == 0 %} + 0 {% else %} - {{user.usage_bytes|div:allocation.usage_exact|mul:100|floatformat:2 }}% + {{userusage|div:allocationusage|mul:100|floatformat:2 }}% {% endif %} - {% if "Cluster" in allocation.get_parent_resource.resource_type.name %} - {% cost_cpuhours user.usage as cost %} + {% if if user.unit not "CPU Hours" %} + {% cost_cpuhours userusage as cost %} {% else %} - {% cost_bytes user.usage_bytes as cost %} + {% cost_bytes userusage as cost %} {% endif %} {% if cost %} {{ cost }} diff --git a/coldfront/plugins/slurm/management/commands/slurm_sync.py b/coldfront/plugins/slurm/management/commands/slurm_sync.py index c96017854..3a5bb9fe4 100644 --- a/coldfront/plugins/slurm/management/commands/slurm_sync.py +++ b/coldfront/plugins/slurm/management/commands/slurm_sync.py @@ -121,5 +121,7 @@ def handle(self, *args, **options): continue alloc_user, _ = allocation_obj.allocationuser_set.get_or_create( user = get_user_model().objects.get(username=user_name), - defaults = {'status': auser_status_active} + defaults = { + 'status': auser_status_active, "unit": "CPU Hours" + } ) diff --git a/coldfront/plugins/xdmod/management/commands/xdmod_usage.py b/coldfront/plugins/xdmod/management/commands/xdmod_usage.py index 5f83a7dda..1c608ee09 100644 --- a/coldfront/plugins/xdmod/management/commands/xdmod_usage.py +++ b/coldfront/plugins/xdmod/management/commands/xdmod_usage.py @@ -295,6 +295,7 @@ def process_total_cpu_hours(self): for user in s.allocationuser_set.all(): if user.user.username in usage_data: user.usage = usage_data[user.user.username] + user.unit = "CPU Hours" user.save() if self.sync: cpu_hours_attr = s.allocationattribute_set.get(