Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / plankton / urls.py @ aed77afe

History | View | Annotate | Download (3.3 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 aed77afe Christos Stavrakakis
49 15137c54 Giorgos Verigakis
def demux_image(request, image_id):
50 15137c54 Giorgos Verigakis
    if request.method == 'GET':
51 15137c54 Giorgos Verigakis
        return views.get_image(request, image_id)
52 15137c54 Giorgos Verigakis
    elif request.method == 'HEAD':
53 15137c54 Giorgos Verigakis
        return views.get_image_meta(request, image_id)
54 15137c54 Giorgos Verigakis
    elif request.method == 'PUT':
55 15137c54 Giorgos Verigakis
        return views.update_image(request, image_id)
56 15137c54 Giorgos Verigakis
    else:
57 15137c54 Giorgos Verigakis
        return HttpResponseNotAllowed(['GET', 'HEAD', 'PUT'])
58 15137c54 Giorgos Verigakis
59 aed77afe Christos Stavrakakis
60 15137c54 Giorgos Verigakis
def demux_image_members(request, image_id):
61 15137c54 Giorgos Verigakis
    if request.method == 'GET':
62 15137c54 Giorgos Verigakis
        return views.list_image_members(request, image_id)
63 15137c54 Giorgos Verigakis
    elif request.method == 'PUT':
64 15137c54 Giorgos Verigakis
        return views.update_image_members(request, image_id)
65 15137c54 Giorgos Verigakis
    else:
66 15137c54 Giorgos Verigakis
        return HttpResponseNotAllowed(['GET', 'PUT'])
67 15137c54 Giorgos Verigakis
68 aed77afe Christos Stavrakakis
69 15137c54 Giorgos Verigakis
def demux_members(request, image_id, member):
70 15137c54 Giorgos Verigakis
    if request.method == 'DELETE':
71 15137c54 Giorgos Verigakis
        return views.remove_image_member(request, image_id, member)
72 15137c54 Giorgos Verigakis
    elif request.method == 'PUT':
73 15137c54 Giorgos Verigakis
        return views.add_image_member(request, image_id, member)
74 15137c54 Giorgos Verigakis
    else:
75 15137c54 Giorgos Verigakis
        return HttpResponseNotAllowed(['DELETE', 'PUT'])
76 15137c54 Giorgos Verigakis
77 15137c54 Giorgos Verigakis
78 15137c54 Giorgos Verigakis
urlpatterns = patterns('',
79 15137c54 Giorgos Verigakis
    (r'^images/$', demux),
80 15137c54 Giorgos Verigakis
    (r'^images/detail$', views.list_public_images, {'detail': True}),
81 15137c54 Giorgos Verigakis
    (r'^images/([\w-]+)$', demux_image),
82 15137c54 Giorgos Verigakis
    (r'^images/([\w-]+)/members$', demux_image_members),
83 aed77afe Christos Stavrakakis
    (r'^images/([\w-]+)/members/([\w@._-]+)$', demux_members),
84 aed77afe Christos Stavrakakis
    (r'^shared-images/$', views.list_shared_images),
85 aed77afe Christos Stavrakakis
    (r'^shared-images/detail', views.list_shared_images, {'detail': True}),
86 aed77afe Christos Stavrakakis
    (r'^shared-images/([\w@._-]+)$', views.list_shared_images_with)
87 c34de90f Giorgos Verigakis
)