cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
template.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.admin_cm.template
22 #
23 # @author Krzysztof Danielowski, Piotr Wojcik
24 # @date 17.03.2011
25 #
26 
27 from django.conf.urls import url, patterns, include
28 from django.utils.translation import ugettext_lazy as _
29 
30 from wi.forms.template import TemplateForm
31 from wi.utils.decorators import admin_cm_permission
32 from wi.utils.views import form_generic_id, direct_to_template, simple_generic_id, form_generic
33 
34 
35 template_patterns = patterns('wi.views.admin_cm.template',
36  url(r'^templates/$', admin_cm_permission(direct_to_template), {'template_name': 'admin_cm/templates.html'}, name='cma_templates'),
37  url(r'^ajax/get_table_templates/$', 'cma_ajax_get_table_templates', name='cma_ajax_get_table_templates'),
38  url(r'^ajax/delete_template/(?P<id1>\d+)/$', admin_cm_permission(simple_generic_id),
39  {'template_name': 'generic/simple.html',
40  'success_msg': (lambda desc: _('You have successfully deleted template <b>%(desc)s</b>.') % {'desc': desc}),
41  'ask_msg': (lambda desc: _('Do you want to delete template <b>%(desc)s</b>?') % {'desc': desc}),
42  'request_url': 'admin_cm/template/delete/',
43  'id_key': 'template_id', },
44  name='cma_ajax_delete_template'),
45  url(r'^ajax/add_template/$', admin_cm_permission(form_generic),
46  {'template_name': 'generic/form.html',
47  'success_msg': (lambda desc, data: _('You have successfully created a template.') % {'desc': desc}),
48  'confirmation': _('Create'),
49  'request_url_post': 'admin_cm/template/add/',
50  'form_class': TemplateForm},
51  name='cma_ajax_add_template'),
52  url(r'^ajax/edit_template/(?P<id1>\d+)/$', admin_cm_permission(form_generic_id),
53  {'template_name': 'generic/form.html',
54  'success_msg': (lambda desc, data: _('You have successfully edited selected template.') % {'desc': desc}),
55  'confirmation': _('Save'),
56  'request_url_post': 'admin_cm/template/edit/',
57  'request_url_get': 'admin_cm/template/get_by_id/',
58  'id_key': 'template_id',
59  'form_class': TemplateForm},
60  name='cma_ajax_edit_template'),
61 )
62 
63 urlpatterns = patterns('',
64  url(r'^admin_cm/', include(template_patterns)),
65 )
66