Skip to content

Commit

Permalink
Add admin action for easy deactivation of users (#6314)
Browse files Browse the repository at this point in the history
Minor quality of life improvement which helps managing status of users.
  • Loading branch information
pktiuk authored Sep 11, 2023
1 parent 6826dda commit 705db7b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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

0 comments on commit 705db7b

Please sign in to comment.