cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
farm.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.farm
22 #
23 # @author Piotr Wójcik
24 # @date 14.11.2011
25 #
26 
27 from django.conf.urls import patterns, url, include
28 from django.utils.translation import ugettext_lazy as _
29 
30 from wi.forms.farm import CreateFarmForm1, CreateFarmForm2, CreateFarmForm3, CreateFarmForm4
31 from wi.forms.vm import EditVMForm
32 from wi.utils.decorators import user_permission
33 from wi.utils.views import direct_to_template, simple_generic_id, form_generic_id
34 from wi.views.user.farm import CreateFarmWizard
35 
36 
37 farm_patterns = patterns('wi.views.user.farm',
38  url(r'^$', user_permission(direct_to_template), {'template_name': 'farms/base.html'}, name='far_farms'),
39 
40  url(r'^potato/$', user_permission(direct_to_template), {'template_name': 'farms/potato.html'}, name='far_potato'),
41 
42  url(r'^create_farm/$', CreateFarmWizard.as_view([CreateFarmForm1, CreateFarmForm2, CreateFarmForm3, CreateFarmForm4]),
43  name='far_create_farm'),
44  url(r'^show_farm/$', user_permission(direct_to_template), {'template_name': 'farms/show_farm.html'}, name='far_show_farm'),
45 
46  url(r'^ajax/get_table/$', 'far_ajax_get_table', name='far_ajax_get_table'),
47  url(r'^ajax/destroy_farm/(?P<id1>\d+)/$', user_permission(simple_generic_id),
48  {'template_name': 'generic/simple.html',
49  'success_msg': (lambda desc: _('You have successfully destroyed farm <b>%(desc)s</b>.') % {'desc': desc}),
50  'ask_msg': (lambda desc: _('Do you really want to destroy farm <b>%(desc)s</b>?') % {'desc': desc}),
51  'request_url': 'user/farm/destroy/',
52  'id_key': 'farm_id',
53  },
54  name='far_ajax_destroy_farm'),
55  url(r'^ajax/save_and_shutdown_farm/(?P<id1>\d+)/$', user_permission(form_generic_id),
56  {'template_name': 'generic/form.html',
57  'success_msg': (lambda desc, data: _('Farm head will be saved.') % {'desc': desc}),
58  'ask_msg': (lambda desc: _('The farm will be closed. Enter a name to save head of this farm.') % {'desc': desc}),
59  'confirmation': _('Save and shutdown'),
60  'request_url_post': 'user/farm/save_and_shutdown/',
61  'request_url_get': 'user/farm/get_by_id/',
62  'form_class': EditVMForm,
63  'id_key': 'farm_id', },
64  name='far_ajax_save_and_shutdown'),
65 )
66 
67 
68 urlpatterns = patterns('',
69  url(r'^farm/', include(farm_patterns)),
70 )
71