diff --git a/wikisensei/subscription/admin.py b/wikisensei/subscription/admin.py index 13be29d..d7ee3c6 100644 --- a/wikisensei/subscription/admin.py +++ b/wikisensei/subscription/admin.py @@ -2,5 +2,21 @@ from __future__ import unicode_literals from django.contrib import admin +from .models import Customer, Subscription, SubscriptionEvent, WebhookEvent -# Register your models here. +class CustomerAdmin(admin.ModelAdmin): + pass + +class SubscriptionAdmin(admin.ModelAdmin): + pass + +class SubscriptionEventAdmin(admin.ModelAdmin): + pass + +class WebhookEventAdmin(admin.ModelAdmin): + pass + +admin.site.register(Customer, CustomerAdmin) +admin.site.register(Subscription, SubscriptionAdmin) +admin.site.register(SubscriptionEvent, SubscriptionEventAdmin) +admin.site.register(WebhookEvent, WebhookEventAdmin) diff --git a/wikisensei/subscription/models.py b/wikisensei/subscription/models.py index a6ceb83..682fb75 100644 --- a/wikisensei/subscription/models.py +++ b/wikisensei/subscription/models.py @@ -27,17 +27,29 @@ class Customer(models.Model): stripe_id = models.CharField(max_length=64) created_at = models.DateTimeField(auto_now_add=True) + def __str__(self): + return 'customer-' + self.user.username + class Subscription(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) stripe_id = models.CharField(max_length=64) created_at = models.DateTimeField(auto_now_add=True) + def __str__(self): + return 'subscription-' + self.user.username + class SubscriptionEvent(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) data = models.TextField() created_at = models.DateTimeField(auto_now_add=True) + def __str__(self): + return 'subscription_event-' + self.user.username + class WebhookEvent(models.Model): stripe_id = models.CharField(max_length=64, unique=True) data = models.TextField() created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return 'webhook-' + self.stripe_id diff --git a/wikisensei/subscription/services.py b/wikisensei/subscription/services.py index ef8f733..3545daa 100644 --- a/wikisensei/subscription/services.py +++ b/wikisensei/subscription/services.py @@ -19,7 +19,6 @@ def ensure_customer(user): except Customer.DoesNotExist: # Create a new customer if not exists _customer = stripe.Customer.create( - id=user.id, email=user.email, )