Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Noticia(models.Model):
- '''
- classe abstrata que serve de base para todo o tipo de publicação
- '''
- nome=models.CharField("título",max_length=300)
- chamada=models.TextField("chamada",max_length=1000,blank=True)
- publicado_em=models.DateTimeField("data publicação",auto_now_add=True)
- atualizado_em=models.DateTimeField("data atualização",auto_now=True)
- visivel=models.BooleanField("visível",default=True)
- projeto=models.ManyToManyField(
- Projeto,
- blank=True,
- limit_choices_to={'visivel': True},
- related_name='%(app_label)s_%(class)s',
- help_text="Selecione os projetos a qual a publicação se relaciona"
- )
- texto=RichTextField("notícia",
- help_text='Espaço para inserir notícias, aceita fotos e formatações de texto avançadas,\
- bem como iframes para vídeos do youtube')
- imagem=models.ImageField('banner',
- upload_to='noticias/',
- help_text="imagem principal da notícia",
- blank=True,
- null=True)
- legenda_imagem = models.CharField('legenda banner notícia',
- max_length=200,blank = True, null = True)
- destaque=models.BooleanField('destaque',default=False)
- def __str__(self):
- '''
- retorna o nome da notícia
- '''
- return self.nome
- def get_absolute_url(self):
- '''
- retorna a url da notícia a ser apresentada
- '''
- #ainda a ser implementado...
- return reverse('postagem:noticia', kwargs = {'slug':self.slug})
- class Meta:
- verbose_name="notícia"
- verbose_name_plural="notícias"
- class Projetos(models.Model, RetornoDados):
- '''
- classe que armazena o projeto instituicional
- '''
- Codigo=models.CharField('código',max_length=20,help_text="código definido pelo financiador")
- NomeCurto=models.CharField('Nome curto',max_length=50,blank=True)
- Titulo=models.CharField('título',max_length=255,blank=True)
- slug = models.SlugField(max_length=500,blank=True,null=True)
- visivel = models.BooleanField(default=True)
- visivel_site = models.BooleanField('hotsite',default = False,help_text="defina se existe um hotsite para esse objeto")
- exibir_logo=models.CharField("Exibição da Logo",max_length=200,blank=True,null=True,
- help_text="Escolha o local onde irá ficar o link do site",
- choices=(('indice_geral','indice_geral'),
- ('hotsite','hotsite'),
- ),
- default='indice_geral')
- def __str__(self):
- if self.titulo_site != None:
- if self.titulo_site != "":
- return self.titulo_site
- else:
- return self.NomeCurto
- return self.NomeCurto
- def get_absolute_url(self):
- return reverse('institucional:projeto', kwargs = {'slug':self.slug})
- def finalizado(self):
- '''
- verifica se o projeto está ou não finalizado
- '''
- from datetime import datetime
- agora=datetime.now()
- if self.dataFinal > agora:
- return False
- elif self.dataInicial <= agora:
- return True
- class Meta:
- verbose_name='projeto'
- verbose_name_plural='projetos'
- #order_with_respect_to = 'idEixo'
- ordering=['NomeCurto',]
- class HotsiteBase(models.Model):
- '''
- classe base, abstrata para os hotsites
- '''
- nome=models.CharField('título', max_length=500,help_text="Título do Hotsite",unique=True)
- descricao=RichTextField('descrição',help_text="Descrição/Explicação do Hotsite ou tema desejado")
- agrupamento=models.ManyToManyField(Projetos,
- help_text="Selecione os projetos que deseja agregar a esse hotsite")
- def get_absolute_url(self):
- return reverse('hotsite:projeto', kwargs = {'slug':self.slug})
- class Meta:
- verbose_name="hotsite de projeto"
- verbose_name_plural="hotsites de projetos"
- ordering=['nome',]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement