2020-02-21 09:41:22 +00:00
|
|
|
import uuid
|
|
|
|
|
2020-02-21 10:32:41 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-21 09:41:22 +00:00
|
|
|
class Product(models.Model):
|
|
|
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
name = models.CharField(max_length=256)
|
|
|
|
|
|
|
|
recurring_period = models.CharField(max_length=256,
|
|
|
|
choices = (
|
|
|
|
("per_year", "Per Year"),
|
|
|
|
("per_month", "Per Month"),
|
|
|
|
("per_week", "Per Week"),
|
|
|
|
("per_day", "Per Day"),
|
|
|
|
("per_hour", "Per Hour"),
|
|
|
|
("not_recurring", "Not recurring")
|
|
|
|
),
|
|
|
|
default="not_recurring"
|
|
|
|
)
|
|
|
|
|
2020-02-21 10:32:41 +00:00
|
|
|
def __str__(self):
|
|
|
|
return "{}".format(self.name)
|
2020-02-21 09:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Feature(models.Model):
|
|
|
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
name = models.CharField(max_length=256)
|
|
|
|
|
|
|
|
recurring_price = models.FloatField(default=0)
|
|
|
|
one_time_price = models.FloatField()
|
|
|
|
|
|
|
|
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
2020-02-21 10:32:41 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "'{}' - '{}'".format(self.product, self.name)
|
|
|
|
|
|
|
|
|
|
|
|
class Order(models.Model):
|
|
|
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
|
|
|
|
owner = models.ForeignKey(get_user_model(),
|
|
|
|
on_delete=models.CASCADE)
|
|
|
|
|
|
|
|
product = models.ForeignKey(Product,
|
|
|
|
on_delete=models.CASCADE)
|
|
|
|
|
|
|
|
|
2020-02-21 19:51:04 +00:00
|
|
|
|
2020-02-21 10:32:41 +00:00
|
|
|
class OrderReference(models.Model):
|
|
|
|
"""
|
|
|
|
An order can references another product / relate to it.
|
|
|
|
This model is used for the relation
|
|
|
|
"""
|
|
|
|
|
|
|
|
pass
|