Send email. It does not work. Please, fix it!
[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, Index
23 from ema.views import get_entry_by_slug
24
25 from django.contrib import admin
26 admin.autodiscover()
27
28
29 MEDIA = {'document_root': settings.INSTANCE('media')}
30
31 # the only difference between info_dict and info_dict_full is that the
32 # full version contains all entries and the other has just entries
33 # without menus.
34
35 hasmenu = [x.entry.id for x in Menu.objects.all()]
36 inindex = [x.entry.id for x in Index.objects.all()]
37
38 info_dict = {
39     'queryset': Entry.published_on_site.exclude(id__in=hasmenu).filter(id__in=inindex),
40     'template_object_name': 'entry',
41     'extra_context': {'menus': Menu.objects.all()},
42 }
43
44 info_dict_full = {
45     'queryset': Entry.published_on_site.all(),
46     'template_object_name': 'entry',
47     'extra_context': {'menus': Menu.objects.all()},
48 }
49
50 urlpatterns = patterns('',
51     (r'^admin/(.*)', admin.site.root),
52
53     url(regex='^$',
54         view='django.views.generic.list_detail.object_list',
55         kwargs=dict(info_dict, paginate_by=DIARIO_NUM_LATEST),
56         name='index'),
57
58     url(regex='^(?P<year>\d{4})/(?P<month>[0-9]{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
59         view='diario.views.entries.entry_detail',
60         kwargs=dict(info_dict_full, slug_field='slug', month_format='%m',
61                     date_field='pub_date'),
62         name='diario-entry'),
63
64     (r'^', include('ema.eventos.urls')),
65     (r'^([-\w]+)/$', get_entry_by_slug),
66
67     # static media
68     (r'^(?P<path>imgs/.*)$', 'django.views.static.serve', MEDIA),
69     (r'^(?P<path>css/.*)$', 'django.views.static.serve', MEDIA),
70 )