urls.py 5.79 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
from views.autocomplete import (
    ProposalAutocomplete,
    RepresentativeAutocomplete,
11
    ThemeAutocomplete,
12
13
    ChamberAutocomplete,
    GroupAutocomplete,
Jamesie Pic's avatar
Jamesie Pic committed
14
)
Nicolas Joyard's avatar
Nicolas Joyard committed
15
16
17

from views.charts import ThemeScoresJSONView, ChamberScoresJSONView

Nicolas Joyard's avatar
Nicolas Joyard committed
18
from views.dossier_detail_base import DossierDetailBase
19
from views.dossier_detail_recommendations import DossierDetailRecommendations
Nicolas Joyard's avatar
Nicolas Joyard committed
20
21
from views.dossier_detail_proposals import DossierDetailProposals
from views.dossier_detail_documents import DossierDetailDocuments
22
from views.dossier_list import DossierList
Nicolas Joyard's avatar
Nicolas Joyard committed
23

24
from views.representative_detail_base import RepresentativeDetailBase
25
26
27
from views.representative_detail_votes import RepresentativeDetailVotes
from views.representative_detail_mandates import RepresentativeDetailMandates
from views.representative_detail_positions import RepresentativeDetailPositions
28
from views.representative_list import RepresentativeList
29
from views.representative_search import search_autocomplete
Nicolas Joyard's avatar
Nicolas Joyard committed
30
31
32
33

from views.redirects import (
    RedirectRepresentativeDetail,
    RedirectThemeDetail,
Nicolas Joyard's avatar
Nicolas Joyard committed
34
35
    RedirectGroupRepresentativeList,
    RedirectDossierDetail
Nicolas Joyard's avatar
Nicolas Joyard committed
36
37
38
39
40
41
42
)

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
43
from views.theme_list import ThemeList
44

45
46
from .legacy_urls import urlpatterns as legacy_patterns

Jamesie Pic's avatar
Jamesie Pic committed
47
import api
luxcem's avatar
luxcem committed
48

49

Arnaud Fabre's avatar
Arnaud Fabre committed
50
51
admin.autodiscover()

Jamesie Pic's avatar
Jamesie Pic committed
52
urlpatterns = [
53
54
55
56
57
58
59
60
61
62
63
64
65

    # 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
66
    url(
67
        r'^representatives/$',
68
69
70
        RepresentativeList.as_view(),
        name='representative-list'
    ),
71
72
73

    # Representative detail

74
    url(
75
        r'^representatives/(?P<slug>[-\w]+)/$',
76
        RedirectRepresentativeDetail.as_view(),
77
78
        name='representative-detail'
    ),
79

80
    url(
81
        r'^representatives/(?P<slug>[-\w]+)/votes/$',
82
83
84
        RepresentativeDetailVotes.as_view(),
        name='representative-votes'
    ),
85

86
    url(
87
        r'^representatives/(?P<slug>[-\w]+)/mandates/$',
88
89
90
        RepresentativeDetailMandates.as_view(),
        name='representative-mandates'
    ),
91

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

    # Dossier list

100
    url(
101
        r'^dossiers/$',
102
103
        DossierList.as_view(),
        name='dossier-list'
Jamesie Pic's avatar
Jamesie Pic committed
104
    ),
105
106
107

    # Dossier detail

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

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

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

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

Jamesie Pic's avatar
Jamesie Pic committed
132
    # Autocomplete
133

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

Jamesie Pic's avatar
Jamesie Pic committed
140
141
142
143
144
145
    url(
        r'^autocomplete/representative/$',
        RepresentativeAutocomplete.as_view(),
        name='representative-autocomplete',
    ),

146
147
148
149
150
151
    url(
        r'^autocomplete/theme/$',
        ThemeAutocomplete.as_view(),
        name='theme-autocomplete',
    ),

152
153
154
155
156
157
158
159
160
161
162
    url(
        r'^autocomplete/chamber/$',
        ChamberAutocomplete.as_view(),
        name='chamber-autocomplete',
    ),

    url(
        r'^autocomplete/group/$',
        GroupAutocomplete.as_view(),
        name='group-autocomplete',
    ),
163
164
165

    # Theme list

166
    url(
167
        r'^themes/$',
168
169
170
        ThemeList.as_view(),
        name='theme-list'
    ),
171
172
173

    # Theme detail

174
    url(
175
        r'^themes/(?P<slug>[-\w]+)/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
176
        RedirectThemeDetail.as_view(),
177
178
        name='theme-detail'
    ),
179

180
    url(
181
        r'^themes/(?P<slug>[-\w]+)/links/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
182
183
184
        ThemeDetailLinks.as_view(),
        name='theme-links'
    ),
185

Nicolas Joyard's avatar
Nicolas Joyard committed
186
    url(
187
        r'^themes/(?P<slug>[-\w]+)/dossiers/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
188
189
190
        ThemeDetailDossiers.as_view(),
        name='theme-dossiers'
    ),
191

Nicolas Joyard's avatar
Nicolas Joyard committed
192
    url(
193
        r'^themes/(?P<slug>[-\w]+)/proposals/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
194
195
196
        ThemeDetailProposals.as_view(),
        name='theme-proposals'
    ),
197

Nicolas Joyard's avatar
Nicolas Joyard committed
198
    url(
199
        r'^themes/(?P<slug>[-\w]+)/positions/$',
Nicolas Joyard's avatar
Nicolas Joyard committed
200
201
        ThemeDetailPositions.as_view(),
        name='theme-positions'
202
    ),
Jamesie Pic's avatar
Jamesie Pic committed
203

204
205
206
207
208
209
210
211
    # 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
    # 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'
    ),

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
    # 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'
    ),
245
246
247
248
249
    url(
        r'^representative/search/$',
        search_autocomplete,
        name="representative-search-name-autocomplete"
    ),
250
251

] + legacy_patterns