summaryrefslogtreecommitdiff
path: root/app/birds/urls.py
blob: 017ce39605f4e6389eaadbc2231dc9b6269569e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from django.conf.urls import url
from django.views.generic.base import RedirectView
from . import views

urlpatterns = [
    url(
        regex=r'(?P<user>[\w]+)/(?P<page>\d+)/',
        view=views.BirdListUserView.as_view(),
        name='list_by_person'
    ),
    url(
        regex=r'(?P<page>\d+)/$',
        view=views.BirdListView.as_view(),
        name="list"
    ),
    url(
        regex=r'^(?P<slug>[-_\w]+)$',
        view=views.BirdDetailView.as_view(),
        name='detail'
    ),
    # redirect /slug/ to /slug/1/ for live server
    url(
        regex=r'(?P<user>[-\w]+)/$',
        view=RedirectView.as_view(url="/birds/%(user)s/1/", permanent=False),
        name="list_person_redirect"
    ),
    url(
        regex=r'',
        view=RedirectView.as_view(url="/birds/1/", permanent=False),
        name="list_redirect"
    ),
]