source: telemeta/urls.py @ 8a5b1b5

cremcrem2devdev2diademsfeature/breadcrumbsfeature/ts-0.5feature/ts-0.5.4feature/writecachegenericinstru_searchlamlam2mapsv3mergenlivemultiproductionrelease/1.4.4sabiodsecurityserversocialstoragetelecastertest
Last change on this file since 8a5b1b5 was 8a5b1b5, checked in by yomguy <yomguy@…>, 2 years ago

fix menu bugs, fix some styles, add urls

  • Property mode set to 100644
File size: 20.6 KB
Line 
1# -*- coding: utf-8 -*-
2# Copyright (C) 2007 Samalyse SARL
3# Copyright (c) 2007-2011 Parisson SARL
4
5# This software is a computer program whose purpose is to backup, analyse,
6# transcode and stream any audio content with its metadata over a web frontend.
7
8# This software is governed by the CeCILL  license under French law and
9# abiding by the rules of distribution of free software.  You can  use,
10# modify and/ or redistribute the software under the terms of the CeCILL
11# license as circulated by CEA, CNRS and INRIA at the following URL
12# "http://www.cecill.info".
13
14# As a counterpart to the access to the source code and  rights to copy,
15# modify and redistribute granted by the license, users are provided only
16# with a limited warranty  and the software's author,  the holder of the
17# economic rights,  and the successive licensors  have only  limited
18# liability.
19
20# In this respect, the user's attention is drawn to the risks associated
21# with loading,  using,  modifying and/or developing or reproducing the
22# software by the user in light of its specific status of free software,
23# that may mean  that it is complicated to manipulate,  and  that  also
24# therefore means  that it is reserved for developers  and  experienced
25# professionals having in-depth computer knowledge. Users are therefore
26# encouraged to load and test the software's suitability as regards their
27# requirements in conditions enabling the security of their systems and/or
28# data to be ensured and,  more generally, to use and operate it in the
29# same conditions as regards security.
30
31# The fact that you are presently reading this means that you have had
32# knowledge of the CeCILL license and that you accept its terms.
33#
34# Authors: Olivier Guilyardi <olivier@samalyse.com>
35#          Guillaume Pellerin <yomguy@parisson.com>
36
37from django.conf.urls.defaults import *
38from django.conf import settings
39from django.views.generic.simple import redirect_to
40from telemeta.models import MediaItem, MediaCollection, MediaItemMarker, MediaCorpus, MediaFonds
41from telemeta.views.base import GeneralView, AdminView, CollectionView, ItemView, \
42                                InstrumentView, PlaylistView, ProfileView, GeoView, \
43                                LastestRevisionsFeed, ResourceView, UserRevisionsFeed
44from jsonrpc import jsonrpc_site
45import os.path
46import telemeta.config
47
48telemeta.config.check()
49
50# initialization
51general_view = GeneralView()
52admin_view = AdminView()
53collection_view = CollectionView()
54item_view = ItemView()
55instrument_view = InstrumentView()
56playlist_view = PlaylistView()
57profile_view = ProfileView()
58geo_view = GeoView()
59resource_view = ResourceView()
60
61# query sets for Django generic views
62all_items = { 'queryset': MediaItem.objects.enriched().order_by('code', 'old_code') }
63all_items_sound = { 'queryset': MediaItem.objects.sound().order_by('code', 'old_code') }
64all_collections = { 'queryset': MediaCollection.objects.enriched(), }
65all_collections_unpublished = { 'queryset': MediaCollection.objects.filter(code__contains='_I_'), }
66all_collections_published = { 'queryset': MediaCollection.objects.filter(code__contains='_E_'), }
67all_collections_sound = { 'queryset': MediaCollection.objects.sound().order_by('code', 'old_code') }
68all_corpus = { 'queryset': MediaCorpus.objects.all().order_by('title') }
69all_fonds = { 'queryset': MediaFonds.objects.all().order_by('title') }
70
71# ID's regular expressions
72export_extensions = "|".join(item_view.list_export_extensions())
73
74htdocs = os.path.dirname(__file__) + '/htdocs'
75
76urlpatterns = patterns('',
77    url(r'^$', general_view.home, name="telemeta-home"),
78
79    # items
80    url(r'^archives/items/$', 'django.views.generic.list_detail.object_list',
81        dict(all_items, paginate_by=20, template_name="telemeta/mediaitem_list.html"),
82        name="telemeta-items"),
83    url(r'^archives/items_sound/$', 'django.views.generic.list_detail.object_list',
84        dict(all_items_sound, paginate_by=20, template_name="telemeta/mediaitem_list.html"), name="telemeta-items-sound"),
85    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/$', item_view.item_detail,
86        name="telemeta-item-detail"),
87    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/dc/$', item_view.item_detail,
88        {'template': 'telemeta/mediaitem_detail_dc.html'},
89        name="telemeta-item-dublincore"),
90    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/dc/xml/$', item_view.item_detail,
91        {'format': 'dublin_core_xml'},
92        name="telemeta-item-dublincore-xml"),
93    url(r'^archives/items/download/(?P<public_id>[A-Za-z0-9._-]+)\.(?P<extension>'
94            + export_extensions + ')$',
95        item_view.item_export,
96        name="telemeta-item-export"),
97    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/visualize/(?P<visualizer_id>[0-9a-z_]+)/(?P<width>[0-9A-Z]+)x(?P<height>[0-9A-Z]+)/$',
98        item_view.item_visualize,
99        name="telemeta-item-visualize"),
100    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/analyze/xml/$',
101        item_view.item_analyze_xml,
102        name="telemeta-item-analyze-xml"),
103    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/item_xspf.xml$',
104        item_view.item_playlist,
105        dict(template="telemeta/mediaitem_xspf.xml", mimetype="application/xspf+xml"),
106        name="telemeta-item-xspf"),
107    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/edit/$', item_view.item_edit,
108        dict(template='telemeta/mediaitem_edit.html'), name="telemeta-item-edit"),
109    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/copy/$', item_view.item_copy,
110        dict(template='telemeta/mediaitem_copy.html'), name="telemeta-item-copy"),
111    url(r'^archives/item_new/add/$', item_view.item_add,
112        dict(template='telemeta/mediaitem_add.html'), name="telemeta-item-add"),
113    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/player/(?P<width>[0-9]+)x(?P<height>[0-9]+)/$', item_view.item_detail,
114        dict(template='telemeta/mediaitem_player.html'), name="telemeta-item-player"),
115    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/performances/$', item_view.item_performances_edit,
116        dict(template='telemeta/mediaitem_performances_edit.html'), name="telemeta-item-performances_edit"),
117    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/keywords/$', item_view.item_keywords_edit,
118        dict(template='telemeta/mediaitem_keywords_edit.html'), name="telemeta-item-keywords_edit"),
119    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/delete/$', item_view.item_delete, name="telemeta-item-delete"),
120    url(r'^archives/items/(?P<item_public_id>[A-Za-z0-9._-]+)/related/(?P<media_id>[A-Za-z0-9._-]+)$', item_view.related_media_item_stream, name="telemeta-item-related"),
121    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/related_edit/$', item_view.related_media_edit,  dict(template='telemeta/mediaitem_related_edit.html'), name="telemeta-item-related_edit"),
122    # Markers
123    url(r'^markers/(?P<marker_id>[A-Za-z0-9]+)/$', item_view.item_detail, name="telemeta-item-detail-marker"),
124    # FIXME: need all paths
125    url(r'^items/(?P<path>[A-Za-z0-9._-s/]+)/$', redirect_to, {'url': '/archives/items/%(path)s/', 'permanent': False}, name="telemeta-item-redir"),
126
127    # collections
128    url(r'^archives/collections/$', 'django.views.generic.list_detail.object_list',
129        dict(all_collections, paginate_by=20, template_name="telemeta/collection_list.html"), name="telemeta-collections"),
130    url(r'^archives/collections_unpublished/$', 'django.views.generic.list_detail.object_list',
131        dict(all_collections_unpublished, paginate_by=20, template_name="telemeta/collection_list.html"), name="telemeta-collections-unpublished"),
132    url(r'^archives/collections_published/$', 'django.views.generic.list_detail.object_list',
133        dict(all_collections_published, paginate_by=20, template_name="telemeta/collection_list.html"), name="telemeta-collections-published"),
134    url(r'^archives/collections/?page=(?P<page>[0-9]+)$',
135        'django.views.generic.list_detail.object_list',
136        dict(all_collections, paginate_by=20)),
137    url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/$', collection_view.collection_detail,
138        dict(template="telemeta/collection_detail.html"), name="telemeta-collection-detail"),
139    url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/dc/$', collection_view.collection_detail,
140        dict(template="telemeta/collection_detail_dc.html"), name="telemeta-collection-dublincore"),
141    url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/collection_xspf.xml$',
142        collection_view.collection_playlist,
143        dict(template="telemeta/collection_xspf.xml", mimetype="application/xspf+xml"),
144        name="telemeta-collection-xspf"),
145    url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/collection.m3u$',
146        collection_view.collection_playlist,
147        dict(template="telemeta/collection.m3u", mimetype="audio/mpegurl"),
148        name="telemeta-collection-m3u"),
149    url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/edit/$', collection_view.collection_edit,
150        dict(template='telemeta/collection_edit.html'), name="telemeta-collection-edit"),
151    url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/copy/$', collection_view.collection_copy,
152        dict(template='telemeta/collection_edit.html'), name="telemeta-collection-copy"),
153    url(r'^archives/collection_new/add/$', collection_view.collection_add,
154        dict(template='telemeta/collection_add.html'), name="telemeta-collection-add"),
155    url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/add_item/$', item_view.item_add,
156        dict(template='telemeta/mediaitem_add.html'), name="telemeta-collection-additem"),
157    url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/delete/$', collection_view.collection_delete, name="telemeta-collection-delete"),
158    url(r'^archives/collections/(?P<collection_public_id>[A-Za-z0-9._-]+)/related/(?P<media_id>[A-Za-z0-9._-]+)$', collection_view.related_media_collection_stream, name="telemeta-collection-related"),
159    url(r'^archives/collections/(?P<public_id>[A-Za-z0-9._-]+)/related_edit/$', collection_view.related_media_edit,  dict(template='telemeta/collection_related_edit.html'), name="telemeta-collection-related_edit"),
160    url(r'^archives/collections_sound/$', 'django.views.generic.list_detail.object_list',
161        dict(all_collections_sound, paginate_by=20, template_name="telemeta/collection_list.html"), name="telemeta-collections-sound"),
162    # FIXME: need all paths
163    url(r'^collections/(?P<path>[A-Za-z0-9._-s/]+)/$', redirect_to, {'url': '/archives/collections/%(path)s/', 'permanent': False}, name="telemeta-collection-redir"),
164
165    # RESOURCES
166    # Corpus list
167    url(r'^archives/corpus/$', 'django.views.generic.list_detail.object_list',
168        dict(all_corpus, paginate_by=20, template_name="telemeta/resource_list.html", extra_context={'type':'corpus'}), name="telemeta-corpus"),
169    # Fonds list
170    url(r'^archives/fonds/$', 'django.views.generic.list_detail.object_list',
171        dict(all_fonds, paginate_by=20, template_name="telemeta/resource_list.html", extra_context={'type':'fonds'}), name="telemeta-fonds"),
172
173    # Generic resource
174    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/$', resource_view.detail,
175        dict(template="telemeta/resource_detail.html"), name="telemeta-resource-detail"),
176    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/dc/$', resource_view.detail,
177        dict(template="telemeta/resource_detail_dc.html"), name="telemeta-resource-dublincore"),
178    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/edit/$', resource_view.edit,
179        dict(template='telemeta/resource_edit.html'), name="telemeta-resource-edit"),
180    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/copy/$', resource_view.copy,
181        dict(template='telemeta/resource_edit.html'), name="telemeta-resource-copy"),
182    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)_add$', resource_view.add,
183        dict(template='telemeta/resource_add.html'), name="telemeta-resource-add"),
184    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/delete/$', resource_view.delete, name="telemeta-resource-delete"),
185    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/related/(?P<media_id>[A-Za-z0-9._-]+)$', resource_view.related_stream, name="telemeta-resource-related"),
186    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/related_edit/$', resource_view.related_edit,  dict(template='telemeta/resource_related_edit.html'), name="telemeta-resource-related_edit"),
187    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/dc/$', resource_view.detail,
188        {'template': 'telemeta/resource_detail_dc.html'},
189        name="telemeta-resource-dublincore"),
190    url(r'^archives/(?P<type>[A-Za-z0-9._-]+)/(?P<public_id>[A-Za-z0-9._-]+)/dc/xml/$', resource_view.detail,
191        {'format': 'dublin_core_xml'},
192        name="telemeta-resource-dublincore-xml"),
193    url(r'^archives/$', general_view.search, name="telemeta-archives"),
194
195    # search
196    url(r'^search/$', general_view.search, name="telemeta-search"),
197    url(r'^search/collections/$', general_view.search, {'type': 'collections'},
198        name="telemeta-search-collections"),
199    url(r'^search/items/$', general_view.search, {'type': 'items'},
200        name="telemeta-search-items"),
201    url(r'^search/corpus/$', general_view.search, {'type': 'corpus'},
202        name="telemeta-search-corpus"),
203    url(r'^search/fonds/$', general_view.search, {'type': 'fonds'},
204        name="telemeta-search-fonds"),
205
206    url(r'^search/criteria/$', general_view.edit_search, name="telemeta-search-criteria"),
207    url(r'^complete_location/$', general_view.complete_location, name="telemeta-complete-location"),
208
209    # administration
210    url(r'^admin/$', admin_view.admin_index, name="telemeta-admin"),
211    url(r'^admin/general/$', admin_view.admin_general, name="telemeta-admin-general"),
212    url(r'^admin/enumerations/$', admin_view.admin_enumerations, name="telemeta-admin-enumerations"),
213    url(r'^admin/users/$', admin_view.admin_users, name="telemeta-admin-users"),
214
215    # instruments administration
216    url(r'^admin/instruments/$',
217        instrument_view.edit_instrument ,
218        name="telemeta-instrument-edit"),
219    url(r'^admin/instruments/add/$',
220        instrument_view.add_to_instrument,
221        name="telemeta-instrument-add"),
222    url(r'^admin/instruments/update/$',
223        instrument_view.update_instrument,
224        name="telemeta-instrument-update"),
225    url(r'^admin/instruments/'
226        + r'(?P<value_id>[0-9]+)/$',
227        instrument_view.edit_instrument_value,
228        name="telemeta-instrument-record-edit"),
229    url(r'^admin/instruments/'
230        + r'(?P<value_id>[0-9]+)/update/$',
231        instrument_view.update_instrument_value,
232        name="telemeta-instrument-record-update"),
233
234    # enumerations administration
235    url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/$',
236        admin_view.edit_enumeration ,
237        name="telemeta-enumeration-edit"),
238    url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/add/$',
239        admin_view.add_to_enumeration,
240        name="telemeta-enumeration-add"),
241    url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/update/$',
242        admin_view.update_enumeration,
243        name="telemeta-enumeration-update"),
244    url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/'
245        + r'(?P<value_id>[0-9]+)/$',
246        admin_view.edit_enumeration_value,
247        name="telemeta-enumeration-record-edit"),
248    url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/'
249        + r'(?P<value_id>[0-9]+)/update/$',
250        admin_view.update_enumeration_value,
251        name="telemeta-enumeration-record-update"),
252
253    # Geographic browsing
254    url(r'^geo/$', geo_view.list_continents, name="telemeta-geo-continents"),
255    url(r'^geo/(?P<continent>[a-z_]+)/$', geo_view.list_countries,
256        name="telemeta-geo-countries"),
257    url(r'^geo/collections/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$',
258        geo_view.list_country_collections,
259        name="telemeta-geo-country-collections"),
260    url(r'^geo/items/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$',
261        geo_view.list_country_items,
262        name="telemeta-geo-country-items"),
263    url(r'^geo/country_info/(?P<id>[0-9a-z]+)/$',
264        geo_view.country_info, name="telemeta-country-info"),
265
266    # CSS+Images (FIXME: for developement only)
267    url(r'^css/(?P<path>.*)$', 'django.views.static.serve',
268        {'document_root': htdocs+'/css'},
269        name="telemeta-css"),
270    url(r'images/(?P<path>.*)$', 'django.views.static.serve',
271        {'document_root': htdocs+'/images'},
272        name="telemeta-images"),
273    url(r'images/(?P<path>.*).png$', 'django.views.static.serve',
274        {'document_root': htdocs+'/images'},
275        name="telemeta-type-images"),
276    url(r'^js/(?P<path>.*)$', 'django.views.static.serve',
277        {'document_root': htdocs+'/js'},
278        name="telemeta-js"),
279    url(r'^swf/(?P<path>.*)$', 'django.views.static.serve',
280        {'document_root': htdocs+'/swf'},
281        name="telemeta-swf"),
282    url(r'^timeside/(?P<path>.*)$', 'django.views.static.serve',
283        {'document_root': htdocs+'/timeside'},
284        name="telemeta-timeside"),
285
286    # Flat pages
287    url(r'^pages/(?P<path>.*)$', general_view.render_flatpage, name="telemeta-flatpage"),
288
289    # OAI-PMH Data Provider
290    url(r'^oai/.*$', general_view.handle_oai_request, name="telemeta-oai"),
291
292    # Authentication
293    url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'telemeta/login.html'},
294        name="telemeta-login"),
295    url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'telemeta/login.html'},
296        name="telemeta-login"),
297    #url(r'^login/$', 'ipauth.views.login', {'template_name': 'telemeta/login.html'},
298    #    name="telemeta-login"),
299    url(r'^logout/$', general_view.logout, name="telemeta-logout"),
300
301    # Users
302    url(r'^users/$', general_view.users, name="telemeta-users"),
303
304    # Desk
305    url(r'^desk/lists/$', general_view.lists, name="telemeta-desk-lists"),
306    url(r'^desk/profile/(?P<username>[A-Za-z0-9._-]+)/$', profile_view.profile_detail, name="telemeta-desk-profile"),
307    url(r'^desk/home/$', general_view.home, name="telemeta-desk-home"),
308
309    # Profiles
310    url(r'^users/(?P<username>[A-Za-z0-9._-]+)/profile/$', profile_view.profile_detail, name="telemeta-profile-detail"),
311    url(r'^users/(?P<username>[A-Za-z0-9._-]+)/profile/edit/$', profile_view.profile_edit, name="telemeta-profile-edit"),
312    url(r'^users/(?P<username>[A-Za-z0-9._-]+)/rss/$', UserRevisionsFeed(),  name="telemeta-user-rss"),
313
314    # Registration
315    url(r'^accounts/password_change/$', 'django.contrib.auth.views.password_change', {'template_name': 'telemeta/registration/password_change_form.html'}, name="telemeta-password-change"),
316    url(r'^accounts/password_change_done/$', 'django.contrib.auth.views.password_change_done', {'template_name': 'telemeta/registration/password_change_done.html'}, name="telemeta-password-change-done"),
317
318    url(r'^accounts/password_reset/$', 'django.contrib.auth.views.password_reset', {'template_name': 'telemeta/registration/password_reset_form.html', 'email_template_name': 'telemeta/registration/password_reset_email.html'}, name="telemeta-password-reset"),
319    url(r'^accounts/password_reset_done/$', 'django.contrib.auth.views.password_reset_done', {'template_name': 'telemeta/registration/password_reset_done.html'}, name="telemeta-password-reset-done"),
320    url(r'^accounts/password_reset_confirm/(?P<uidb36>[A-Za-z0-9._-]+)/(?P<token>[A-Za-z0-9._-]+)/$', 'django.contrib.auth.views.password_reset_confirm', {'template_name': 'telemeta/registration/password_reset_confirm.html'}, name="telemeta-password-reset-confirm"),
321    url(r'^accounts/password_reset_complete/$', 'django.contrib.auth.views.password_reset_complete', {'template_name': 'telemeta/registration/password_reset_complete.html'}, name="telemeta-password-reset-complete"),
322    url(r'^accounts/password_reset_complete/$', 'django.contrib.auth.views.password_reset_complete', {'template_name': 'telemeta/registration/password_reset_complete.html'}, name="telemeta-password-reset-complete"),
323
324    # JSON RPC
325    url(r'json/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint'),
326    # for the graphical browser/web console only, omissible
327    # url(r'json/browse/', 'jsonrpc.views.browse', name="jsonrpc_browser"),
328
329    # Playlists
330    url(r'^playlists/(?P<public_id>[a-zA-Z0-9]+)/(?P<resource_type>[a-zA-Z0-9]+)/csv/$', playlist_view.playlist_csv_export, name="telemeta-playlist-csv-export"),
331
332    # RSS feeds
333    url(r'^rss/$', LastestRevisionsFeed(), name="telemeta-rss"),
334
335    # Static media
336    # FIXME:need to move export dir from the cache
337    url(r'^media/cache/(?P<path>.*)$', 'django.views.static.serve', {
338            'document_root': settings.TELEMETA_CACHE_DIR,}),
339)
340
341
Note: See TracBrowser for help on using the repository browser.