| /trunk/fleshin/urls/photos.py r6 | /trunk/fleshin/urls/photos.py r16 | ||
| 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 | album_info_dict = { | ||
| 28 | 'queryset': Album.objects.all(), | ||
| 29 | 'template_object_name': 'album', | ||
| 30 | } | ||
| 31 | 27 | ||
| 32 | photo_detail = url( | 28 | photo_detail = url( |
| 33 | regex = '^(?P<album>[-\w]+)/(?P<slug>[-\w]+)/$', | 29 | regex = '^[-\w]+/(?P<slug>[-\w]+)/$', |
| 34 | view = 'fleshin.views.photo_detail', | 30 | view = 'django.views.generic.list_detail.object_detail', |
| 35 | kwargs = dict(photo_info_dict, slug_field='slug'), | 31 | kwargs = dict(photo_info_dict, slug_field='slug'), |
| 36 | name = 'fleshin-photo' | 32 | name = 'fleshin-photo' |
| 37 | ) | 33 | ) |
| 38 | photo_list = url( # all photos + album list | 34 | photo_list = url( # all photos + album list |
| 39 | regex = '^$', | 35 | regex = '^$', |
| 40 | view = 'django.views.generic.list_detail.object_list', | 36 | view = 'django.views.generic.list_detail.object_list', |
| 41 | kwargs = dict(photo_info_dict, extra_context={'album_list': Album.objects.all}), | 37 | kwargs = dict(photo_info_dict, paginate_by=FLESHIN_NUM_LATEST, |
| 38 | extra_context={'album_list': Album.objects.all}), | ||
| 42 | name = 'fleshin-photo-list' | 39 | name = 'fleshin-photo-list' |
| 43 | ) | 40 | ) |
| 44 | photo_album_list = url( # only photos in ``album`` | 41 | photo_album_list = url( # only photos in ``album`` |
| 45 | regex = '^(?P<album>[-\w]+)/$', | 42 | regex = '^(?P<album>[-\w]+)/$', |
| 46 | view = 'fleshin.views.photo_list', | 43 | view = 'fleshin.views.photo_list', |
| 47 | kwargs = dict(photo_info_dict, paginate_by=FLESHIN_NUM_LATEST), | 44 | kwargs = dict(photo_info_dict, paginate_by=FLESHIN_NUM_LATEST), |
| 48 | name = 'fleshin-photo-album-list' | 45 | name = 'fleshin-photo-album-list' |
| 49 | ) | 46 | ) |
| 50 | album_detail = url( | 47 | |
| 51 | regex = '^(?P<slug>[-\w]+)/$', | 48 | urlpatterns = patterns('', photo_detail, photo_list, photo_album_list) |
| 52 | view = 'django.views.generic.list_detail.object_detail', | ||
| 53 | kwargs = dict(album_info_dict, slug_field='slug'), | ||
| 54 | name = 'fleshin-album' | ||
| 55 | ) | ||
| 56 | |||
| 57 | urlpatterns = patterns('', photo_detail, photo_list, photo_album_list, | ||
| 58 | album_detail) | ||