Created
September 8, 2014 14:51
-
-
Save guilhermecarvalhocarneiro/c7a2d1ae02156a7ffbbd to your computer and use it in GitHub Desktop.
Classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create your models here. | |
class Abastecimento(models.Model): | |
valor_etanol = models.DecimalField("Valor Etanol", max_digits=9, decimal_places=2) | |
valor_gasolina = models.DecimalField("Valor Gasolina", max_digits=9, decimal_places=2) | |
valor_diesel = models.DecimalField("Valor Diesel", max_digits=9, decimal_places=2) | |
usuario = models.ForeignKey(Usuario, blank=True, null=True) | |
posto = models.ForeignKey('Posto', blank=True, null=True) | |
def __unicode__(self): | |
return u"Posto: %s - Valores: Gas R$ %s Alc R$ %s Die R$ %s" % (self.posto, self.valor_gasolina, self.valor_etanol, self.valor_diesel) | |
class Cidade(models.Model): | |
nome = models.CharField("Nome", max_length=200, unique=True) | |
uf = models.CharField("UF", max_length=2) | |
def __unicode__(self): | |
return u"%s" % self.nome | |
class Posto(models.Model): | |
nome = models.CharField("Nome", max_length=200) | |
bandeira = models.CharField("Bandeira", max_length=200) | |
latitude = models.CharField("Latitude", max_length=200) | |
longitude = models.CharField("Longitude", max_length=200) | |
cidade = models.ForeignKey(Cidade) | |
class Meta: | |
unique_together = ('nome', 'cidade') | |
def __unicode__(self): | |
return u"%s" % self.nome |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment