cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
key.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.key
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.key import AddKeyForm
30 from wi.utils.decorators import user_permission
31 from wi.utils.views import direct_to_template, get_list_generic, form_generic, generic_multiple_id
32 
33 
34 resources_patterns = patterns('wi.views.user.key',
35 
36  url(r'^keys/$', user_permission(direct_to_template), {'template_name': 'resources/keys.html'}, name='res_keys'),
37  url(r'^key_file/$', 'res_key_file', name='res_key_file'),
38  url(r'^ajax/get_table_keys/$', user_permission(get_list_generic),
39  {'request_url': 'user/key/get_list/', },
40  name='res_ajax_get_table_keys'),
41  url(r'^ajax/generate_key/$', 'res_ajax_generate_key', name='res_ajax_generate_key'),
42  url(r'^ajax/add_key/$', user_permission(form_generic),
43  {'template_name': 'generic/form.html',
44  'success_msg': (lambda desc, data: _('You have successfully added a key') % {'desc': desc}),
45  'confirmation': _('Add'),
46  'request_url_post': 'user/key/add/',
47  'form_class': AddKeyForm},
48  name='res_ajax_add_key'),
49  url(r'^ajax/delete_key/$', user_permission(generic_multiple_id),
50  {'template_name': 'generic/simple.html',
51  'success_msg': (lambda desc, count: ungettext('You have successfully deleted key <b>%(desc)s</b>.', 'You have successfully deleted %(count)s keys <b>%(desc)s</b>.', count) % {'desc': desc, 'count': count}),
52  'ask_msg': (lambda desc, count: ungettext('Do you really want to delete key <b>%(desc)s</b>?',
53  'Do you really want to delete %(count)s keys <b>%(desc)s</b>?', count) % {'desc': desc, 'count': count}),
54  'request_url': 'user/key/delete_by_id/',
55  'id_key': 'key_ids'
56  },
57  name='res_ajax_delete_key'),
58 
59  )
60 
61 urlpatterns = patterns('',
62  url(r'^resources/', include(resources_patterns)),
63 )
64