replace string with enum
This commit is contained in:
@@ -308,7 +308,7 @@ class BillAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
@admin.display(description="QR Code")
|
@admin.display(description="QR Code")
|
||||||
def get_qrcode(self, obj):
|
def get_qrcode(self, obj):
|
||||||
if obj.status != "C":
|
if obj.status != Bill.Status.CLEARED:
|
||||||
return "-"
|
return "-"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -335,10 +335,10 @@ class BillAdmin(admin.ModelAdmin):
|
|||||||
def status_colored(self, obj):
|
def status_colored(self, obj):
|
||||||
# TODO: if there is a status without color, set nothing.
|
# TODO: if there is a status without color, set nothing.
|
||||||
colors = {
|
colors = {
|
||||||
"S": "red",
|
Bill.Status.SUBMITTED: "red",
|
||||||
"C": "darkorange",
|
Bill.Status.CLEARED: "darkorange",
|
||||||
"F": "green",
|
Bill.Status.FINISHED: "green",
|
||||||
"I": "blue",
|
Bill.Status.INCOMPLETED: "blue",
|
||||||
}
|
}
|
||||||
return format_html(
|
return format_html(
|
||||||
f'<b style="background:{colors[obj.status]};">{obj.get_status_display()}</b>'
|
f'<b style="background:{colors[obj.status]};">{obj.get_status_display()}</b>'
|
||||||
@@ -346,7 +346,7 @@ class BillAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
@admin.action(description="Als 'Abgerechnet' markieren.")
|
@admin.action(description="Als 'Abgerechnet' markieren.")
|
||||||
def make_cleared(self, request, queryset):
|
def make_cleared(self, request, queryset):
|
||||||
updated = queryset.update(status="C")
|
updated = queryset.update(status=Bill.Status.CLEARED)
|
||||||
self.message_user(
|
self.message_user(
|
||||||
request,
|
request,
|
||||||
ngettext(
|
ngettext(
|
||||||
@@ -360,7 +360,7 @@ class BillAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
@admin.action(description="Als 'Abgeschlossen' markieren.")
|
@admin.action(description="Als 'Abgeschlossen' markieren.")
|
||||||
def make_finished(self, request, queryset):
|
def make_finished(self, request, queryset):
|
||||||
updated = queryset.update(status="F")
|
updated = queryset.update(status=Bill.Status.FINISHED)
|
||||||
self.message_user(
|
self.message_user(
|
||||||
request,
|
request,
|
||||||
ngettext(
|
ngettext(
|
||||||
|
|||||||
Reference in New Issue
Block a user