| /trunk/fleshin/urls/photos.py r16 | /trunk/fleshin/urls/photos.py r17 | ||
| 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
|---|---|---|---|
| 2 | # ---------------------------------------------------------------------------- | 2 | # ---------------------------------------------------------------------------- |
| 3 | # $Id$ | 3 | # $Id$ |
| 4 | # ---------------------------------------------------------------------------- | 4 | # ---------------------------------------------------------------------------- |
| 5 | # | 5 | # |
| 6 | # Copyright (c) 2008 Guilherme Mesquita Gondim | 6 | # Copyright (c) 2008 Guilherme Mesquita Gondim |
| 7 | # | 7 | # |
| 8 | # This file is part of django-fleshin. | 8 | # This file is part of django-fleshin. |
| 9 | # | 9 | # |
| 10 | # django-fleshin is free software under terms of the GNU General | 10 | # django-fleshin is free software under terms of the GNU General |
| 11 | # Public License version 3 (GPLv3) as published by the Free Software | 11 | # Public License version 3 (GPLv3) as published by the Free Software |
| 12 | # Foundation. See the file README for copying conditions. | 12 | # Foundation. See the file README for copying conditions. |
| 13 | # | 13 | # |
| 14 | 14 | ||
| 15 | """ | 15 | """ |
| 16 | URL definitions for photos and albums. | 16 | URL definitions for photos and albums. |
| 17 | """ | 17 | """ |
| 18 | 18 | ||
| 19 | from django.conf.urls.defaults import * | 19 | from django.conf.urls.defaults import * |
| 20 | from fleshin.models import Photo, Album | 20 | from fleshin.models import Photo, Album |
| 21 | from fleshin.settings import FLESHIN_NUM_LATEST | 21 | from fleshin.settings import FLESHIN_NUM_LATEST |
| 22 | 22 | ||
| 23 | photo_info_dict = { | 23 | photo_info_dict = { |
| 24 | 'queryset': Photo.published_on_site.all(), | 24 | 'queryset': Photo.published_on_site.all(), |
| 25 | 'template_object_name': 'photo', | 25 | 'template_object_name': 'photo', |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | photo_detail = url( | 28 | photo_detail = url( |
| 29 | regex = '^[-\w]+/(?P<slug>[-\w]+)/$', | 29 | regex = '^(?P<album>[-\w]+)/(?P<slug>[-\w]+)/$', |
| 30 | view = 'django.views.generic.list_detail.object_detail', | 30 | view = 'fleshin.views.photo_detail', |
| 31 | kwargs = dict(photo_info_dict, slug_field='slug'), | 31 | kwargs = dict(photo_info_dict, slug_field='slug'), |
| 32 | name = 'fleshin-photo' | 32 | name = 'fleshin-photo' |
| 33 | ) | 33 | ) |
| 34 | photo_list = url( # all photos + album list | 34 | photo_list = url( # all photos + album list |
| 35 | regex = '^$', | 35 | regex = '^$', |
| 36 | view = 'django.views.generic.list_detail.object_list', | 36 | view = 'django.views.generic.list_detail.object_list', |
| 37 | kwargs = dict(photo_info_dict, paginate_by=FLESHIN_NUM_LATEST, | 37 | kwargs = dict(photo_info_dict, paginate_by=FLESHIN_NUM_LATEST, |
| 38 | extra_context={'album_list': Album.objects.all}), | 38 | extra_context={'album_list': Album.objects.all}), |
| 39 | name = 'fleshin-photo-list' | 39 | name = 'fleshin-photo-list' |
| 40 | ) | 40 | ) |
| 41 | photo_album_list = url( # only photos in ``album`` | 41 | photo_album_list = url( # only photos in ``album`` |
| 42 | regex = '^(?P<album>[-\w]+)/$', | 42 | regex = '^(?P<album>[-\w]+)/$', |
| 43 | view = 'fleshin.views.photo_list', | 43 | view = 'fleshin.views.photo_list', |
| 44 | kwargs = dict(photo_info_dict, paginate_by=FLESHIN_NUM_LATEST), | 44 | kwargs = dict(photo_info_dict, paginate_by=FLESHIN_NUM_LATEST), |
| 45 | name = 'fleshin-photo-album-list' | 45 | name = 'fleshin-photo-album-list' |
| 46 | ) | 46 | ) |
| 47 | 47 | ||
| 48 | urlpatterns = patterns('', photo_detail, photo_list, photo_album_list) | 48 | urlpatterns = patterns('', photo_detail, photo_list, photo_album_list) |