Skip to content

Commit

Permalink
Add is_active filter and actions to Service admin
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyunar committed Jan 29, 2025
1 parent 99455ac commit 1e45f06
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions registry/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,25 @@ class ServiceAdmin(ModelAdmin):
)
search_fields = ("name", "website")
ordering = ("name",)
list_filter = ("is_active",)
inlines = [ServiceURLInline, ServiceInfoInline]
prepopulated_fields = {"slug": ("name",)}
actions = ["make_active", "make_inactive"]

@admin.display(boolean=True, description=_("Has Image"))
def has_image(self, obj):
return bool(obj.image)

@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")


@admin.register(ServiceURL)
class ServiceURLAdmin(ModelAdmin):
Expand Down

0 comments on commit 1e45f06

Please sign in to comment.