Skip to content

Commit

Permalink
Disable removing users from locked allocations and remove from list o…
Browse files Browse the repository at this point in the history
…f allocations a new user can be added to
  • Loading branch information
mkzia committed Dec 16, 2019
1 parent 97f6a17 commit 44219b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions coldfront/core/allocation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,12 @@ def test_func(self):
def dispatch(self, request, *args, **kwargs):
allocation_obj = get_object_or_404(
Allocation, pk=self.kwargs.get('pk'))

if allocation_obj.is_locked and not self.request.user.is_superuser:
messages.error(
request, 'You cannot modify this allocation because it is locked! Contact support for details.')
return HttpResponseRedirect(reverse('allocation-detail', kwargs={'pk': allocation_obj.pk}))

if allocation_obj.status.name not in ['Active', 'New', 'Renewal Requested', ]:
messages.error(request, 'You cannot remove users from a allocation with status {}.'.format(
allocation_obj.status.name))
Expand Down
2 changes: 1 addition & 1 deletion coldfront/core/project/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, request_user, project_pk, *args, **kwargs):
project_obj = get_object_or_404(Project, pk=project_pk)

allocation_query_set = project_obj.allocation_set.filter(
status__name__in=['Active', 'New', 'Renewal Requested', ], resources__is_allocatable=True)
status__name__in=['Active', 'New', 'Renewal Requested', ], resources__is_allocatable=True, is_locked=False)
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'))
Expand Down

0 comments on commit 44219b4

Please sign in to comment.