forked from ubccr/coldfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from fasrc/cp_minor_tweaks
minor tweaks
- Loading branch information
Showing
4 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
coldfront/core/allocation/management/commands/change_allocation_project.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters