cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
group.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.group
22 #
23 # @author Piotr W√≥jcik
24 #
25 
26 from django.conf.urls import patterns, url, include
27 from django.utils.translation import ugettext_lazy as _
28 
29 from wi.forms.group import GroupForm
30 from wi.utils.decorators import user_permission
31 from wi.utils.views import direct_to_template, simple_generic_twoid, \
32  simple_generic_id, form_generic, form_generic_id
33 
34 
35 group_patterns = patterns('wi.views.user.group',
36  url(r'^$', user_permission(direct_to_template), {'template_name': 'groups/base.html'}, name='grp_groups'),
37  url(r'^list_groups/$', user_permission(direct_to_template), {'template_name': 'groups/show_groups.html'}, name='grp_list'),
38  url(r'^my_groups/$', user_permission(direct_to_template), {'template_name': 'groups/my_groups.html'}, name='grp_my_groups'),
39  url(r'^details/(?P<group_id>\d+)/$', 'grp_details', name='grp_details'),
40 
41  url(r'^ajax/get_table_my/$', 'grp_ajax_get_table_my', name='grp_ajax_get_table_my'),
42  url(r'^ajax/grp_details_table/(?P<group_id>\d+)/$', 'grp_ajax_grp_details_table', name='grp_ajax_grp_details_table'),
43 
44  url(r'^ajax/grp_delete_user_my/(?P<id1>\d+)/(?P<id2>\d+)/$', user_permission(simple_generic_twoid),
45  {'template_name': 'generic/simple.html',
46  'success_msg': (lambda desc: _('You have successfully removed user <b>%(desc)s</b> from this group.') % {'desc': desc}),
47  'ask_msg': (lambda desc: _('Do you want to remove user <b>%(desc)s</b> from this group?') % {'desc': desc}),
48  'confirmation': _('Remove'),
49  'request_url': 'user/group/delete_user/',
50  'id_key2': 'user_id',
51  'id_key': 'group_id', },
52  name='grp_ajax_delete_user_my_group'),
53  url(r'^ajax/grp_add_user_my/(?P<id1>\d+)/(?P<id2>\d+)/$', user_permission(simple_generic_twoid),
54  {'template_name': 'generic/simple.html',
55  'success_msg': (lambda desc: _('You have successfully added user <b>%(desc)s</b> to this group.') % {'desc': desc}),
56  'ask_msg': (lambda desc: _('Do you want to add user <b>%(desc)s</b> to this group?') % {'desc': desc}),
57  'confirmation': _('Add'),
58  'request_url': 'user/group/activate_user/',
59  'id_key2': 'user_id',
60  'id_key': 'group_id', },
61  name='grp_ajax_add_user_my_group'),
62 
63  url(r'^ajax/grp_change_user_my/(?P<id1>\d+)/(?P<id2>\d+)/$', user_permission(simple_generic_twoid),
64  {'template_name': 'generic/simple.html',
65  'success_msg': (lambda desc: _('You have successfully changed group leader to user <b>%(desc)s</b>.') % {'desc': desc}),
66  'ask_msg': (lambda desc: _('Do you want to change group leader to user <b>%(desc)s</b>?') % {'desc': desc}),
67  'request_url': 'user/group/change_owner/',
68  'id_key2': 'user_id',
69  'id_key': 'group_id', },
70  name='grp_ajax_change_user_my_group'),
71 
72  url(r'^ajax/send_request/(?P<group_id>\d+)/$', 'grp_ajax_send_request', name='grp_ajax_send_request'),
73  url(r'^ajax/cancel_request/(?P<id1>\d+)/(?P<id2>\d+)/$', user_permission(simple_generic_twoid),
74  {'template_name': 'generic/simple.html',
75  'success_msg': (lambda desc: _('You have successfully canceled request from user <b>%(desc)s</b>.') % {'desc': desc}),
76  'ask_msg': (lambda desc: _('Do you want to cancel request from user <b>%(desc)s</b>?') % {'desc': desc}),
77  'request_url': 'user/group/delete_user/',
78  'id_key2': 'user_id',
79  'id_key': 'group_id', },
80  name='grp_ajax_cancelrequest'),
81 
82  url(r'^ajax/get_table_all/$', 'grp_ajax_get_table_all', name='grp_ajax_get_table_all'),
83 
84  url(r'^ajax/delete_my_group/(?P<id1>\d+)/$', user_permission(simple_generic_id),
85  {'template_name': 'generic/simple.html',
86  'success_msg': (lambda desc: _('You have successfully deleted this group.') % {'desc': desc}),
87  'ask_msg': (lambda desc: _('Do you want to delete this group? <br/><b>Note!</b> All images from this group will be set private to their owners.')),
88  'request_url': 'user/group/delete/',
89  'id_key': 'group_id', },
90  name='grp_ajax_delete_my_group'),
91  url(r'^ajax/edit_my_group/(?P<id1>\d+)/$', user_permission(form_generic_id),
92  {'template_name': 'generic/form.html',
93  'success_msg': (lambda desc, data: _('You have successfully edited selected group.') % {'desc': desc}),
94  'confirmation': _('Save'),
95  'request_url_post': 'user/group/edit/',
96  'request_url_get': 'user/group/get_by_id/',
97  'form_class': GroupForm,
98  'id_key': 'group_id', },
99  name='grp_ajax_edit_my_group'),
100 
101  url(r'^ajax/add_group/$', user_permission(form_generic),
102  {'template_name': 'generic/form.html',
103  'success_msg': (lambda desc, data: _('You have successfully created a group.') % {'desc': desc}),
104  'confirmation': _('Create'),
105  'request_url_post': 'user/group/create/',
106  'form_class': GroupForm},
107  name='grp_ajax_add_group'),
108 )
109 
110 urlpatterns = patterns('',
111  url(r'^groups/', include(group_patterns)),
112 )
113