uncloud-mravi/nicohack202002/uncloud/uncloud_api/models.py
Nico Schottelius 4df7c761d3 ++stuff
2020-02-21 20:51:04 +01:00

59 lines
1.8 KiB
Python

import uuid
from django.db import models
from django.contrib.auth import get_user_model
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"
)
def __str__(self):
return "{}".format(self.name)
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)
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)
class OrderReference(models.Model):
"""
An order can references another product / relate to it.
This model is used for the relation
"""
pass