X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fema.git;a=blobdiff_plain;f=urls.py;h=3a46f2d0382e99ee6a8661240ba03d4353a17d2c;hp=572767b3202584461165affa1c4a2a3452ac3c7c;hb=3245747f4c68a8b7dbd366702f51d4910a597be0;hpb=bcfecc088b96da943a969e5aa6e447425102773d diff --git a/urls.py b/urls.py index 572767b..3a46f2d 100644 --- a/urls.py +++ b/urls.py @@ -1,6 +1,66 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2008 Lincoln de Sousa +# +# 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.conf.urls.defaults import * +from django.conf import settings +from diario.settings import DIARIO_NUM_LATEST +from diario.models import Entry +from contents.models import Menu, Index +from ema.views import get_entry_by_slug + +MEDIA = {'document_root': settings.INSTANCE('media')} + +# the only difference between info_dict and info_dict_full is that the +# full version contains all entries and the other has just entries +# without menus. + +hasmenu = [x.entry.id for x in Menu.objects.all()] +inindex = [x.entry.id for x in Index.objects.all()] + +info_dict = { + 'queryset': Entry.published_on_site.exclude(id__in=hasmenu).filter(id__in=inindex), + 'template_object_name': 'entry', + 'extra_context': {'menus': Menu.objects.all()}, +} + +info_dict_full = { + 'queryset': Entry.published_on_site.all(), + 'template_object_name': 'entry', + 'extra_context': {'menus': Menu.objects.all()}, +} urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), - (r'^', include('diario.urls.entries')), + + url(regex='^$', + view='django.views.generic.list_detail.object_list', + kwargs=dict(info_dict, paginate_by=DIARIO_NUM_LATEST), + name='index'), + + url(regex='^(?P\d{4})/(?P[0-9]{2})/(?P\d{2})/(?P[-\w]+)/$', + view='diario.views.entries.entry_detail', + kwargs=dict(info_dict_full, slug_field='slug', month_format='%m', + date_field='pub_date'), + name='diario-entry'), + + (r'^([-\w]+)/$', get_entry_by_slug), + (r'^', include('ema.eventos.urls')), + + # static media + (r'^(?Pimgs/.*)$', 'django.views.static.serve', MEDIA), + (r'^(?Pcss/.*)$', 'django.views.static.serve', MEDIA), )