adicionando gerenciamento de conteudo (noticias, secoes e menus)
authorLincoln de Sousa <pythonwarrior@pidinti.localdomain>
Fri, 27 Jul 2007 14:52:59 +0000 (11:52 -0300)
committerLincoln de Sousa <pythonwarrior@pidinti.localdomain>
Fri, 27 Jul 2007 14:52:59 +0000 (11:52 -0300)
conteudo/__init__.py [new file with mode: 0644]
conteudo/models.py [new file with mode: 0644]
conteudo/views.py [new file with mode: 0644]

diff --git a/conteudo/__init__.py b/conteudo/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/conteudo/models.py b/conteudo/models.py
new file mode 100644 (file)
index 0000000..49720e3
--- /dev/null
@@ -0,0 +1,71 @@
+# -*- coding: utf8; -*-
+"""
+Copyright (C) 2007 Lincoln de Sousa <lincoln@archlinux-br.org>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with this program; if not, write to the
+Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+"""
+from django.db import models
+from django.contrib.auth.models import User
+
+ELLIPSIS_START = 400
+
+class Noticia(models.Model):
+    titulo = models.CharField(maxlength=100)
+    autor = models.ForeignKey(User)
+    data_criacao = models.DateTimeField(auto_now=True)
+    chamada = models.CharField(maxlength=400,
+                help_text='Texto que irá aparecer na index.')
+    corpo = models.TextField(help_text='Texto que irá aparecer na '
+                'página de detalhes da notícia.')
+
+    class Admin:
+        js = ('/site_media/tiny_mce/tiny_mce.js',
+              '/site_media/js/textarea.js',)
+
+
+    def __str__(self):
+        return '%s - %s' % (self.titulo, self.data_criacao)
+
+    def elipse(self):
+        if len(self.corpo) > ELLIPSIS_START:
+            return self.corpo[:ELLIPSIS_START] + ' ...'
+        else:
+            return self.corpo
+
+class Secao(models.Model):
+    nome = models.CharField(maxlength=100)
+    corpo = models.TextField()
+
+    class Meta:
+        verbose_name = 'seção'
+        verbose_name_plural = 'seções'
+
+    class Admin:
+        pass
+
+    def __str__(self):
+        return self.nome
+
+
+class Menu(models.Model):
+    titulo = models.CharField(maxlength=100)
+    secao = models.ForeignKey(Secao)
+
+    class Admin:
+        pass
+
+    def __str__(self):
+        return self.titulo
diff --git a/conteudo/views.py b/conteudo/views.py
new file mode 100644 (file)
index 0000000..60f00ef
--- /dev/null
@@ -0,0 +1 @@
+# Create your views here.