Add resend payment confirmation action
This commit is contained in:
parent
9bd0af45a3
commit
e903268753
|
|
@ -1,8 +1,9 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from vbv_lernwelt.shop.invoice.abacus import abacus_ssh_upload
|
from vbv_lernwelt.shop.invoice.abacus import abacus_ssh_upload
|
||||||
from vbv_lernwelt.shop.models import CheckoutInformation, Product
|
from vbv_lernwelt.shop.models import CheckoutInformation, CheckoutState, Product
|
||||||
from vbv_lernwelt.shop.services import get_transaction_state
|
from vbv_lernwelt.shop.services import get_transaction_state
|
||||||
|
from vbv_lernwelt.shop.views import send_vv_welcome_email
|
||||||
|
|
||||||
|
|
||||||
@admin.action(description="DATATRANS: Sync transaction states")
|
@admin.action(description="DATATRANS: Sync transaction states")
|
||||||
|
|
@ -30,6 +31,24 @@ class CheckoutInformationAdmin(admin.ModelAdmin):
|
||||||
request, f"Beim SFTP upload ist ein Fehler aufgetreten", level="error"
|
request, f"Beim SFTP upload ist ein Fehler aufgetreten", level="error"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@admin.action(description="Buchungsbestätigung: Bestätigung erneut senden")
|
||||||
|
def resend_payment_confirmation(self, request, queryset):
|
||||||
|
for ci in queryset:
|
||||||
|
if ci.state != CheckoutState.PAID.value:
|
||||||
|
self.message_user(
|
||||||
|
request,
|
||||||
|
f"Die Buchung mit der ID {ci.transaction_id} ist nicht bezahlt",
|
||||||
|
level="error",
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
send_vv_welcome_email(ci)
|
||||||
|
self.message_user(
|
||||||
|
request,
|
||||||
|
f"Die Buchungsbestätigung für {ci.transaction_id} wurde erneut versendet",
|
||||||
|
level="success",
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def customer(obj):
|
def customer(obj):
|
||||||
return f"{obj.user.first_name} {obj.user.last_name} ({obj.user.email})"
|
return f"{obj.user.first_name} {obj.user.last_name} ({obj.user.email})"
|
||||||
|
|
@ -65,7 +84,7 @@ class CheckoutInformationAdmin(admin.ModelAdmin):
|
||||||
]
|
]
|
||||||
list_filter = ("state", "product_name", "product_sku", "abacus_ssh_upload_done")
|
list_filter = ("state", "product_name", "product_sku", "abacus_ssh_upload_done")
|
||||||
date_hierarchy = "created_at"
|
date_hierarchy = "created_at"
|
||||||
actions = [abacus_upload_order, sync_transaction_state]
|
actions = [abacus_upload_order, sync_transaction_state, resend_payment_confirmation]
|
||||||
readonly_fields = [
|
readonly_fields = [
|
||||||
"user",
|
"user",
|
||||||
"transaction_id",
|
"transaction_id",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue