Advertisement
andre_guilhon

Untitled

Aug 29th, 2016
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.82 KB | None | 0 0
  1. from __future__ import unicode_literals
  2.  
  3. from django.db import models
  4.  
  5. class Empresa(models.Model):
  6.     id_empresa = models.BigIntegerField(primary_key=True)
  7.     nome = models.CharField(max_length=255)
  8.     bol_status = models.IntegerField()
  9.     def __str__(self):
  10.         return self.nome
  11.     class Meta:
  12.         managed = False
  13.         db_table = 'empresa'
  14.  
  15.  
  16. class Fornecedor(models.Model):
  17.     id_fornecedor = models.AutoField(primary_key=True)
  18.     char_fornecedor = models.CharField(max_length=1)
  19.     nome_fornecedor = models.CharField(max_length=45, blank=True, null=True)
  20.  
  21.     def __str__(self):
  22.         return self.nome_fornecedor
  23.  
  24.     class Meta:
  25.         managed = False
  26.         db_table = 'fornecedor'
  27.  
  28.  
  29. class Stick(models.Model):
  30.     id_stick = models.AutoField(primary_key=True)
  31.     char_stick = models.CharField(max_length=3)
  32.     id_versao = models.ForeignKey('Versao', models.DO_NOTHING, db_column='id_versao')
  33.     setor = models.CharField(max_length=45, blank=True, null=True)
  34.     id_empresa = models.ForeignKey(Empresa, models.DO_NOTHING, db_column='id_empresa', blank=True, null=True)
  35.     id_zabbix = models.IntegerField(blank=True, null=True)
  36.     def __str__(self):
  37.         return '%s-%s' % (self.char_versao, self.char_stick)
  38.  
  39.     class Meta:
  40.         managed = False
  41.         db_table = 'stick'
  42.         unique_together = (('char_stick', 'id_versao'),)
  43.  
  44. class Versao(models.Model):
  45.     id_versao = models.AutoField(primary_key=True)
  46.     char_versao = models.CharField(max_length=1)
  47.     id_fornecedor = models.ForeignKey(Fornecedor, models.DO_NOTHING, db_column='id_fornecedor')
  48.     def __str__(self):
  49.         return '%s%s' % (self.char_fornecedor,self.char_versao)
  50.     class Meta:
  51.         managed = False
  52.         db_table = 'versao'
  53.         unique_together = (('char_versao', 'id_fornecedor'),)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement