Skip to content

Commit

Permalink
fix Promotion code (dj-stripe#2083)
Browse files Browse the repository at this point in the history
* rm created prpoerty as it clashed with created field

* add promotion code to model namespace

* add promotion code admin
  • Loading branch information
abe-101 committed Jun 25, 2024
1 parent f271062 commit f6de504
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 7 additions & 0 deletions djstripe/admin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ def get_queryset(self, request):
return super().get_queryset(request).prefetch_related("prices")


@admin.register(models.PromotionCode)
class PromotionCodeAdmin(StripeModelAdmin):
list_display = ("code", "active", "created", "times_redeemed", "max_redemptions")
search_fields = ("code",)
list_filter = ("active", "created")


@admin.register(models.Refund)
class RefundAdmin(StripeModelAdmin):
list_display = (
Expand Down
2 changes: 2 additions & 0 deletions djstripe/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
InvoiceItem,
LineItem,
Plan,
PromotionCode,
ShippingRate,
Subscription,
SubscriptionItem,
Expand Down Expand Up @@ -72,6 +73,7 @@
"Plan",
"Price",
"Product",
"PromotionCode",
"Refund",
"ShippingRate",
"ScheduledQueryRun",
Expand Down
5 changes: 0 additions & 5 deletions djstripe/models/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,6 @@ def code(self) -> str:
def active(self) -> str:
return self.stripe_data["active"]

# https://docs.stripe.com/api/promotion_codes/object#promotion_code_object-created
@property
def created(self):
return self.stripe_data["created"]

# https://docs.stripe.com/api/promotion_codes/object#promotion_code_object-times_redeemed
@property
def times_redeemed(self) -> int:
Expand Down

0 comments on commit f6de504

Please sign in to comment.