uncloud-mravi/uncloud_v4/models.py
2022-01-02 19:34:55 +01:00

72 lines
2.1 KiB
Python

from django.db import models
from django.contrib.auth import get_user_model
# 1st mixin: owner alike?
# 2nd: time frames
class Nextcloudv1(models.Model):
name = models.CharField(max_length=128, unique=True)
owner = models.ForeignKey(
get_user_model(), on_delete=models.CASCADE, editable=False
)
domain = models.CharField(max_length=253)
cpu_cores = models.FloatField(null=True, blank=True)
ram_in_gb = models.FloatField(null=True, blank=True)
storage_in_gb = models.FloatField(null=True, blank=True)
def __str__(self):
return f"Nextcloud {domain}: {cores}C {ram_in_gb}GB RAM {storage} GB storage from {owner}"
class ResourceConfig(models.Model):
"""
Describes an actual setting of a resource
"""
value = models.FloatField()
resource = models.ForeignKey(Resource, on_delete=models.CASCADE)
class ProductTextConfiguration(models.Model):
name = models.CharField(max_length=128, unique=True) # Domain, etc.
class ProductTextFieldConfiguration(models.Model):
name = models.CharField(max_length=128, unique=True) # homeserver.Yaml, etc.
class ProductTextConfig(models.Model):
"""
Describes an actual setting of a resource
"""
value = models.CharField(max_length=256)
config = models.ForeignKey(ProductTextConfiguration, on_delete=models.CASCADE)
class ProductTextFieldConfig(models.Model):
"""
Describes an actual setting of a resource
"""
value = models.TextField()
config = models.ForeignKey(ProductTextFieldConfiguration, on_delete=models.CASCADE)
# 3600
# 86400
# 30*86400
# class Nextcloudv2(Product):
# domain = models.CharField(max_length=253)
# def __str__(self):
# return f"Nextcloud {domain} {owner}"
# class ProductPricing(models.Model):
# """
# Defines the allowed time frames and the available resources
# """
# name = models.CharField(max_length=128, unique=True) # cpu 2022, ipv4 2022
# timeframes = models.ManyToManyField(TimeFrame)
# resources = models.ManyToManyField(Resource)