adding images to the new layout
[cascardo/ema.git] / urls.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2008 Lincoln de Sousa <lincoln@minaslivre.org>
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public
15 # License along with this program; if not, write to the
16 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
18 from django.conf.urls.defaults import *
19 from django.conf import settings
20 from diario.settings import DIARIO_NUM_LATEST
21 from diario.models import Entry
22 from contents.models import Menu
23
24 MEDIA = {'document_root': settings.INSTANCE('media')}
25
26 # the only difference between info_dict and info_dict_full is that the
27 # full version contains all entries and the other has just entries
28 # without menus.
29
30 hasmenu = [x.entry.id for x in Menu.objects.all()]
31 info_dict = {
32     'queryset': Entry.published_on_site.exclude(id__in=hasmenu),
33     'template_object_name': 'entry',
34     'extra_context': {'menus': Menu.objects.all()},
35 }
36
37 info_dict_full = {
38     'queryset': Entry.published_on_site.all(),
39     'template_object_name': 'entry',
40     'extra_context': {'menus': Menu.objects.all()},
41 }
42
43 urlpatterns = patterns('',
44     (r'^admin/', include('django.contrib.admin.urls')),
45
46     url(regex='^$',
47         view='django.views.generic.list_detail.object_list',
48         kwargs=dict(info_dict, paginate_by=DIARIO_NUM_LATEST),
49         name='index'),
50
51     url(regex='^(?P<year>\d{4})/(?P<month>[0-9]{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
52         view='diario.views.entries.entry_detail',
53         kwargs=dict(info_dict_full, slug_field='slug', month_format='%m',
54                     date_field='pub_date'),
55         name='diario-entry'),
56
57     (r'^', include('ema.eventos.urls')),
58
59     # static media
60     (r'^(?P<path>imgs/.*)$', 'django.views.static.serve', MEDIA),
61     (r'^(?P<path>css/.*)$', 'django.views.static.serve', MEDIA),
62 )