Added DonatorStatus model in order to know if an donator has canceled or not his monthly donation, Now we create a DonatorStatus for the user after receiving his first donation. Added DonatorStatus view. Added donator_status.html in order to allow an user view his donation status , Added action to allow user to cancel his monthly donations. Now the user can logout using navbar. added Donation model to admin.Added command make_donations_charges in order to create stripe current monthly donations from all donators
This commit is contained in:
parent
cb520f6b58
commit
4580a75f89
22 changed files with 611 additions and 232 deletions
|
|
@ -1,15 +1,28 @@
|
|||
from django.db import models
|
||||
from membership.models import CustomUser
|
||||
from membership.models import StripeCustomer, CustomUser
|
||||
from utils.models import BillingAddress
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class DonatorStatus(models.Model):
|
||||
ACTIVE = 'active'
|
||||
CANCELED = 'canceled'
|
||||
|
||||
STATUS_CHOICES = (
|
||||
(ACTIVE, 'Active'),
|
||||
(CANCELED, 'Canceled')
|
||||
)
|
||||
user = models.OneToOneField(CustomUser)
|
||||
status = models.CharField(choices=STATUS_CHOICES, max_length=10, default=ACTIVE)
|
||||
|
||||
@classmethod
|
||||
def create(cls, user):
|
||||
cls.objects.get_or_create(user=user)
|
||||
|
||||
|
||||
class Donation(models.Model):
|
||||
|
||||
donation = models.FloatField()
|
||||
donator = models.ForeignKey(CustomUser)
|
||||
donator = models.ForeignKey(StripeCustomer)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
billing_address = models.ForeignKey(BillingAddress)
|
||||
last4 = models.CharField(max_length=4)
|
||||
|
|
@ -20,3 +33,9 @@ class Donation(models.Model):
|
|||
def create(cls, data):
|
||||
obj = cls.objects.create(**data)
|
||||
return obj
|
||||
|
||||
def set_stripe_charge(self, stripe_charge):
|
||||
self.stripe_charge_id = stripe_charge.id
|
||||
self.last4 = stripe_charge.source.last4
|
||||
self.cc_brand = stripe_charge.source.brand
|
||||
self.save
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue