# -*- coding:utf-8 -*-

from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf import settings
from django.views.decorators.cache import cache_page

from dcf import views, feeds, sitemap

admin.autodiscover()

urlpatterns = patterns(
    '',
    url(r'^$', cache_page(60 * 15)(views.IndexPageView.as_view())),

    url(r'^new$', views.ItemCreateView.as_view(), name='item-new'),
    url(r'^edit/(?P<pk>\d+)$', views.ItemUpdateView.as_view(), name='item-edit'),

    # listings
    url(r'^(?P<pk>\d+)-(?P<slug>[-\w]+)$', cache_page(60 * 15)(views.ItemDetailView.as_view()), name='item'),
    url(r'^group/(?P<pk>\d+)-(?P<slug>[-\w]+)$', cache_page(60 * 15)(views.GroupDetail.as_view()), name='group'),

    url(r'^search/', views.SearchView.as_view(), name='search'),
    url(r'^robots\.txt$', cache_page(60 * 60)(views.RobotsView.as_view()), name='robots'),

    url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
        {'sitemaps': sitemap.sitemaps_dict}, name='sitemap'),
    url(r'^rss\.xml$', cache_page(60 * 15)(feeds.LatestItemFeed()), name='rss'),

    url(r'^user/$', views.MyItemsView.as_view(), name='my'),
    url(r'^user/profile/$', views.view_profile, name='profile'),
    url(r'^user/my/delete/(?P<pk>\d+)$', views.ItemDeleteView.as_view(), name='my-delete'),

    # authorization
    url(r'user/', include('social.apps.django_app.urls', namespace='social')),
    url(r'^user/login/', 'django.contrib.auth.views.login', name='login'),
    url(r'^user/logout/$', 'django.contrib.auth.views.logout', name='logout'),

    url(r'^admin/', include(admin.site.urls)),

)

handler404 = views.page404
handler403 = views.page403
handler500 = views.page500

if settings.DEBUG:
    from django.conf.urls.static import static
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
@@ -365,16 +365,17 @@
 l(r'%5Enew
+/
 $', view
@@ -439,32 +439,33 @@
 edit/(?P%3Cpk%3E%5Cd+)
+/
 $', views.ItemUp
@@ -550,32 +550,33 @@
 (?P%3Cslug%3E%5B-%5Cw%5D+)
+/
 $', cache_page(6
@@ -675,16 +675,17 @@
 %3E%5B-%5Cw%5D+)
+/
 $', cach
@@ -1278,16 +1278,17 @@
 %3Cpk%3E%5Cd+)
+/
 $', view

urls should ends with slash