cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
system_image.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # @COPYRIGHT_begin
3 #
4 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # @COPYRIGHT_end
19 
20 ##
21 # @package src.wi.urls.user.system_image
22 # @author Piotr W√≥jcik
23 # @date 19.11.2010
24 #
25 
26 from django.conf.urls import patterns, url, include
27 from django.utils.translation import ungettext, ugettext_lazy as _
28 
29 from wi.forms.system_image import EditImageForm, AssignGroupForm
30 from wi.utils.decorators import user_permission
31 from wi.utils.views import direct_to_template, simple_generic_id, form_generic_id, generic_multiple_id
32 
33 
34 images_patterns = patterns('wi.views.user.system_image',
35  url(r'^$', user_permission(direct_to_template), {'template_name': 'images/base.html'}, name='img_images'),
36  url(r'^images_private/$', user_permission(direct_to_template), {'template_name': 'images/images_private.html'},
37  name='img_images_private'),
38  url(r'^images_group/$', user_permission(direct_to_template), {'template_name': 'images/images_group.html'},
39  name='img_images_group'),
40  url(r'^images_public/$', user_permission(direct_to_template), {'template_name': 'images/images_public.html'},
41  name='img_images_public'),
42 
43  url(r'^ajax/delete/$', user_permission(generic_multiple_id),
44  {'template_name': 'generic/simple.html',
45  'success_msg': (lambda desc, count: ungettext('You have successfully deleted image <b>%(desc)s</b>.', 'You have successfully deleted %(count)s images <b>%(desc)s</b>.', count) % {'desc': desc, 'count': count}),
46  'ask_msg': (lambda desc, count: ungettext('Do you really want to delete image <b>%(desc)s</b>?',
47  'Do you really want to delete %(count)s images <b>%(desc)s</b>?', count) % {'desc': desc, 'count': count}),
48  'request_url': 'user/system_image/delete/',
49  'id_key': 'system_image_ids'
50  },
51  name='img_ajax_delete'),
52 
53  url(r'^ajax/get_all_table/(?P<img_type>\w+)/$', 'img_ajax_get_all_table', name='img_ajax_get_all_table'),
54  url(r'^ajax/get_private_table/$', 'img_ajax_get_private_table', name='img_ajax_get_private_table'),
55  url(r'^ajax/get_group_table/$', 'img_ajax_get_group_table', name='img_ajax_get_group_table'),
56  url(r'^ajax/get_public_table/$', 'img_ajax_get_public_table', name='img_ajax_get_public_table'),
57 
58  url(r'^ajax/assign_group/(?P<id1>\d+)/$', user_permission(form_generic_id),
59  {'template_name': 'generic/form.html',
60  'success_msg': (lambda desc, data: _('You have successfully assigned image <b>%(desc)s</b> to group.') % {'desc': desc}),
61  'ask_msg': (lambda desc: _('Enter a name of group for image <b>%(desc)s</b>.') % {'desc': desc}),
62  'confirmation': _('Assign to group'),
63  'form_class': AssignGroupForm,
64  'request_url_post': 'user/system_image/set_group/',
65  'request_url_both': {'groups': 'user/group/list_groups/'},
66  'id_key': 'system_image_id', },
67  name='img_ajax_assign_group'),
68  url(r'^ajax/revoke_group/(?P<id1>\d+)/$', user_permission(simple_generic_id),
69  {'template_name': 'generic/simple.html',
70  'success_msg': (lambda desc: _('You have successfully revoked group\'s assigment.') % {'desc': desc}),
71  'ask_msg': (lambda desc: _('Do you want to make image <b>%(desc)s</b> private?') % {'desc': desc}),
72  'request_url': 'user/system_image/set_private/',
73  'id_key': 'system_image_id', },
74  name='img_ajax_revoke_group'),
75 
76  url(r'^ajax/add_image_http/$', 'img_ajax_add_image_http', name='img_ajax_add_image_http'),
77  url(r'^ajax/edit_image/(?P<id1>\d+)/$', user_permission(form_generic_id),
78  {'template_name': 'generic/form.html',
79  'success_msg': (lambda desc, data: _('You have successfully edited this image.') % {'desc': desc}),
80  'ask_msg': (lambda desc: _('Edit image data:') % {'desc': desc}),
81  'confirmation': _('Save'),
82  'request_url_get': 'user/system_image/get_by_id/',
83  'request_url_post': 'user/system_image/edit/',
84  'request_url_both': {'disk_controllers': 'user/system_image/get_disk_controllers/',
85  'video_devices': 'user/system_image/get_video_devices/',
86  'network_devices': 'user/system_image/get_network_devices/', },
87  'id_key': 'system_image_id',
88  'form_class': EditImageForm,
89  },
90  name='img_ajax_edit_image'),
91 
92  url(r'^ajax/change_to_storage/(?P<id1>\d+)/$', user_permission(simple_generic_id),
93  {'template_name': 'generic/simple.html',
94  'success_msg': (lambda desc: _('You have successfully changed image <b>%(desc)s</b> to a storage disk.') % {'desc': desc}),
95  'ask_msg': (lambda desc: _('Do you want to change image <b>%(desc)s</b> to a storage disk?') % {'desc': desc}),
96  'request_url': 'user/system_image/convert_to_storage_image/',
97  'id_key': 'system_image_id', },
98  name='img_ajax_change_to_storage'),
99 
100 )
101 
102 
103 urlpatterns = patterns('',
104  url(r'^images/', include(images_patterns)),
105 )
106