Advertisement
Guest User

Untitled

a guest
Nov 30th, 2016
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.01 KB | None | 0 0
  1. from __future__ import unicode_literals
  2. from django.db import models
  3.  
  4. # Choice Fields :
  5.  
  6. RELACAO_PESSOA_PESSOA = (
  7.    
  8.     (0, 'Filho(a)'),
  9.     (1, 'Pai'),
  10.     (2, 'Mãe'),
  11.     (3, 'Casado(a)'),
  12.     (4, 'Viúvo(a)'),
  13.     (5, 'Parente'),
  14. )
  15.  
  16. ESTADOS_CIVIS = (
  17.  
  18.     ('Solteiro(a)', 'Solteiro(a)'),
  19.     ('Casado(a)', 'Casado(a)'),
  20.     ('Viúvo(a)', 'Viúvo(a)'),
  21.     ('Divorciado(a)', 'Divorciado(a)'),
  22.  
  23.     )
  24.  
  25. # The models below are the same in the UML graph we have
  26. # They were adpated to be created and managed by Django
  27.  
  28. #Except for this class, Imovel, which is managed by ArcGIS applications, Django is only aware of it to create the relationships
  29. #This class has not been adapted in any way as Django will not change it in any way
  30. #Django will NOT create new objects for this class
  31. class Imovel(models.Model):
  32.     objectid = models.BigIntegerField(unique=True)
  33.     geocodigo_imovel = models.AutoField(primary_key=True)
  34.     area_levantada = models.CharField(max_length=150, blank=True, null=True)
  35.     fonte = models.CharField(max_length=150, blank=True, null=True)
  36.     tipo_imovel = models.CharField(max_length=150, blank=True, null=True)
  37.     created_user = models.CharField(max_length=765, blank=True, null=True)
  38.     created_date = models.DateTimeField(blank=True, null=True)
  39.     last_edited_user = models.CharField(max_length=765, blank=True, null=True)
  40.     last_edited_date = models.DateTimeField(blank=True, null=True)
  41.     shape = models.TextField(blank=True, null=True)  # This field type is a guess. - ESRI Shape
  42.  
  43.     class Meta:
  44.         managed = False
  45.         db_table = 'IMOVEL'
  46.  
  47. class Ccir(models.Model):
  48.  
  49.     cod_ccir = models.AutoField(primary_key=True)
  50.     codigo_imovel_rural = models.CharField(max_length=150, blank=True, null=True)
  51.     area_total_hec = models.CharField(max_length=150, blank=True, null=True)
  52.     nun_modulos_rurais = models.CharField(max_length=150, blank=True, null=True)
  53.     modulo_fiscal_hec = models.CharField(max_length=150, blank=True, null=True)
  54.     num_modulo_fiscais = models.CharField(max_length=150, blank=True, null=True)
  55.     fmp_hec = models.CharField(max_length=150, blank=True, null=True)
  56.     valor_cobrado = models.CharField(max_length=150, blank=True, null=True)
  57.     valor_total = models.CharField(max_length=150, blank=True, null=True)
  58.     documento = models.CharField(max_length=150, blank=True, null=True)
  59.     declarante = models.CharField(max_length=150, blank=True, null=True)
  60.     status = models.CharField(max_length=150, blank=True, null=True)
  61.     created_user = models.CharField(max_length=765, blank=True, null=True)
  62.     created_date = models.DateTimeField(blank=True, null=True)
  63.     last_edited_user = models.CharField(max_length=765, blank=True, null=True)
  64.     last_edited_date = models.DateTimeField(blank=True, null=True)
  65.  
  66.     documentos = models.ManyToManyField(
  67.         'Doc',
  68.         through = 'Ccir_Doc'
  69.         )
  70.     imoveis = models.ManyToManyField(
  71.         Imovel,
  72.         through = 'Ccir_Imovel'
  73.         )
  74.     pessoas = models.ManyToManyField(
  75.         'Pessoa',
  76.         through = 'Ccir_Pessoa'
  77.         )
  78.     def __str__(self):
  79.  
  80.         return self.codigo_imovel_rural
  81.  
  82.     class Meta:
  83.         verbose_name = "CCIR"
  84.         verbose_name_plural = "CCIRs"
  85.         #db_table = '"GEO"."django_ccir"'
  86.  
  87. class Ccir_Doc(models.Model):
  88.     cod_ccir = models.ForeignKey('Ccir', on_delete=models.CASCADE)
  89.     cod_doc = models.ForeignKey('Doc', on_delete=models.CASCADE)
  90.  
  91.     class Meta:
  92.         verbose_name = "Ccir com Doc"
  93.  
  94. class Ccir_Imovel(models.Model):
  95.     cod_ccir = models.ForeignKey('Ccir', on_delete=models.CASCADE)
  96.     cod_imovel = models.ForeignKey(Imovel, on_delete=models.CASCADE)
  97.  
  98.     #class Meta:
  99.         #db_table = '"GEO"."django_ccir_imovel"'
  100.  
  101. class Ccir_Pessoa(models.Model):
  102.     cod_ccir = models.ForeignKey('Ccir', on_delete=models.CASCADE)
  103.     cod_pessoa = models.ForeignKey('Pessoa', on_delete=models.CASCADE)
  104.  
  105.     #class Meta:
  106.         #db_table = '"GEO"."django_ccir_pessoa"'
  107.  
  108. class Pessoa(models.Model):
  109.     cod_pessoa = models.AutoField(primary_key=True)
  110.     nome = models.CharField(max_length=150, blank=True, null=True)
  111.     estado_civil = models.CharField(choices = ESTADOS_CIVIS, default = 'Solteiro(a)', max_length = 255)
  112.     endereço = models.CharField(max_length=150, blank=True, null=True)
  113.     telefone = models.CharField(max_length=150, blank=True, null=True)
  114.     email = models.CharField(max_length=150, blank=True, null=True)
  115.     rg = models.CharField(max_length=150, blank=True, null=True)
  116.     created_user = models.CharField(max_length=765, blank=True, null=True)
  117.     created_date = models.DateTimeField(blank=True, null=True)
  118.     last_edited_user = models.CharField(max_length=765, blank=True, null=True)
  119.     last_edited_date = models.DateTimeField(blank=True, null=True)
  120.  
  121.     relacoes = models.ManyToManyField(
  122.         'self',
  123.         through = 'Pessoa_Pessoa', #This lets you define the model that will act as an intermadiary
  124.         symmetrical = False, #This needs to be set with recursive relationships
  125.         )
  126.  
  127.     imoveis = models.ManyToManyField(
  128.         Imovel,
  129.         through = 'Pessoa_Imovel',
  130.         )
  131.  
  132.     itrs = models.ManyToManyField(
  133.         'Itr',
  134.         through = 'Pessoa_Itr',
  135.         )
  136.  
  137.     def __str__(self):
  138.         return str(self.cod_pessoa) + " " + self.nome
  139.  
  140.     #class Meta:
  141.         #db_table = '"GEO"."django_pessoa"'
  142.  
  143. class Pessoa_Pessoa(models.Model):
  144.     cod_pessoa_1 = models.ForeignKey('Pessoa', on_delete=models.CASCADE,
  145.         related_name='%(class)s_cod_pessoa_1')
  146.     cod_pessoa_2 = models.ForeignKey('Pessoa', on_delete=models.CASCADE,
  147.         related_name='%(class)s_cod_pessoa_2')
  148.     relacao = models.IntegerField(choices = RELACAO_PESSOA_PESSOA, default = 5)
  149.  
  150.     #class Meta:
  151.         #db_table = '"GEO"."django_pessoa_pessoa"'
  152.  
  153. class Pessoa_Imovel(models.Model):
  154.     cod_pessoa = models.ForeignKey('Pessoa', on_delete=models.CASCADE)
  155.     cod_imovel = models.ForeignKey(Imovel, on_delete=models.CASCADE)
  156.  
  157.     #class Meta:
  158.         #db_table = '"GEO"."django_pessoa_imovel"'
  159.  
  160. class Pessoa_Itr(models.Model):
  161.     cod_pessoa = models.ForeignKey('Pessoa', on_delete=models.CASCADE)
  162.     cod_itr = models.ForeignKey('Itr', on_delete=models.CASCADE)
  163.  
  164.     #class Meta:
  165.         #db_table = '"GEO"."django_pessoa_itr"'
  166.  
  167. class Itr(models.Model):
  168.     cod_itr = models.AutoField(primary_key=True)
  169.     nirf = models.CharField(max_length=150, blank=True, null=True)
  170.     nome_imovel = models.CharField(max_length=150, blank=True, null=True)
  171.     area_hec = models.CharField(max_length=150, blank=True, null=True)
  172.     emissao_cn = models.CharField(max_length=150, blank=True, null=True)
  173.     validade_cn = models.CharField(max_length=150, blank=True, null=True)
  174.     declarante = models.CharField(max_length=150, blank=True, null=True)
  175.     status = models.CharField(max_length=150, blank=True, null=True)
  176.     municipio = models.CharField(max_length=150, blank=True, null=True)
  177.     uf = models.CharField(max_length=150, blank=True, null=True)
  178.     created_user = models.CharField(max_length=765, blank=True, null=True)
  179.     created_date = models.DateTimeField(blank=True, null=True)
  180.     last_edited_user = models.CharField(max_length=765, blank=True, null=True)
  181.     last_edited_date = models.DateTimeField(blank=True, null=True)
  182.  
  183.     imoveis = models.ManyToManyField(
  184.         Imovel,  
  185.         through = 'Itr_Imovel',
  186.         )
  187.  
  188.     #class Meta:
  189.         #db_table = '"GEO"."django_itr"'
  190.  
  191. class Itr_Imovel(models.Model):
  192.     cod_itr = models.ForeignKey('Itr', on_delete=models.CASCADE)
  193.     cod_imovel = models.ForeignKey(Imovel, on_delete=models.CASCADE)
  194.  
  195.     #class Meta:
  196.         #db_table = '"GEO"."django_itr_imovel"'
  197.  
  198. class Doc(models.Model):
  199.     cod_doc = models.AutoField(primary_key=True)
  200.     tipo = models.CharField(max_length=150, blank=True, null=True)
  201.     num_documento = models.CharField(max_length=150, blank=True, null=True)
  202.     registro_averbacao = models.CharField(max_length=150, blank=True, null=True)
  203.     registro_anterior = models.CharField(max_length=150, blank=True, null=True)
  204.     area_doc = models.CharField(max_length=150, blank=True, null=True)
  205.     comarca = models.CharField(max_length=150, blank=True, null=True)
  206.     municipio = models.CharField(max_length=150, blank=True, null=True)
  207.     uf = models.CharField(max_length=150, blank=True, null=True)
  208.     tipo_imovel = models.CharField(max_length=150, blank=True, null=True)
  209.     contrato_eol = models.CharField(max_length=150, blank=True, null=True)
  210.     created_user = models.CharField(max_length=765, blank=True, null=True)
  211.     created_date = models.DateTimeField(blank=True, null=True)
  212.     last_edited_user = models.CharField(max_length=765, blank=True, null=True)
  213.     last_edited_date = models.DateTimeField(blank=True, null=True)
  214.     status = models.CharField(max_length=150, blank=True, null=True)
  215.  
  216.     imoveis = models.ManyToManyField(
  217.         Imovel,
  218.         through = 'Doc_Imovel',
  219.         )
  220.  
  221.     pessoas = models.ManyToManyField(
  222.         'Pessoa',  
  223.         through = 'Doc_Pessoa',
  224.         )
  225.  
  226.     #class Meta:
  227.         #db_table = '"GEO"."django_doc"'
  228.  
  229. class Doc_Imovel(models.Model):
  230.     cod_doc = models.ForeignKey('Doc', on_delete=models.CASCADE)
  231.     cod_imovel = models.ForeignKey(Imovel, on_delete=models.CASCADE)
  232.  
  233.     #class Meta:
  234.         #db_table = '"GEO"."django_doc_imovel"'
  235.  
  236. class Doc_Pessoa(models.Model):
  237.     cod_doc = models.ForeignKey('Doc', on_delete=models.CASCADE)
  238.     cod_pessoa = models.ForeignKey('Pessoa', on_delete=models.CASCADE)
  239.     percentual_area = models.IntegerField()
  240.     rid = models.IntegerField()
  241.     valor_area = models.IntegerField()
  242.  
  243.     #class Meta:
  244.         #db_table = '"GEO"."django_doc_pessoa"'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement