urls.py 5.17 KB
Newer Older
Arnaud Fabre's avatar
Arnaud Fabre committed
1
# coding: utf-8
2

Jamesie Pic's avatar
Jamesie Pic committed
3
from django.conf.urls import include, url
luxcem's avatar
Init  
luxcem committed
4
from django.contrib import admin
Nicolas Joyard's avatar
Nicolas Joyard committed
5 6

from views.home import HomeView
luxcem's avatar
Init  
luxcem committed
7

Jamesie Pic's avatar
Jamesie Pic committed
8 9 10 11
from views.autocomplete import (
    ProposalAutocomplete,
    RepresentativeAutocomplete,
)
Nicolas Joyard's avatar
Nicolas Joyard committed
12 13 14

from views.charts import ThemeScoresJSONView, ChamberScoresJSONView

Nicolas Joyard's avatar
Nicolas Joyard committed
15
from views.dossier_detail_base import DossierDetailBase
16
from views.dossier_detail_recommendations import DossierDetailRecommendations
Nicolas Joyard's avatar
Nicolas Joyard committed
17 18
from views.dossier_detail_proposals import DossierDetailProposals
from views.dossier_detail_documents import DossierDetailDocuments
19
from views.dossier_list import DossierList
Nicolas Joyard's avatar
Nicolas Joyard committed
20

21
from views.representative_detail_base import RepresentativeDetailBase
22 23 24
from views.representative_detail_votes import RepresentativeDetailVotes
from views.representative_detail_mandates import RepresentativeDetailMandates
from views.representative_detail_positions import RepresentativeDetailPositions
25
from views.representative_list import RepresentativeList
Nicolas Joyard's avatar
Nicolas Joyard committed
26 27 28 29

from views.redirects import (
    RedirectRepresentativeDetail,
    RedirectThemeDetail,
Nicolas Joyard's avatar
Nicolas Joyard committed
30 31
    RedirectGroupRepresentativeList,
    RedirectDossierDetail
Nicolas Joyard's avatar
Nicolas Joyard committed
32 33 34 35 36 37 38
)

from views.theme_detail_base import ThemeDetailBase
from views.theme_detail_links import ThemeDetailLinks
from views.theme_detail_dossiers import ThemeDetailDossiers
from views.theme_detail_proposals import ThemeDetailProposals
from views.theme_detail_positions import ThemeDetailPositions
39
from views.theme_list import ThemeList
40

41 42
from .legacy_urls import urlpatterns as legacy_patterns

Jamesie Pic's avatar
Jamesie Pic committed
43
import api
luxcem's avatar
luxcem committed
44

45

Arnaud Fabre's avatar
Arnaud Fabre committed
46 47
admin.autodiscover()

Jamesie Pic's avatar
Jamesie Pic committed
48
urlpatterns = [
49 50 51 52 53 54 55 56 57 58 59 60 61

    # Imported URLs

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

    url(r'^api/', include(api.router.urls)),

    # Homepage

    url(r'^$', HomeView.as_view(), name='home'),

    # Representative list

Robin's avatar
Robin committed
62
    url(
63
        r'^representatives/$',
64 65 66
        RepresentativeList.as_view(),
        name='representative-list'
    ),
67 68 69

    # Representative detail

70
    url(
71
        r'^representatives/(?P<slug>[-\w]+)/$',
72
        RedirectRepresentativeDetail.as_view(),
73 74
        name='representative-detail'
    ),
75

76
    url(
77
        r'^representatives/(?P<slug>[-\w]+)/votes/$',
78 79 80
        RepresentativeDetailVotes.as_view(),
        name='representative-votes'
    ),
81

82
    url(
83
        r'^representatives/(?P<slug>[-\w]+)/mandates/$',
84 85 86
        RepresentativeDetailMandates.as_view(),
        name='representative-mandates'
    ),
87

88
    url(
89
        r'^representatives/(?P<slug>[-\w]+)/positions/$',
90 91 92
        RepresentativeDetailPositions.as_view(),
        name='representative-positions'
    ),
93 94 95

    # Dossier list

96
    url(
97
        r'^dossiers/$',
98 99
        DossierList.as_view(),
        name='dossier-list'
Jamesie Pic's avatar
Jamesie Pic committed
100
    ),
101 102 103

    # Dossier detail

Jamesie Pic's avatar
Jamesie Pic committed
104
    url(
105
        r'^dossiers/(?P<pk>\d+)/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
106
        RedirectDossierDetail.as_view(),
107
        name='dossier-detail'
Jamesie Pic's avatar
Jamesie Pic committed
108
    ),
109

Nicolas Joyard's avatar
Nicolas Joyard committed
110
    url(
111
        r'^dossiers/(?P<pk>\d+)/recommendations/$',
112 113 114
        DossierDetailRecommendations.as_view(),
        name='dossier-recommendations'
    ),
115

Nicolas Joyard's avatar
Nicolas Joyard committed
116
    url(
117
        r'^dossiers/(?P<pk>\d+)/proposals/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
118 119 120
        DossierDetailProposals.as_view(),
        name='dossier-proposals'
    ),
121

Nicolas Joyard's avatar
Nicolas Joyard committed
122
    url(
123
        r'^dossiers/(?P<pk>\d+)/documents/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
124 125 126
        DossierDetailDocuments.as_view(),
        name='dossier-documents'
    ),
127

Jamesie Pic's avatar
Jamesie Pic committed
128
    # Autocomplete
129

Jamesie Pic's avatar
Jamesie Pic committed
130
    url(
131
        r'^autocomplete/proposal/$',
132 133
        ProposalAutocomplete.as_view(),
        name='proposal-autocomplete',
Jamesie Pic's avatar
Jamesie Pic committed
134
    ),
Jamesie Pic's avatar
Jamesie Pic committed
135 136 137 138 139 140
    url(
        r'^autocomplete/representative/$',
        RepresentativeAutocomplete.as_view(),
        name='representative-autocomplete',
    ),

141 142 143

    # Theme list

144
    url(
145
        r'^themes/$',
146 147 148
        ThemeList.as_view(),
        name='theme-list'
    ),
149 150 151

    # Theme detail

152
    url(
153
        r'^themes/(?P<slug>[-\w]+)/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
154
        RedirectThemeDetail.as_view(),
155 156
        name='theme-detail'
    ),
157

158
    url(
159
        r'^themes/(?P<slug>[-\w]+)/links/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
160 161 162
        ThemeDetailLinks.as_view(),
        name='theme-links'
    ),
163

Nicolas Joyard's avatar
Nicolas Joyard committed
164
    url(
165
        r'^themes/(?P<slug>[-\w]+)/dossiers/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
166 167 168
        ThemeDetailDossiers.as_view(),
        name='theme-dossiers'
    ),
169

Nicolas Joyard's avatar
Nicolas Joyard committed
170
    url(
171
        r'^themes/(?P<slug>[-\w]+)/proposals/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
172 173 174
        ThemeDetailProposals.as_view(),
        name='theme-proposals'
    ),
175

Nicolas Joyard's avatar
Nicolas Joyard committed
176
    url(
177
        r'^themes/(?P<slug>[-\w]+)/positions/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
178 179
        ThemeDetailPositions.as_view(),
        name='theme-positions'
180
    ),
Jamesie Pic's avatar
Jamesie Pic committed
181

182 183 184 185 186 187 188 189
    # Group URLs

    url(
        r'^groups/(?P<group_kind>[-\w]+)/(?P<group>[^/]+)/$',
        RedirectGroupRepresentativeList.as_view(),
        name='redirect-group-representative-list'
    ),

Nicolas Joyard's avatar
Nicolas Joyard committed
190 191 192 193 194 195 196 197 198 199 200 201 202 203
    # Chart data URLs

    url(
        r'^charts/data/theme-scores/(?P<theme>\d+)/$',
        ThemeScoresJSONView.as_view(),
        name='charts-data-theme-scores'
    ),

    url(
        r'^charts/data/chamber-scores/(?P<chamber>\d+)/$',
        ChamberScoresJSONView.as_view(),
        name='charts-data-chamber-scores'
    ),

204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
    # Testing URLs

    url(
        r'^representatives/(?P<slug>[-\w]+)/none/$',
        RepresentativeDetailBase.as_view(),
        name='representative-none'
    ),

    url(
        r'^dossiers/(?P<pk>\d+)/none/$',
        DossierDetailBase.as_view(),
        name='dossier-none'
    ),

    url(
        r'^themes/(?P<slug>[-\w]+)/none/$',
        ThemeDetailBase.as_view(),
        name='theme-none'
    ),

] + legacy_patterns