Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import unicode_literals
- from django.db import models
- # Choice Fields :
- RELACAO_PESSOA_PESSOA = (
- (0, 'Filho(a)'),
- (1, 'Pai'),
- (2, 'Mãe'),
- (3, 'Casado(a)'),
- (4, 'Viúvo(a)'),
- (5, 'Parente'),
- )
- ESTADOS_CIVIS = (
- ('Solteiro(a)', 'Solteiro(a)'),
- ('Casado(a)', 'Casado(a)'),
- ('Viúvo(a)', 'Viúvo(a)'),
- ('Divorciado(a)', 'Divorciado(a)'),
- )
- # The models below are the same in the UML graph we have
- # They were adpated to be created and managed by Django
- #Except for this class, Imovel, which is managed by ArcGIS applications, Django is only aware of it to create the relationships
- #This class has not been adapted in any way as Django will not change it in any way
- #Django will NOT create new objects for this class
- class Imovel(models.Model):
- objectid = models.BigIntegerField(unique=True)
- geocodigo_imovel = models.AutoField(primary_key=True)
- area_levantada = models.CharField(max_length=150, blank=True, null=True)
- fonte = models.CharField(max_length=150, blank=True, null=True)
- tipo_imovel = models.CharField(max_length=150, blank=True, null=True)
- created_user = models.CharField(max_length=765, blank=True, null=True)
- created_date = models.DateTimeField(blank=True, null=True)
- last_edited_user = models.CharField(max_length=765, blank=True, null=True)
- last_edited_date = models.DateTimeField(blank=True, null=True)
- shape = models.TextField(blank=True, null=True) # This field type is a guess. - ESRI Shape
- class Meta:
- managed = False
- db_table = 'IMOVEL'
- class Ccir(models.Model):
- cod_ccir = models.AutoField(primary_key=True)
- codigo_imovel_rural = models.CharField(max_length=150, blank=True, null=True)
- area_total_hec = models.CharField(max_length=150, blank=True, null=True)
- nun_modulos_rurais = models.CharField(max_length=150, blank=True, null=True)
- modulo_fiscal_hec = models.CharField(max_length=150, blank=True, null=True)
- num_modulo_fiscais = models.CharField(max_length=150, blank=True, null=True)
- fmp_hec = models.CharField(max_length=150, blank=True, null=True)
- valor_cobrado = models.CharField(max_length=150, blank=True, null=True)
- valor_total = models.CharField(max_length=150, blank=True, null=True)
- documento = models.CharField(max_length=150, blank=True, null=True)
- declarante = models.CharField(max_length=150, blank=True, null=True)
- status = models.CharField(max_length=150, blank=True, null=True)
- created_user = models.CharField(max_length=765, blank=True, null=True)
- created_date = models.DateTimeField(blank=True, null=True)
- last_edited_user = models.CharField(max_length=765, blank=True, null=True)
- last_edited_date = models.DateTimeField(blank=True, null=True)
- documentos = models.ManyToManyField(
- 'Doc',
- through = 'Ccir_Doc'
- )
- imoveis = models.ManyToManyField(
- Imovel,
- through = 'Ccir_Imovel'
- )
- pessoas = models.ManyToManyField(
- 'Pessoa',
- through = 'Ccir_Pessoa'
- )
- def __str__(self):
- return self.codigo_imovel_rural
- class Meta:
- verbose_name = "CCIR"
- verbose_name_plural = "CCIRs"
- #db_table = '"GEO"."django_ccir"'
- class Ccir_Doc(models.Model):
- cod_ccir = models.ForeignKey('Ccir', on_delete=models.CASCADE)
- cod_doc = models.ForeignKey('Doc', on_delete=models.CASCADE)
- class Meta:
- verbose_name = "Ccir com Doc"
- class Ccir_Imovel(models.Model):
- cod_ccir = models.ForeignKey('Ccir', on_delete=models.CASCADE)
- cod_imovel = models.ForeignKey(Imovel, on_delete=models.CASCADE)
- #class Meta:
- #db_table = '"GEO"."django_ccir_imovel"'
- class Ccir_Pessoa(models.Model):
- cod_ccir = models.ForeignKey('Ccir', on_delete=models.CASCADE)
- cod_pessoa = models.ForeignKey('Pessoa', on_delete=models.CASCADE)
- #class Meta:
- #db_table = '"GEO"."django_ccir_pessoa"'
- class Pessoa(models.Model):
- cod_pessoa = models.AutoField(primary_key=True)
- nome = models.CharField(max_length=150, blank=True, null=True)
- estado_civil = models.CharField(choices = ESTADOS_CIVIS, default = 'Solteiro(a)', max_length = 255)
- endereço = models.CharField(max_length=150, blank=True, null=True)
- telefone = models.CharField(max_length=150, blank=True, null=True)
- email = models.CharField(max_length=150, blank=True, null=True)
- rg = models.CharField(max_length=150, blank=True, null=True)
- created_user = models.CharField(max_length=765, blank=True, null=True)
- created_date = models.DateTimeField(blank=True, null=True)
- last_edited_user = models.CharField(max_length=765, blank=True, null=True)
- last_edited_date = models.DateTimeField(blank=True, null=True)
- relacoes = models.ManyToManyField(
- 'self',
- through = 'Pessoa_Pessoa', #This lets you define the model that will act as an intermadiary
- symmetrical = False, #This needs to be set with recursive relationships
- )
- imoveis = models.ManyToManyField(
- Imovel,
- through = 'Pessoa_Imovel',
- )
- itrs = models.ManyToManyField(
- 'Itr',
- through = 'Pessoa_Itr',
- )
- def __str__(self):
- return str(self.cod_pessoa) + " " + self.nome
- #class Meta:
- #db_table = '"GEO"."django_pessoa"'
- class Pessoa_Pessoa(models.Model):
- cod_pessoa_1 = models.ForeignKey('Pessoa', on_delete=models.CASCADE,
- related_name='%(class)s_cod_pessoa_1')
- cod_pessoa_2 = models.ForeignKey('Pessoa', on_delete=models.CASCADE,
- related_name='%(class)s_cod_pessoa_2')
- relacao = models.IntegerField(choices = RELACAO_PESSOA_PESSOA, default = 5)
- #class Meta:
- #db_table = '"GEO"."django_pessoa_pessoa"'
- class Pessoa_Imovel(models.Model):
- cod_pessoa = models.ForeignKey('Pessoa', on_delete=models.CASCADE)
- cod_imovel = models.ForeignKey(Imovel, on_delete=models.CASCADE)
- #class Meta:
- #db_table = '"GEO"."django_pessoa_imovel"'
- class Pessoa_Itr(models.Model):
- cod_pessoa = models.ForeignKey('Pessoa', on_delete=models.CASCADE)
- cod_itr = models.ForeignKey('Itr', on_delete=models.CASCADE)
- #class Meta:
- #db_table = '"GEO"."django_pessoa_itr"'
- class Itr(models.Model):
- cod_itr = models.AutoField(primary_key=True)
- nirf = models.CharField(max_length=150, blank=True, null=True)
- nome_imovel = models.CharField(max_length=150, blank=True, null=True)
- area_hec = models.CharField(max_length=150, blank=True, null=True)
- emissao_cn = models.CharField(max_length=150, blank=True, null=True)
- validade_cn = models.CharField(max_length=150, blank=True, null=True)
- declarante = models.CharField(max_length=150, blank=True, null=True)
- status = models.CharField(max_length=150, blank=True, null=True)
- municipio = models.CharField(max_length=150, blank=True, null=True)
- uf = models.CharField(max_length=150, blank=True, null=True)
- created_user = models.CharField(max_length=765, blank=True, null=True)
- created_date = models.DateTimeField(blank=True, null=True)
- last_edited_user = models.CharField(max_length=765, blank=True, null=True)
- last_edited_date = models.DateTimeField(blank=True, null=True)
- imoveis = models.ManyToManyField(
- Imovel,
- through = 'Itr_Imovel',
- )
- #class Meta:
- #db_table = '"GEO"."django_itr"'
- class Itr_Imovel(models.Model):
- cod_itr = models.ForeignKey('Itr', on_delete=models.CASCADE)
- cod_imovel = models.ForeignKey(Imovel, on_delete=models.CASCADE)
- #class Meta:
- #db_table = '"GEO"."django_itr_imovel"'
- class Doc(models.Model):
- cod_doc = models.AutoField(primary_key=True)
- tipo = models.CharField(max_length=150, blank=True, null=True)
- num_documento = models.CharField(max_length=150, blank=True, null=True)
- registro_averbacao = models.CharField(max_length=150, blank=True, null=True)
- registro_anterior = models.CharField(max_length=150, blank=True, null=True)
- area_doc = models.CharField(max_length=150, blank=True, null=True)
- comarca = models.CharField(max_length=150, blank=True, null=True)
- municipio = models.CharField(max_length=150, blank=True, null=True)
- uf = models.CharField(max_length=150, blank=True, null=True)
- tipo_imovel = models.CharField(max_length=150, blank=True, null=True)
- contrato_eol = models.CharField(max_length=150, blank=True, null=True)
- created_user = models.CharField(max_length=765, blank=True, null=True)
- created_date = models.DateTimeField(blank=True, null=True)
- last_edited_user = models.CharField(max_length=765, blank=True, null=True)
- last_edited_date = models.DateTimeField(blank=True, null=True)
- status = models.CharField(max_length=150, blank=True, null=True)
- imoveis = models.ManyToManyField(
- Imovel,
- through = 'Doc_Imovel',
- )
- pessoas = models.ManyToManyField(
- 'Pessoa',
- through = 'Doc_Pessoa',
- )
- #class Meta:
- #db_table = '"GEO"."django_doc"'
- class Doc_Imovel(models.Model):
- cod_doc = models.ForeignKey('Doc', on_delete=models.CASCADE)
- cod_imovel = models.ForeignKey(Imovel, on_delete=models.CASCADE)
- #class Meta:
- #db_table = '"GEO"."django_doc_imovel"'
- class Doc_Pessoa(models.Model):
- cod_doc = models.ForeignKey('Doc', on_delete=models.CASCADE)
- cod_pessoa = models.ForeignKey('Pessoa', on_delete=models.CASCADE)
- percentual_area = models.IntegerField()
- rid = models.IntegerField()
- valor_area = models.IntegerField()
- #class Meta:
- #db_table = '"GEO"."django_doc_pessoa"'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement