Merge ssh://holoscopio.com/var/www/cascardo/eventmanager into holoscopio
[cascardo/eventmanager.git] / conteudo / models.py
1 # -*- coding: utf-8; -*-
2 """
3 Copyright (C) 2007 Lincoln de Sousa <lincoln@archlinux-br.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 """
20 from django.db import models
21 from django.contrib.auth.models import User
22
23 ELLIPSIS_START = 400
24
25 class Noticia(models.Model):
26     titulo = models.CharField(maxlength=100)
27     autor = models.ForeignKey(User)
28     data_criacao = models.DateTimeField(auto_now=True)
29     chamada = models.TextField(help_text='Texto que irá aparecer na index.')
30     corpo = models.TextField(help_text='Texto que irá aparecer na '
31                 'página de detalhes da notícia.')
32
33     class Admin:
34         js = ('/site_media/tiny_mce/tiny_mce.js',
35               '/site_media/js/textarea-noticias.js',)
36
37     def __str__(self):
38         return self.titulo
39
40     def elipse(self):
41         if len(self.corpo) > ELLIPSIS_START:
42             return self.corpo[:ELLIPSIS_START] + ' ...'
43         else:
44             return self.corpo
45
46
47 class Secao(models.Model):
48     nome = models.CharField(maxlength=100)
49     index = models.BooleanField(help_text='Se marcado aparecerá na index, '
50             'acima das notícias. Caso contrário, aparecerá no menu principal')
51     corpo = models.TextField()
52
53     class Meta:
54         verbose_name = 'seção'
55         verbose_name_plural = 'seções'
56
57     class Admin:
58         js = ('/site_media/tiny_mce/tiny_mce.js',
59               '/site_media/js/textarea-noticias.js',)
60
61     def __str__(self):
62         return self.nome
63
64
65 class Menu(models.Model):
66     titulo = models.CharField(maxlength=100)
67     secao = models.ForeignKey(Secao)
68
69     class Admin:
70         pass
71
72     def __str__(self):
73         return self.titulo