wip: product admin
This commit is contained in:
parent
be160f5fa7
commit
cf329e5046
|
|
@ -1,13 +1,29 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from vbv_lernwelt.shop.models import CheckoutInformation, Country
|
from vbv_lernwelt.shop.models import CheckoutInformation, Country, Product
|
||||||
|
from vbv_lernwelt.shop.services import DataTransPaymentProvider
|
||||||
|
|
||||||
|
|
||||||
@admin.action(description="Create invoice for selected checkouts")
|
@admin.action(description="ABACUS: Create invoices")
|
||||||
def generate_invoice(modeladmin, request, queryset):
|
def generate_invoice(modeladmin, request, queryset):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@admin.action(description="DATATRANS: Sync transaction states")
|
||||||
|
def sync_transaction_state(modeladmin, request, queryset):
|
||||||
|
for checkout in queryset:
|
||||||
|
state = DataTransPaymentProvider().get_transaction_state(
|
||||||
|
transaction_id=checkout.transaction_id
|
||||||
|
)
|
||||||
|
print(state)
|
||||||
|
checkout.state = state.value
|
||||||
|
checkout.save(
|
||||||
|
update_fields=[
|
||||||
|
"state",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(CheckoutInformation)
|
@admin.register(CheckoutInformation)
|
||||||
class CheckoutInformationAdmin(admin.ModelAdmin):
|
class CheckoutInformationAdmin(admin.ModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
|
|
@ -19,7 +35,7 @@ class CheckoutInformationAdmin(admin.ModelAdmin):
|
||||||
"state",
|
"state",
|
||||||
"invoice_transmitted_at",
|
"invoice_transmitted_at",
|
||||||
)
|
)
|
||||||
actions = [generate_invoice]
|
actions = [generate_invoice, sync_transaction_state]
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Country)
|
@admin.register(Country)
|
||||||
|
|
@ -30,3 +46,13 @@ class CountryAdmin(admin.ModelAdmin):
|
||||||
"name_fr",
|
"name_fr",
|
||||||
"name_it",
|
"name_it",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Product)
|
||||||
|
class ProductAdmin(admin.ModelAdmin):
|
||||||
|
list_display = (
|
||||||
|
"sku",
|
||||||
|
"name",
|
||||||
|
"price",
|
||||||
|
"description",
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue