diff --git a/coldfront/core/project/forms.py b/coldfront/core/project/forms.py index 3c2c88edd1..e29b76d766 100644 --- a/coldfront/core/project/forms.py +++ b/coldfront/core/project/forms.py @@ -46,6 +46,16 @@ class ProjectAddUserForm(forms.Form): selected = forms.BooleanField(initial=False, required=False) +class ProjectReactivateUserForm(forms.Form): + username = forms.CharField(max_length=150, disabled=True) + first_name = forms.CharField(max_length=150, required=False, disabled=True) + last_name = forms.CharField(max_length=150, required=False, disabled=True) + email = forms.EmailField(max_length=100, required=False, disabled=True) + role = forms.ModelChoiceField( + queryset=ProjectUserRoleChoice.objects.all(), required=False, empty_label=None) + selected = forms.BooleanField(initial=False, required=False) + + class ProjectAddUsersToAllocationForm(forms.Form): allocation = forms.MultipleChoiceField( widget=forms.CheckboxSelectMultiple(attrs={'checked': 'checked'}), required=False) @@ -55,9 +65,17 @@ 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( - resources__is_allocatable=True, is_locked=False, status__name__in=PENDING_ACTIVE_ALLOCATION_STATUSES).distinct() - 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] + resources__is_allocatable=True, is_locked=False, + status__name__in=PENDING_ACTIVE_ALLOCATION_STATUSES + ).distinct() + 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_sorted = [] allocation_choices_sorted = sorted(allocation_choices, key=lambda x: x[1][0].lower()) allocation_choices.insert(0, ('__select_all__', 'Select All')) @@ -74,6 +92,7 @@ class ProjectRemoveUserForm(forms.Form): last_name = forms.CharField(max_length=150, required=False, disabled=True) email = forms.EmailField(max_length=100, required=False, disabled=True) role = forms.CharField(max_length=30, disabled=True) + primary_group = forms.BooleanField(required=False, disabled=True) selected = forms.BooleanField(initial=False, required=False) diff --git a/coldfront/core/project/management/commands/add_default_project_choices.py b/coldfront/core/project/management/commands/add_default_project_choices.py index d66e03b46a..ddcaca7271 100644 --- a/coldfront/core/project/management/commands/add_default_project_choices.py +++ b/coldfront/core/project/management/commands/add_default_project_choices.py @@ -21,7 +21,9 @@ def handle(self, *args, **options): for choice in ['User', 'General Manager', 'Storage Manager', 'Access Manager', 'PI']: ProjectUserRoleChoice.objects.get_or_create(name=choice) - for choice in ['Active', 'Pending - Add', 'Pending - Remove', 'Denied', 'Removed', ]: + for choice in [ + 'Active', 'Pending - Add', 'Pending - Remove', 'Denied', 'Removed', 'Deactivated' + ]: ProjectUserStatusChoice.objects.get_or_create(name=choice) for attribute_type in ('Date', 'Float', 'Int', 'Text', 'Yes/No'): diff --git a/coldfront/core/project/signals.py b/coldfront/core/project/signals.py index c7982c2720..08a3840972 100644 --- a/coldfront/core/project/signals.py +++ b/coldfront/core/project/signals.py @@ -1,5 +1,9 @@ +import logging import django.dispatch +log = logging.getLogger(__name__) + + project_create = django.dispatch.Signal() #providing_args=["project_title"] project_post_create = django.dispatch.Signal() @@ -11,6 +15,8 @@ project_preremove_projectuser = django.dispatch.Signal() #providing_args=["user_name", "group_name"] +project_reactivate_projectuser = django.dispatch.Signal() + project_filter_users_to_remove = django.dispatch.Signal() #providing_args=["project_user_list"] # return tuple of (no_removal, can_remove) diff --git a/coldfront/core/project/templates/project/project_add_users.html b/coldfront/core/project/templates/project/project_add_users.html index dbc3da18cd..6316481af3 100644 --- a/coldfront/core/project/templates/project/project_add_users.html +++ b/coldfront/core/project/templates/project/project_add_users.html @@ -44,6 +44,51 @@
+ The following users, which had this lab's AD Group as their primary group, are currently disabled. + You can reenable them by selecting them and clicking "Reactivate Users" below. +
+@@ -17,10 +17,17 @@
- To be removed from a lab, the user must not have the lab as their primary - group. If you would like to remove a user that has your lab as their primary - group, please - contact FASRC support. + {% if request.user.is_superuser %} + As a superuser, you can remove any user from the project. Please be aware that + removing a user from their primary group will cause their account to be deactivated and + prevent access to computational resources. If you are unsure, please + contact FASRC support or the ColdFront system administrator. + {% else %} + To be removed from a lab, the user must not have the lab as their primary + group. If you would like to remove a user that has your lab as their primary + group, please + contact FASRC support. + {% endif %}