b0c05683be569ee24bcfb34eed188000609f185a
[cascardo/eventmanager.git] / conteudo / models.py
1 # -*- coding: utf8; -*-
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     corpo = models.TextField()
50
51     class Meta:
52         verbose_name = 'seção'
53         verbose_name_plural = 'seções'
54
55     class Admin:
56         pass
57
58     def __str__(self):
59         return self.nome
60
61
62 class Menu(models.Model):
63     titulo = models.CharField(maxlength=100)
64     secao = models.ForeignKey(Secao)
65
66     class Admin:
67         pass
68
69     def __str__(self):
70         return self.titulo