158 lines
4.4 KiB
Python
158 lines
4.4 KiB
Python
import uuid
|
|
|
|
from django.contrib.auth.models import User
|
|
from django.db import models
|
|
from localflavor.br.br_states import STATE_CHOICES
|
|
|
|
|
|
class UuidModel(models.Model):
|
|
uuid = models.UUIDField(unique=True, editable=False, default=uuid.uuid4)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
|
|
class TimeStampedModel(models.Model):
|
|
created = models.DateTimeField(
|
|
'criado em',
|
|
auto_now_add=True,
|
|
auto_now=False
|
|
)
|
|
modified = models.DateTimeField(
|
|
'modificado em',
|
|
auto_now_add=False,
|
|
auto_now=True
|
|
)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
|
|
class CreatedBy(models.Model):
|
|
created_by = models.ForeignKey(
|
|
User,
|
|
verbose_name='criado por',
|
|
on_delete=models.SET_NULL,
|
|
null=True,
|
|
blank=True,
|
|
)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
|
|
class Address(models.Model):
|
|
address = models.CharField(
|
|
'endereço',
|
|
max_length=100,
|
|
null=True,
|
|
blank=True
|
|
)
|
|
address_number = models.IntegerField('número', null=True, blank=True)
|
|
complement = models.CharField(
|
|
'complemento',
|
|
max_length=100,
|
|
null=True,
|
|
blank=True
|
|
)
|
|
district = models.CharField(
|
|
'bairro',
|
|
max_length=100,
|
|
null=True,
|
|
blank=True
|
|
)
|
|
city = models.CharField('cidade', max_length=100, null=True, blank=True)
|
|
uf = models.CharField(
|
|
'UF',
|
|
max_length=2,
|
|
choices=STATE_CHOICES,
|
|
null=True,
|
|
blank=True
|
|
)
|
|
cep = models.CharField('CEP', max_length=9, null=True, blank=True)
|
|
country = models.CharField(
|
|
'país',
|
|
max_length=50,
|
|
default='Brasil',
|
|
null=True,
|
|
blank=True
|
|
)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
def to_dict_base(self):
|
|
return {
|
|
'address': self.address,
|
|
'address_number': self.address_number,
|
|
'complement': self.complement,
|
|
'district': self.district,
|
|
'city': self.city,
|
|
'uf': self.uf,
|
|
'cep': self.cep,
|
|
}
|
|
|
|
|
|
class Document(models.Model):
|
|
cpf = models.CharField(
|
|
'CPF',
|
|
max_length=11,
|
|
unique=True,
|
|
null=True,
|
|
blank=True
|
|
)
|
|
rg = models.CharField('RG', max_length=11, null=True, blank=True)
|
|
cnh = models.CharField('CNH', max_length=20, null=True, blank=True)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
def to_dict_base(self):
|
|
return {
|
|
'cpf': self.cpf,
|
|
'rg': self.rg,
|
|
'cnh': self.cnh,
|
|
}
|
|
|
|
|
|
class Active(models.Model):
|
|
active = models.BooleanField('ativo', default=True)
|
|
exist_deleted = models.BooleanField(
|
|
'existe/deletado',
|
|
default=True,
|
|
help_text='Se for True o item existe. Se for False o item foi deletado.'
|
|
)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
|
|
class Organization(models.Model):
|
|
name = models.CharField(max_length=255)
|
|
email = models.EmailField()
|
|
employee_headcount = models.CharField(max_length=20)
|
|
annual_revenue = models.CharField(max_length=20)
|
|
critical_applications = models.CharField(max_length=20)
|
|
compliance_frameworks = models.JSONField() # Stores selected compliance frameworks as a list
|
|
industry_sector = models.CharField(max_length=255)
|
|
it_dependency = models.IntegerField()
|
|
data_sensitivity = models.CharField(max_length=20)
|
|
network_infrastructure = models.CharField(max_length=20)
|
|
remote_workforce_percentage = models.CharField(max_length=20)
|
|
third_party_vendor_access = models.CharField(max_length=20)
|
|
internal_software_development = models.CharField(max_length=20)
|
|
geographic_scope = models.CharField(max_length=20, null=True, blank=True)
|
|
customer_base = models.CharField(max_length=20, null=True, blank=True)
|
|
customer_type = models.CharField(max_length=20, null=True, blank=True)
|
|
product_portfolio = models.CharField(max_length=20, null=True, blank=True)
|
|
supplier_base = models.CharField(max_length=20, null=True, blank=True)
|
|
it_infrastructure = models.JSONField(null=True, blank=True) # Stores selected IT infrastructure types as a list
|
|
intellectual_property = models.JSONField(null=True, blank=True) # Stores selected IP protection types as a list
|
|
sensitive_data = models.JSONField(null=True, blank=True) # Stores selected sensitive data types as a list
|
|
integration_level = models.CharField(max_length=20, null=True, blank=True)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|