root / snf-cyclades-app / synnefo / plankton / urls.py @ ec22dfc4
History | View | Annotate | Download (3.2 kB)
1 | c34de90f | Giorgos Verigakis | # Copyright 2011 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | c34de90f | Giorgos Verigakis | #
|
3 | c34de90f | Giorgos Verigakis | # Redistribution and use in source and binary forms, with or
|
4 | c34de90f | Giorgos Verigakis | # without modification, are permitted provided that the following
|
5 | c34de90f | Giorgos Verigakis | # conditions are met:
|
6 | c34de90f | Giorgos Verigakis | #
|
7 | c34de90f | Giorgos Verigakis | # 1. Redistributions of source code must retain the above
|
8 | c34de90f | Giorgos Verigakis | # copyright notice, this list of conditions and the following
|
9 | c34de90f | Giorgos Verigakis | # disclaimer.
|
10 | c34de90f | Giorgos Verigakis | #
|
11 | c34de90f | Giorgos Verigakis | # 2. Redistributions in binary form must reproduce the above
|
12 | c34de90f | Giorgos Verigakis | # copyright notice, this list of conditions and the following
|
13 | c34de90f | Giorgos Verigakis | # disclaimer in the documentation and/or other materials
|
14 | c34de90f | Giorgos Verigakis | # provided with the distribution.
|
15 | c34de90f | Giorgos Verigakis | #
|
16 | c34de90f | Giorgos Verigakis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | c34de90f | Giorgos Verigakis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | c34de90f | Giorgos Verigakis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | c34de90f | Giorgos Verigakis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | c34de90f | Giorgos Verigakis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | c34de90f | Giorgos Verigakis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | c34de90f | Giorgos Verigakis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | c34de90f | Giorgos Verigakis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | c34de90f | Giorgos Verigakis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | c34de90f | Giorgos Verigakis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | c34de90f | Giorgos Verigakis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | c34de90f | Giorgos Verigakis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | c34de90f | Giorgos Verigakis | #
|
29 | c34de90f | Giorgos Verigakis | # The views and conclusions contained in the software and
|
30 | c34de90f | Giorgos Verigakis | # documentation are those of the authors and should not be
|
31 | c34de90f | Giorgos Verigakis | # interpreted as representing official policies, either expressed
|
32 | c34de90f | Giorgos Verigakis | # or implied, of GRNET S.A.
|
33 | c34de90f | Giorgos Verigakis | |
34 | c34de90f | Giorgos Verigakis | from django.conf.urls.defaults import patterns |
35 | 15137c54 | Giorgos Verigakis | from django.http import HttpResponseNotAllowed |
36 | c34de90f | Giorgos Verigakis | |
37 | 15137c54 | Giorgos Verigakis | from synnefo.plankton import views |
38 | 15137c54 | Giorgos Verigakis | |
39 | 15137c54 | Giorgos Verigakis | |
40 | 15137c54 | Giorgos Verigakis | def demux(request): |
41 | 15137c54 | Giorgos Verigakis | if request.method == 'GET': |
42 | 15137c54 | Giorgos Verigakis | return views.list_public_images(request)
|
43 | 15137c54 | Giorgos Verigakis | elif request.method == 'POST': |
44 | 15137c54 | Giorgos Verigakis | return views.add_image(request)
|
45 | 15137c54 | Giorgos Verigakis | else:
|
46 | 15137c54 | Giorgos Verigakis | return HttpResponseNotAllowed(['GET', 'POST']) |
47 | 15137c54 | Giorgos Verigakis | |
48 | 15137c54 | Giorgos Verigakis | def demux_image(request, image_id): |
49 | 15137c54 | Giorgos Verigakis | if request.method == 'GET': |
50 | 15137c54 | Giorgos Verigakis | return views.get_image(request, image_id)
|
51 | 15137c54 | Giorgos Verigakis | elif request.method == 'HEAD': |
52 | 15137c54 | Giorgos Verigakis | return views.get_image_meta(request, image_id)
|
53 | 15137c54 | Giorgos Verigakis | elif request.method == 'PUT': |
54 | 15137c54 | Giorgos Verigakis | return views.update_image(request, image_id)
|
55 | 15137c54 | Giorgos Verigakis | else:
|
56 | 15137c54 | Giorgos Verigakis | return HttpResponseNotAllowed(['GET', 'HEAD', 'PUT']) |
57 | 15137c54 | Giorgos Verigakis | |
58 | 15137c54 | Giorgos Verigakis | def demux_image_members(request, image_id): |
59 | 15137c54 | Giorgos Verigakis | if request.method == 'GET': |
60 | 15137c54 | Giorgos Verigakis | return views.list_image_members(request, image_id)
|
61 | 15137c54 | Giorgos Verigakis | elif request.method == 'PUT': |
62 | 15137c54 | Giorgos Verigakis | return views.update_image_members(request, image_id)
|
63 | 15137c54 | Giorgos Verigakis | else:
|
64 | 15137c54 | Giorgos Verigakis | return HttpResponseNotAllowed(['GET', 'PUT']) |
65 | 15137c54 | Giorgos Verigakis | |
66 | 15137c54 | Giorgos Verigakis | def demux_members(request, image_id, member): |
67 | 15137c54 | Giorgos Verigakis | if request.method == 'DELETE': |
68 | 15137c54 | Giorgos Verigakis | return views.remove_image_member(request, image_id, member)
|
69 | 15137c54 | Giorgos Verigakis | elif request.method == 'PUT': |
70 | 15137c54 | Giorgos Verigakis | return views.add_image_member(request, image_id, member)
|
71 | 15137c54 | Giorgos Verigakis | else:
|
72 | 15137c54 | Giorgos Verigakis | return HttpResponseNotAllowed(['DELETE', 'PUT']) |
73 | 15137c54 | Giorgos Verigakis | |
74 | 15137c54 | Giorgos Verigakis | |
75 | 15137c54 | Giorgos Verigakis | urlpatterns = patterns('',
|
76 | 15137c54 | Giorgos Verigakis | (r'^images/$', demux),
|
77 | 15137c54 | Giorgos Verigakis | (r'^images/detail$', views.list_public_images, {'detail': True}), |
78 | 15137c54 | Giorgos Verigakis | (r'^images/([\w-]+)$', demux_image),
|
79 | 15137c54 | Giorgos Verigakis | (r'^images/([\w-]+)/members$', demux_image_members),
|
80 | 15137c54 | Giorgos Verigakis | (r'^images/([\w-]+)/members/(\w+)$', demux_members),
|
81 | 15137c54 | Giorgos Verigakis | (r'^shared-images/(\w+)$', views.list_shared_images)
|
82 | c34de90f | Giorgos Verigakis | ) |