cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
storage_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.storage_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.storage_image import ConvertImageForm, EditDiskForm
30 from wi.utils.decorators import user_permission
31 from wi.utils.views import direct_to_template, form_generic_id, generic_multiple_id
32 
33 
34 resources_patterns = patterns('wi.views.user.storage_image',
35 
36  url(r'^disks/$', user_permission(direct_to_template), {'template_name': 'resources/disks.html'}, name='res_disks'),
37  url(r'^ajax/disk_table/$', 'res_ajax_get_disk_table', name='res_ajax_get_disk_table'),
38  url(r'^ajax/upload_disk_http/$', 'res_ajax_upload_disk_http', name='res_ajax_upload_disk_http'),
39  url(r'^ajax/add_disk/$', 'res_ajax_add_disk', name='res_ajax_add_disk'),
40  url(r'^ajax/edit_disk/(?P<id1>\d+)/$', user_permission(form_generic_id),
41  {'template_name': 'generic/form.html',
42  'success_msg': (lambda desc, data: _('You have successfully edited selected disk.') % {'desc': desc}),
43  'ask_msg': (lambda desc: _('Edit disk data:') % {'desc': desc}),
44  'confirmation': _('Save'),
45  'request_url_post': 'user/storage_image/edit/',
46  'request_url_get': 'user/storage_image/get_by_id/',
47  'request_url_both': {'disk_controllers': 'user/storage_image/get_disk_controllers/'},
48  'id_key': 'storage_image_id',
49  'form_class': EditDiskForm},
50  name='res_ajax_edit_disk'),
51  url(r'^ajax/delete_disk/$', user_permission(generic_multiple_id),
52  {'template_name': 'generic/simple.html',
53  'success_msg': (lambda desc, count: ungettext('You have successfully deleted disk volume <b>%(desc)s</b>.', 'You have successfully deleted %(count)s disk volumes <b>%(desc)s</b>.', count) % {'desc': desc, 'count': count}),
54  'ask_msg': (lambda desc, count: ungettext('Do you really want to delete disk volume <b>%(desc)s</b>?',
55  'Do you really want to delete %(count)s disk volumes <b>%(desc)s</b>?', count) % {'desc': desc, 'count': count}),
56  'request_url': 'user/storage_image/delete/',
57  'id_key': 'storage_image_ids'
58  },
59  name='res_ajax_delete_disk'),
60 
61  url(r'^ajax/change_to_image/(?P<id1>\d+)/$', user_permission(form_generic_id),
62  {'template_name': 'generic/form.html',
63  'success_msg': (lambda desc, data: _('You have successfully changed disk <b>%(desc)s</b> to a VM image.') % {'desc': desc}),
64  'ask_msg': (lambda desc: _('Do you want to change disk <b>%(desc)s</b> to a VM image?') % {'desc': desc}),
65  'request_url_post': 'user/storage_image/convert_to_system_image/',
66  'request_url_both': {'disk_controllers': 'user/system_image/get_disk_controllers/',
67  'video_devices': 'user/system_image/get_video_devices/',
68  'network_devices': 'user/system_image/get_network_devices/', },
69  'confirmation': _('Change'),
70  'id_key': 'storage_image_id',
71  'form_class': ConvertImageForm, },
72  name='img_ajax_change_to_image'),
73  )
74 
75 urlpatterns = patterns('',
76  url(r'^resources/', include(resources_patterns)),
77 )
78