Skip to content

Commit

Permalink
add subscription admin.
Browse files Browse the repository at this point in the history
  • Loading branch information
soasme committed Apr 27, 2017
1 parent df1cb38 commit 01fd591
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
18 changes: 17 additions & 1 deletion wikisensei/subscription/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 12 additions & 0 deletions wikisensei/subscription/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion wikisensei/subscription/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down

0 comments on commit 01fd591

Please sign in to comment.