Created
May 14, 2015 13:38
-
-
Save fandrefh/7f6f175fad2325c3ac0e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from django.db import models | |
from localflavor.br.br_states import STATE_CHOICES | |
# Create your models here. | |
class Restaurante(models.Model): | |
restaurante = models.CharField(u'Restaurante', max_length=255) | |
endereco = models.CharField(u'Endereço', max_length=255) | |
numero = models.CharField(u'Número', max_length=20) | |
cep = models.CharField(u'CEP', max_length=10, help_text='Formato: 00.000-000') | |
bairro = models.CharField(u'Bairro', max_length=50) | |
cidade = models.CharField(u'Cidade', max_length=50) | |
estado = models.CharField(u'Estado', max_length=2, choices=STATE_CHOICES) | |
gerente = models.CharField(u'Responsável/Gerente', max_length=255) | |
telefone = models.CharField(u'Telefone', max_length=14, help_text='(00)00000-0000') | |
dt_cadastro = models.DateTimeField(auto_now_add=True) | |
def __str__(self): | |
return self.restaurante | |
class Meta: | |
ordering = ('-dt_cadastro',) | |
class Semana(models.Model): | |
dia = models.CharField(u'Dia da semana', max_length=30, help_text='Exemplo: Segunda-feira') | |
def __str__(self): | |
return self.dia | |
class Meta: | |
ordering = ('id',) | |
class Cardapio(models.Model): | |
prato = models.CharField(u'Prato/Produto', max_length=200) | |
acompanha = models.TextField(u'Acompanha') | |
preco_normal = models.DecimalField(u'R$ Normal', max_digits=9, decimal_places=2) | |
preco_promocao = models.DecimalField(u'R$ Promocional', max_digits=9, decimal_places=2) | |
calendario = models.ManyToManyField(Semana) | |
restaurante = models.ForeignKey(Restaurante) | |
foto_prato = models.ImageField(upload_to='fotos') | |
dt_cadastro = models.DateTimeField(auto_now_add=True) | |
def dias_semana(self): | |
return ", ".join([c.dia for c in self.calendario.all()]) | |
def __str__(self): | |
return self.prato | |
class Meta: | |
ordering = ('-dt_cadastro',) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment