suitablephones/suitablephones/models.py
2023-04-27 00:07:26 +02:00

77 lines
No EOL
3.5 KiB
Python

from django.contrib.postgres.fields import ArrayField
from django.db import models
class Bluetooth(models.Model):
spec = models.CharField(max_length=100)
profiles = models.CharField(max_length=100, blank=True, null=True)
def __str__(self):
return f"{self.spec} - {self.profiles}"
class Camera(models.Model):
# class FLASHES(models.TextChoices):
# LED = 'L', 'Led'
# DUAL_LED = 'DL', 'Double Led'
flash = models.CharField(max_length=100)
megapixel = models.DecimalField(max_digits=5, decimal_places=1)
info = models.CharField(max_length=100, null=True)
def __str__(self):
return f"{self.flash} - {str(self.megapixel)} - {self.info}"
class Screen(models.Model):
size = models.CharField(max_length=500, null=True)
size_mm = models.DecimalField(max_digits=5, decimal_places=1)
size_in = models.DecimalField(max_digits=5, decimal_places=1)
resolution = models.CharField(max_length=100)
density = models.CharField(max_length=100)
technology = models.CharField(max_length=100)
def __str__(self):
return f"{str(self.size_in)} - {str(self.density)} - {str(self.technology)}"
class Device(models.Model):
#architecture = models.JSONField(default=dict)
#battery = models.JSONField(default=dict)
#before_install = models.JSONField(default=dict, null=True) # dict or str
bluetooth = models.ForeignKey(Bluetooth, on_delete=models.CASCADE, null=True)
cameras = models.ManyToManyField(Camera)
codename = models.CharField(max_length=100)
cpu = models.CharField(max_length=100)
cpu_cores = models.CharField(max_length=100)
cpu_freq = models.CharField(max_length=1000)
current_branch = models.FloatField(default=None, null=True)
custom_recovery_link = models.URLField(max_length=200, null=True)
download_boot = models.CharField(max_length=1000)
#dimensions = models.JSONField(default=dict, null=True)
gpu = models.CharField(max_length=100)
image = models.CharField(max_length=100)
install_method = models.CharField(max_length=100)
is_ab_device = models.BooleanField(null=True)
kernel = models.CharField(max_length=100)
maintainers = ArrayField(models.CharField(max_length=100), default=None, null=True)
device_models = ArrayField(models.CharField(max_length=100), default=None, null=True)
name = models.CharField(max_length=100)
network = ArrayField(models.CharField(max_length=100), default=None, null=True)
peripherals = ArrayField(models.CharField(max_length=100, blank=True, null=True), default=None, blank=True, null=True)
ram = models.CharField(max_length=100)
recovery_boot = models.CharField(max_length=1000)
recovery_reboot = models.CharField(max_length=100)
#release = models.DateField()
screen = models.ManyToManyField(Screen)
#sdcard = models.JSONField(default=dict) # dict or str{1}
soc = models.CharField(max_length=1000)
storage = models.CharField(max_length=100, blank=True)
tree = models.CharField(max_length=100)
device_type = models.CharField(max_length=100)
uses_twrp = models.BooleanField(null=True)
vendor = models.CharField(max_length=100)
vendor_short = models.CharField(max_length=100)
versions = ArrayField(models.FloatField(default=None), default=None, null=True)
wifi = models.CharField(max_length=200, null=True)
def __str__(self):
return 'Device: ' + self.name + ' - ' + self.codename