-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4602cb
commit 0a70bb8
Showing
1 changed file
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
from django.contrib import admin | ||
from unfold.admin import ModelAdmin | ||
|
||
# Register your models here. | ||
from actions.models import Action | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
@admin.register(Action) | ||
class ServiceAdmin(ModelAdmin): | ||
list_display = ("name", "service", "handler", "is_active") | ||
search_fields = ("name", "service__name", "handler") | ||
list_filter = ("is_active",) | ||
actions = ["make_active", "make_inactive"] | ||
readonly_fields = ("created_at", "updated_at", "order") | ||
|
||
@admin.action(description=_("Make selected Services active")) | ||
def make_active(self, request, queryset): | ||
queryset.update(is_active=True) | ||
self.message_user(request, _("Selected Services are now active."), "success") | ||
|
||
@admin.action(description=_("Make selected Services inactive")) | ||
def make_inactive(self, request, queryset): | ||
queryset.update(is_active=False) | ||
self.message_user(request, _("Selected Services are now inactive."), "success") |