Merged in feature/VBV-722-resend-confirmation (pull request #377)
Add resend payment confirmation action
This commit is contained in:
commit
ae747384db
|
|
@ -1,8 +1,9 @@
|
|||
from django.contrib import admin
|
||||
|
||||
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.views import send_vv_welcome_email
|
||||
|
||||
|
||||
@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"
|
||||
)
|
||||
|
||||
@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
|
||||
def customer(obj):
|
||||
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")
|
||||
date_hierarchy = "created_at"
|
||||
actions = [abacus_upload_order, sync_transaction_state]
|
||||
actions = [abacus_upload_order, sync_transaction_state, resend_payment_confirmation]
|
||||
readonly_fields = [
|
||||
"user",
|
||||
"transaction_id",
|
||||
|
|
|
|||
Loading…
Reference in New Issue