adicionando view de notícias e adicionando listagem de menu
authorLincoln de Sousa <pythonwarrior@pidinti.localdomain>
Fri, 27 Jul 2007 20:45:35 +0000 (17:45 -0300)
committerLincoln de Sousa <pythonwarrior@pidinti.localdomain>
Fri, 27 Jul 2007 20:45:35 +0000 (17:45 -0300)
conteudo/views.py
templates/base.html
templates/index.html
urls.py
views.py

index 60f00ef..d7767a1 100644 (file)
@@ -1 +1,9 @@
-# Create your views here.
+from django.shortcuts import render_to_response
+from django.template import RequestContext, Context
+from eventmanager.conteudo.models import Noticia
+
+def noticia(request, nid):
+    n = Noticia.objects.get(pk=int(nid))
+    c = Context({'noticia': n})
+    return render_to_response('noticia.html', c,
+            context_instance=RequestContext(request))
index e69187e..866e564 100644 (file)
 
         {% endif %}
 
+        {% if menu %}
+        <ul id="menu">
+            {% for i in menu %}
+            <li><a href="/secao/{{ i.id }}">{{ i.titulo }}</a></li>
+            {% endfor %}
+        </ul>
+        {% endif %}
+
         <div id="conteudo">
         {% block content %}{% endblock %}
         </div>
index eb46c8e..efdbab8 100644 (file)
@@ -9,7 +9,7 @@
     <li>
         <strong>{{ i.titulo }}</strong> &mdash; <em>{{ i.data_criacao }} (por {{ i.autor }})</em>
         <p>{{ i.chamada }}</p>
-        <a href="/news/{{ i.id }}">Leia mais</a>
+        <a href="/noticias/{{ i.id }}">Leia mais</a>
     </li>
     {% endfor %}
 </ul>
diff --git a/urls.py b/urls.py
index 2429e1f..8780f22 100644 (file)
--- a/urls.py
+++ b/urls.py
@@ -18,10 +18,12 @@ Boston, MA 02111-1307, USA.
 """
 from django.conf.urls.defaults import *
 from django.conf import settings
+from conteudo import views as conteudo_views
 import views
 import os
 
 urlpatterns = patterns('',
+    (r'^noticias/(\d+)/$', conteudo_views.noticia),
     (r'^admin/', include('django.contrib.admin.urls')),
     (r'^logout/', 'django.contrib.auth.views.logout',
         {'next_page': '/'}),
index 8573791..1c3a6a4 100644 (file)
--- a/views.py
+++ b/views.py
@@ -20,12 +20,14 @@ from django.shortcuts import render_to_response
 from django.template import RequestContext, Context
 from eventmanager.decorators import enable_login_form
 from eventmanager.forms import InscreverPalestra, CadastroPalestrante
-from eventmanager.conteudo.models import Noticia
+from eventmanager.conteudo.models import Noticia, Menu
 
 @enable_login_form
 def index(request):
     news = Noticia.objects.order_by('-data_criacao')
-    c = Context({'news': news})
+    menus = Menu.objects.all()
+
+    c = Context({'news': news, 'menu': menus})
     return render_to_response('index.html', c,
             context_instance=RequestContext(request))