Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add admin action for easy deactivation of users #6314

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<https://github.com/opencv/cvat/pull/6314>)

### Changed
- TDB
Expand Down
15 changes: 15 additions & 0 deletions cvat/apps/iam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}),
Expand All @@ -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',)}),)
Expand Down
Loading