Add models, views and forms for authentication

This commit is contained in:
2022-07-21 13:45:44 +01:00
parent adf7c0604a
commit 4efc10a4f9
9 changed files with 297 additions and 0 deletions

29
core/models.py Normal file
View File

@@ -0,0 +1,29 @@
from django.contrib.auth.models import AbstractUser
from django.db import models
# Create your models here.
class Product(models.Model):
name = models.CharField(max_length=255)
description = models.CharField(max_length=1024)
cost = models.IntegerField()
product_id = models.UUIDField(blank=True)
image = models.CharField(max_length=1024, blank=True)
def __str__(self):
return f"{self.name}{self.cost})"
class User(AbstractUser):
# Stripe customer ID
stripe_id = models.CharField(max_length=255, blank=True)
subscription_id = models.CharField(max_length=255, blank=True)
subscription_active = models.BooleanField(blank=True)
last_payment = models.DateTimeField(blank=True)
paid = models.BooleanField(blank=True)
plans = models.ManyToManyField(Product, blank=True)
def has_plan(self, plan):
plan_list = [plan.name for plan in self.plans.all()]
return plan in plan_list