+# -*- coding: utf-8 -*-
+# Copyright (C) 2008 Lincoln de Sousa <lincoln@minaslivre.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.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
+
+from django.contrib import admin
+admin.autodiscover()
+
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'^admin/(.*)', admin.site.root),
+
+ url(regex='^$',
+ view='django.views.generic.list_detail.object_list',
+ kwargs=dict(info_dict, paginate_by=DIARIO_NUM_LATEST),
+ name='index'),
+
+ url(regex='^(?P<year>\d{4})/(?P<month>[0-9]{2})/(?P<day>\d{2})/(?P<slug>[-\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'^', include('ema.eventos.urls')),
- (r'^', include('diario.urls.entries')),
+ (r'^([-\w]+)/$', get_entry_by_slug),
# static media
(r'^(?P<path>imgs/.*)$', 'django.views.static.serve', MEDIA),