From 1e1a2f6ac2cadfbc57cc855a67498af097391caf Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sat, 19 Oct 2024 19:43:59 +0100 Subject: Changes the Resource to include Stripe reference --- alphabetlearning/payments/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'alphabetlearning/payments/models.py') diff --git a/alphabetlearning/payments/models.py b/alphabetlearning/payments/models.py index 62bcbde..0ad07fb 100644 --- a/alphabetlearning/payments/models.py +++ b/alphabetlearning/payments/models.py @@ -14,13 +14,16 @@ class Product(models.Model): class Price(models.Model): - product = models.ForeignKey(Product, on_delete=models.CASCADE) + resource = models.ForeignKey(Resource, on_delete=models.CASCADE, related_name="price") price = models.IntegerField(default=0) stripe_price_id = models.CharField(max_length=100) def get_display_price(self): return "{0:.2f}".format(self.price / 100) + def __str__(self): + return f"{self.price} for {self.resource.name}" + class ShoppingCart(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) -- cgit v1.2.3