Skip to content

Commit

Permalink
docs: display label (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav committed Jul 20, 2023
1 parent 037fa2d commit 8d0920a
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,23 @@ class UserAdmin(ModelAdmin):
@display(
description=_("Status"),
ordering="status",
label=True,
mapping={
UserStatus.ACTIVE: "success",
UserStatus.PENDING: "info",
UserStatus.INACTIVE: "warning",
UserStatus.CANCELLED: "danger",
label=True
)
def show_status_default_color(self, obj):
return obj.status


@display(
description=_("Status"),
ordering="status",
label={
UserStatus.ACTIVE: "success", # green
UserStatus.PENDING: "info", # blue
UserStatus.INACTIVE: "warning", # orange
UserStatus.CANCELLED: "danger", # red
},
)
def show_status(self, obj):
def show_status_customized_color(self, obj)
return obj.status

@display(description=_("Status with label"), ordering="status", label=True)
Expand Down

0 comments on commit 8d0920a

Please sign in to comment.