From 705db7bf7609f006bb6caba8e76ebffd8bc8cea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kotiuk?= Date: Mon, 11 Sep 2023 12:15:32 +0200 Subject: [PATCH] Add admin action for easy deactivation of users (#6314) Minor quality of life improvement which helps managing status of users. --- CHANGELOG.md | 3 ++- cvat/apps/iam/admin.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddaa16139d02..1d1a98afa47e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## \[Unreleased\] ### Added -- TDB + +- Admin actions for easy activation/deactivation of users () ### Changed - TDB diff --git a/cvat/apps/iam/admin.py b/cvat/apps/iam/admin.py index 01a10836e13f..1cfceb19d600 100644 --- a/cvat/apps/iam/admin.py +++ b/cvat/apps/iam/admin.py @@ -8,6 +8,7 @@ from django.utils.translation import gettext_lazy as _ class CustomUserAdmin(UserAdmin): + list_display = ("username", "email", "first_name", "last_name", "is_active", "is_staff") fieldsets = ( (None, {'fields': ('username', 'password')}), (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}), @@ -24,6 +25,20 @@ class CustomUserAdmin(UserAdmin): }, ), ) + actions = ["user_activate", "user_deactivate"] + + @admin.action( + permissions=["change"], description=_("Mark selected users as active") + ) + def user_activate(self, request, queryset): + queryset.update(is_active=True) + + @admin.action( + permissions=["change"], description=_("Mark selected users as not active") + ) + def user_deactivate(self, request, queryset): + queryset.update(is_active=False) + class CustomGroupAdmin(GroupAdmin): fieldsets = ((None, {'fields': ('name',)}),)