From 944ece6b9efc230b62ae33b0e0ff80341e6ef51e Mon Sep 17 00:00:00 2001 From: claire-peters Date: Wed, 11 Dec 2024 19:57:52 -0500 Subject: [PATCH 1/4] add command for changing allocation project --- .../commands/change_allocation_project.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 coldfront/core/allocation/management/commands/change_allocation_project.py diff --git a/coldfront/core/allocation/management/commands/change_allocation_project.py b/coldfront/core/allocation/management/commands/change_allocation_project.py new file mode 100644 index 000000000..a17abf8ad --- /dev/null +++ b/coldfront/core/allocation/management/commands/change_allocation_project.py @@ -0,0 +1,22 @@ +"""Change the Project of the Allocation with the given ID to the project with the given title.""" +from django.core.management.base import BaseCommand +from coldfront.core.allocation.models import Allocation +from coldfront.core.project.models import Project + +class Command(BaseCommand): + help = 'Change the Project of the Allocation with the given ID to the project with the given title.' + + def add_arguments(self, parser): + parser.add_argument('allocation_id', type=int) + parser.add_argument('project_title', type=str) + + def handle(self, *args, **options): + allocation_id = options['allocation_id'] + project_title = options['project_title'] + allocation = Allocation.objects.get(pk=allocation_id) + project = Project.objects.get(title=project_title) + allocation.project = project + allocation.save() + self.stdout.write(self.style.SUCCESS(f'Allocation {allocation_id} is now in project {project_title}')) + return + From d823c87c97a6cf68804c9619cd22b074e359a304 Mon Sep 17 00:00:00 2001 From: claire-peters Date: Wed, 11 Dec 2024 19:58:26 -0500 Subject: [PATCH 2/4] add help_page link to user role docs --- coldfront/core/portal/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coldfront/core/portal/views.py b/coldfront/core/portal/views.py index 19004605d..cd3921e51 100644 --- a/coldfront/core/portal/views.py +++ b/coldfront/core/portal/views.py @@ -203,6 +203,10 @@ def help_page(request): 'href': 'coldfront-allocation-management', 'title': 'Coldfront Usage Guide', }, + { + 'href': 'roles-responsibilities', + 'title': 'Project User Roles Overview', + }, ], 'Storage Documentation':[ { From 5375950541459149209bde36fb3cbb7f3a3014bf Mon Sep 17 00:00:00 2001 From: claire-peters Date: Wed, 11 Dec 2024 19:59:21 -0500 Subject: [PATCH 3/4] add logging to core utils file --- coldfront/core/utils/fasrc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coldfront/core/utils/fasrc.py b/coldfront/core/utils/fasrc.py index 02fe034c3..9bcce0dfa 100644 --- a/coldfront/core/utils/fasrc.py +++ b/coldfront/core/utils/fasrc.py @@ -2,6 +2,7 @@ """ import os import json +import logging import operator from functools import reduce from datetime import datetime @@ -15,6 +16,7 @@ from coldfront.core.project.models import Project from coldfront.core.resource.models import Resource +logger = logging.getLogger(__name__) MISSING_DATA_DIR = './local_data/missing/' @@ -74,7 +76,7 @@ def select_one_project_allocation(project_obj, resource_obj, dirpath): return allocations[0] elif len(allocations) > 1: print(allocations) - logger.exception('multiple allocations found for project/resource/path pairing: %s', allocations) + logger.exception('multiple allocations found for project/resource/path pairing: %s %s', allocations, allocations[0].path) raise Exception('multiple allocations found for project/resource/path pairing') def determine_size_fmt(byte_num): From 60e34a42a6757000507f8da66b18d33ec276a94d Mon Sep 17 00:00:00 2001 From: claire-peters Date: Wed, 11 Dec 2024 20:02:20 -0500 Subject: [PATCH 4/4] show is_public instead of is_allocatable resources in allocation request form --- coldfront/core/allocation/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coldfront/core/allocation/forms.py b/coldfront/core/allocation/forms.py index fc3b63a5a..44bcb8135 100644 --- a/coldfront/core/allocation/forms.py +++ b/coldfront/core/allocation/forms.py @@ -308,7 +308,7 @@ class AllocationSearchForm(forms.Form): resource_name = forms.ModelMultipleChoiceField( label='Resource Name', queryset=Resource.objects.filter( - is_allocatable=True).order_by(Lower('name')), + is_public=True).order_by(Lower('name')), required=False) allocation_attribute_name = forms.ModelChoiceField( label='Allocation Attribute Name',