##// END OF EJS Templates
PEP8ify - controllers
marcink -
r1245:5f2fbab7 beta
parent child Browse files
Show More
@@ -35,6 +35,7 b' from rhodecode.model.db import UserLog'
35
35
36 log = logging.getLogger(__name__)
36 log = logging.getLogger(__name__)
37
37
38
38 class AdminController(BaseController):
39 class AdminController(BaseController):
39
40
40 @LoginRequired()
41 @LoginRequired()
@@ -43,20 +43,19 b' from sqlalchemy.exc import DatabaseError'
43 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
44
44
45
45
46
47 class LdapSettingsController(BaseController):
46 class LdapSettingsController(BaseController):
48
47
49 search_scope_choices = [('BASE', _('BASE'),),
48 search_scope_choices = [('BASE', _('BASE'),),
50 ('ONELEVEL', _('ONELEVEL'),),
49 ('ONELEVEL', _('ONELEVEL'),),
51 ('SUBTREE', _('SUBTREE'),),
50 ('SUBTREE', _('SUBTREE'),),
52 ]
51 ]
53 search_scope_default = 'SUBTREE'
52 search_scope_default = 'SUBTREE'
54
53
55 tls_reqcert_choices = [('NEVER', _('NEVER'),),
54 tls_reqcert_choices = [('NEVER', _('NEVER'),),
56 ('ALLOW', _('ALLOW'),),
55 ('ALLOW', _('ALLOW'),),
57 ('TRY', _('TRY'),),
56 ('TRY', _('TRY'),),
58 ('DEMAND', _('DEMAND'),),
57 ('DEMAND', _('DEMAND'),),
59 ('HARD', _('HARD'),),
58 ('HARD', _('HARD'),),
60 ]
59 ]
61 tls_reqcert_default = 'DEMAND'
60 tls_reqcert_default = 'DEMAND'
62
61
@@ -66,13 +65,13 b' class LdapSettingsController(BaseControl'
66 c.admin_user = session.get('admin_user')
65 c.admin_user = session.get('admin_user')
67 c.admin_username = session.get('admin_username')
66 c.admin_username = session.get('admin_username')
68 c.search_scope_choices = self.search_scope_choices
67 c.search_scope_choices = self.search_scope_choices
69 c.tls_reqcert_choices = self.tls_reqcert_choices
68 c.tls_reqcert_choices = self.tls_reqcert_choices
70 super(LdapSettingsController, self).__before__()
69 super(LdapSettingsController, self).__before__()
71
70
72 def index(self):
71 def index(self):
73 defaults = SettingsModel().get_ldap_settings()
72 defaults = SettingsModel().get_ldap_settings()
74 c.search_scope_cur = defaults.get('ldap_search_scope')
73 c.search_scope_cur = defaults.get('ldap_search_scope')
75 c.tls_reqcert_cur = defaults.get('ldap_tls_reqcert')
74 c.tls_reqcert_cur = defaults.get('ldap_tls_reqcert')
76
75
77 return htmlfill.render(
76 return htmlfill.render(
78 render('admin/ldap/ldap.html'),
77 render('admin/ldap/ldap.html'),
@@ -109,7 +108,7 b' class LdapSettingsController(BaseControl'
109 except formencode.Invalid, errors:
108 except formencode.Invalid, errors:
110
109
111 c.search_scope_cur = self.search_scope_default
110 c.search_scope_cur = self.search_scope_default
112 c.tls_reqcert_cur = self.search_scope_default
111 c.tls_reqcert_cur = self.search_scope_default
113
112
114 return htmlfill.render(
113 return htmlfill.render(
115 render('admin/ldap/ldap.html'),
114 render('admin/ldap/ldap.html'),
@@ -41,6 +41,7 b' import traceback'
41
41
42 log = logging.getLogger(__name__)
42 log = logging.getLogger(__name__)
43
43
44
44 class PermissionsController(BaseController):
45 class PermissionsController(BaseController):
45 """REST Controller styled on the Atom Publishing Protocol"""
46 """REST Controller styled on the Atom Publishing Protocol"""
46 # To properly map this controller, ensure your config/routing.py
47 # To properly map this controller, ensure your config/routing.py
@@ -69,7 +70,6 b' class PermissionsController(BaseControll'
69 self.create_choices = [('hg.create.none', _('Disabled')),
70 self.create_choices = [('hg.create.none', _('Disabled')),
70 ('hg.create.repository', _('Enabled'))]
71 ('hg.create.repository', _('Enabled'))]
71
72
72
73 def index(self, format='html'):
73 def index(self, format='html'):
74 """GET /permissions: All items in the collection"""
74 """GET /permissions: All items in the collection"""
75 # url('permissions')
75 # url('permissions')
@@ -99,7 +99,7 b' class PermissionsController(BaseControll'
99
99
100 try:
100 try:
101 form_result = _form.to_python(dict(request.POST))
101 form_result = _form.to_python(dict(request.POST))
102 form_result.update({'perm_user_name':id})
102 form_result.update({'perm_user_name': id})
103 permission_model.update(form_result)
103 permission_model.update(form_result)
104 h.flash(_('Default permissions updated successfully'),
104 h.flash(_('Default permissions updated successfully'),
105 category='success')
105 category='success')
@@ -123,8 +123,6 b' class PermissionsController(BaseControll'
123
123
124 return redirect(url('edit_permission', id=id))
124 return redirect(url('edit_permission', id=id))
125
125
126
127
128 def delete(self, id):
126 def delete(self, id):
129 """DELETE /permissions/id: Delete an existing item"""
127 """DELETE /permissions/id: Delete an existing item"""
130 # Forms posted to this method should contain a hidden field:
128 # Forms posted to this method should contain a hidden field:
@@ -147,8 +145,8 b' class PermissionsController(BaseControll'
147
145
148 if id == 'default':
146 if id == 'default':
149 default_user = UserModel().get_by_username('default')
147 default_user = UserModel().get_by_username('default')
150 defaults = {'_method':'put',
148 defaults = {'_method': 'put',
151 'anonymous':default_user.active}
149 'anonymous': default_user.active}
152
150
153 for p in default_user.user_perms:
151 for p in default_user.user_perms:
154 if p.permission.permission_name.startswith('repository.'):
152 if p.permission.permission_name.startswith('repository.'):
@@ -47,6 +47,7 b' from rhodecode.model.repo import RepoMod'
47
47
48 log = logging.getLogger(__name__)
48 log = logging.getLogger(__name__)
49
49
50
50 class ReposController(BaseController):
51 class ReposController(BaseController):
51 """
52 """
52 REST Controller styled on the Atom Publishing Protocol"""
53 REST Controller styled on the Atom Publishing Protocol"""
@@ -65,8 +66,8 b' class ReposController(BaseController):'
65 repo_model = RepoModel()
66 repo_model = RepoModel()
66
67
67 c.repo_groups = [('', '')]
68 c.repo_groups = [('', '')]
68 parents_link = lambda k:h.literal('»'.join(
69 parents_link = lambda k: h.literal('»'.join(
69 map(lambda k:k.group_name,
70 map(lambda k: k.group_name,
70 k.parents + [k])
71 k.parents + [k])
71 )
72 )
72 )
73 )
@@ -90,7 +91,6 b' class ReposController(BaseController):'
90 repo_model = RepoModel()
91 repo_model = RepoModel()
91 c.repo_info = repo_model.get_by_repo_name(repo_name)
92 c.repo_info = repo_model.get_by_repo_name(repo_name)
92
93
93
94 if c.repo_info is None:
94 if c.repo_info is None:
95 h.flash(_('%s repository is not mapped to db perhaps'
95 h.flash(_('%s repository is not mapped to db perhaps'
96 ' it was created or renamed from the filesystem'
96 ' it was created or renamed from the filesystem'
@@ -100,7 +100,6 b' class ReposController(BaseController):'
100
100
101 return redirect(url('repos'))
101 return redirect(url('repos'))
102
102
103
104 c.default_user_id = User.by_username('default').user_id
103 c.default_user_id = User.by_username('default').user_id
105 c.in_public_journal = self.sa.query(UserFollowing)\
104 c.in_public_journal = self.sa.query(UserFollowing)\
106 .filter(UserFollowing.user_id == c.default_user_id)\
105 .filter(UserFollowing.user_id == c.default_user_id)\
@@ -120,8 +119,6 b' class ReposController(BaseController):'
120 c.stats_percentage = '%.2f' % ((float((last_rev)) /
119 c.stats_percentage = '%.2f' % ((float((last_rev)) /
121 c.repo_last_rev) * 100)
120 c.repo_last_rev) * 100)
122
121
123
124
125 defaults = c.repo_info.get_dict()
122 defaults = c.repo_info.get_dict()
126 group, repo_name = c.repo_info.groups_and_repo
123 group, repo_name = c.repo_info.groups_and_repo
127 defaults['repo_name'] = repo_name
124 defaults['repo_name'] = repo_name
@@ -130,12 +127,11 b' class ReposController(BaseController):'
130
127
131 #fill owner
128 #fill owner
132 if c.repo_info.user:
129 if c.repo_info.user:
133 defaults.update({'user':c.repo_info.user.username})
130 defaults.update({'user': c.repo_info.user.username})
134 else:
131 else:
135 replacement_user = self.sa.query(User)\
132 replacement_user = self.sa.query(User)\
136 .filter(User.admin == True).first().username
133 .filter(User.admin == True).first().username
137 defaults.update({'user':replacement_user})
134 defaults.update({'user': replacement_user})
138
139
135
140 #fill repository users
136 #fill repository users
141 for p in c.repo_info.repo_to_perm:
137 for p in c.repo_info.repo_to_perm:
@@ -147,10 +143,8 b' class ReposController(BaseController):'
147 defaults.update({'g_perm_%s' % p.users_group.users_group_name:
143 defaults.update({'g_perm_%s' % p.users_group.users_group_name:
148 p.permission.permission_name})
144 p.permission.permission_name})
149
145
150
151 return defaults
146 return defaults
152
147
153
154 @HasPermissionAllDecorator('hg.admin')
148 @HasPermissionAllDecorator('hg.admin')
155 def index(self, format='html'):
149 def index(self, format='html'):
156 """GET /repos: All items in the collection"""
150 """GET /repos: All items in the collection"""
@@ -232,7 +226,7 b' class ReposController(BaseController):'
232 self.__load_defaults()
226 self.__load_defaults()
233 repo_model = RepoModel()
227 repo_model = RepoModel()
234 changed_name = repo_name
228 changed_name = repo_name
235 _form = RepoForm(edit=True, old_data={'repo_name':repo_name},
229 _form = RepoForm(edit=True, old_data={'repo_name': repo_name},
236 repo_groups=c.repo_groups_choices)()
230 repo_groups=c.repo_groups_choices)()
237 try:
231 try:
238 form_result = _form.to_python(dict(request.POST))
232 form_result = _form.to_python(dict(request.POST))
@@ -9,6 +9,7 b' from rhodecode.model.db import Group'
9
9
10 log = logging.getLogger(__name__)
10 log = logging.getLogger(__name__)
11
11
12
12 class ReposGroupsController(BaseController):
13 class ReposGroupsController(BaseController):
13 """REST Controller styled on the Atom Publishing Protocol"""
14 """REST Controller styled on the Atom Publishing Protocol"""
14 # To properly map this controller, ensure your config/routing.py
15 # To properly map this controller, ensure your config/routing.py
@@ -68,7 +69,6 b' class ReposGroupsController(BaseControll'
68
69
69 sort_key = current_sort_slug + '_sort'
70 sort_key = current_sort_slug + '_sort'
70
71
71
72 #overwrite our cached list with current filter
72 #overwrite our cached list with current filter
73 gr_filter = [r.repo_name for r in c.group_repos]
73 gr_filter = [r.repo_name for r in c.group_repos]
74 c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter)
74 c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter)
@@ -82,10 +82,8 b' class ReposGroupsController(BaseControll'
82
82
83 c.repo_cnt = len(c.repos_list)
83 c.repo_cnt = len(c.repos_list)
84
84
85
86 return render('admin/repos_groups/repos_groups.html')
85 return render('admin/repos_groups/repos_groups.html')
87
86
88
89 def edit(self, id, format='html'):
87 def edit(self, id, format='html'):
90 """GET /repos_groups/id/edit: Form to edit an existing item"""
88 """GET /repos_groups/id/edit: Form to edit an existing item"""
91 # url('edit_repos_group', id=ID)
89 # url('edit_repos_group', id=ID)
@@ -57,14 +57,12 b' class SettingsController(BaseController)'
57 # map.resource('setting', 'settings', controller='admin/settings',
57 # map.resource('setting', 'settings', controller='admin/settings',
58 # path_prefix='/admin', name_prefix='admin_')
58 # path_prefix='/admin', name_prefix='admin_')
59
59
60
61 @LoginRequired()
60 @LoginRequired()
62 def __before__(self):
61 def __before__(self):
63 c.admin_user = session.get('admin_user')
62 c.admin_user = session.get('admin_user')
64 c.admin_username = session.get('admin_username')
63 c.admin_username = session.get('admin_username')
65 super(SettingsController, self).__before__()
64 super(SettingsController, self).__before__()
66
65
67
68 @HasPermissionAllDecorator('hg.admin')
66 @HasPermissionAllDecorator('hg.admin')
69 def index(self, format='html'):
67 def index(self, format='html'):
70 """GET /admin/settings: All items in the collection"""
68 """GET /admin/settings: All items in the collection"""
@@ -109,8 +107,8 b' class SettingsController(BaseController)'
109 added, removed = repo2db_mapper(initial, rm_obsolete)
107 added, removed = repo2db_mapper(initial, rm_obsolete)
110
108
111 h.flash(_('Repositories successfully'
109 h.flash(_('Repositories successfully'
112 ' rescanned added: %s,removed: %s') % (added, removed)
110 ' rescanned added: %s,removed: %s') % (added, removed),
113 , category='success')
111 category='success')
114
112
115 if setting_id == 'whoosh':
113 if setting_id == 'whoosh':
116 repo_location = self.get_hg_ui_settings()['paths_root_path']
114 repo_location = self.get_hg_ui_settings()['paths_root_path']
@@ -127,15 +125,16 b' class SettingsController(BaseController)'
127
125
128 try:
126 try:
129 hgsettings1 = settings_model.get('title')
127 hgsettings1 = settings_model.get('title')
130 hgsettings1.app_settings_value = form_result['rhodecode_title']
128 hgsettings1.app_settings_value = \
129 form_result['rhodecode_title']
131
130
132 hgsettings2 = settings_model.get('realm')
131 hgsettings2 = settings_model.get('realm')
133 hgsettings2.app_settings_value = form_result['rhodecode_realm']
132 hgsettings2.app_settings_value = \
133 form_result['rhodecode_realm']
134
134
135 hgsettings3 = settings_model.get('ga_code')
135 hgsettings3 = settings_model.get('ga_code')
136 hgsettings3.app_settings_value = form_result['rhodecode_ga_code']
136 hgsettings3.app_settings_value = \
137
137 form_result['rhodecode_ga_code']
138
139
138
140 self.sa.add(hgsettings1)
139 self.sa.add(hgsettings1)
141 self.sa.add(hgsettings2)
140 self.sa.add(hgsettings2)
@@ -147,12 +146,12 b' class SettingsController(BaseController)'
147
146
148 except Exception:
147 except Exception:
149 log.error(traceback.format_exc())
148 log.error(traceback.format_exc())
150 h.flash(_('error occurred during updating application settings'),
149 h.flash(_('error occurred during updating '
150 'application settings'),
151 category='error')
151 category='error')
152
152
153 self.sa.rollback()
153 self.sa.rollback()
154
154
155
156 except formencode.Invalid, errors:
155 except formencode.Invalid, errors:
157 return htmlfill.render(
156 return htmlfill.render(
158 render('admin/settings/settings.html'),
157 render('admin/settings/settings.html'),
@@ -176,24 +175,30 b' class SettingsController(BaseController)'
176 .filter(RhodeCodeUi.ui_key == '/').one()
175 .filter(RhodeCodeUi.ui_key == '/').one()
177 hgsettings2.ui_value = form_result['paths_root_path']
176 hgsettings2.ui_value = form_result['paths_root_path']
178
177
179
180 #HOOKS
178 #HOOKS
181 hgsettings3 = self.sa.query(RhodeCodeUi)\
179 hgsettings3 = self.sa.query(RhodeCodeUi)\
182 .filter(RhodeCodeUi.ui_key == 'changegroup.update').one()
180 .filter(RhodeCodeUi.ui_key == 'changegroup.update').one()
183 hgsettings3.ui_active = bool(form_result['hooks_changegroup_update'])
181 hgsettings3.ui_active = \
182 bool(form_result['hooks_changegroup_update'])
184
183
185 hgsettings4 = self.sa.query(RhodeCodeUi)\
184 hgsettings4 = self.sa.query(RhodeCodeUi)\
186 .filter(RhodeCodeUi.ui_key == 'changegroup.repo_size').one()
185 .filter(RhodeCodeUi.ui_key ==
187 hgsettings4.ui_active = bool(form_result['hooks_changegroup_repo_size'])
186 'changegroup.repo_size').one()
187 hgsettings4.ui_active = \
188 bool(form_result['hooks_changegroup_repo_size'])
188
189
189 hgsettings5 = self.sa.query(RhodeCodeUi)\
190 hgsettings5 = self.sa.query(RhodeCodeUi)\
190 .filter(RhodeCodeUi.ui_key == 'pretxnchangegroup.push_logger').one()
191 .filter(RhodeCodeUi.ui_key ==
191 hgsettings5.ui_active = bool(form_result['hooks_pretxnchangegroup_push_logger'])
192 'pretxnchangegroup.push_logger').one()
193 hgsettings5.ui_active = \
194 bool(form_result['hooks_pretxnchangegroup'
195 '_push_logger'])
192
196
193 hgsettings6 = self.sa.query(RhodeCodeUi)\
197 hgsettings6 = self.sa.query(RhodeCodeUi)\
194 .filter(RhodeCodeUi.ui_key == 'preoutgoing.pull_logger').one()
198 .filter(RhodeCodeUi.ui_key ==
195 hgsettings6.ui_active = bool(form_result['hooks_preoutgoing_pull_logger'])
199 'preoutgoing.pull_logger').one()
196
200 hgsettings6.ui_active = \
201 bool(form_result['hooks_preoutgoing_pull_logger'])
197
202
198 self.sa.add(hgsettings1)
203 self.sa.add(hgsettings1)
199 self.sa.add(hgsettings2)
204 self.sa.add(hgsettings2)
@@ -208,12 +213,11 b' class SettingsController(BaseController)'
208
213
209 except:
214 except:
210 log.error(traceback.format_exc())
215 log.error(traceback.format_exc())
211 h.flash(_('error occurred during updating application settings'),
216 h.flash(_('error occurred during updating '
212 category='error')
217 'application settings'), category='error')
213
218
214 self.sa.rollback()
219 self.sa.rollback()
215
220
216
217 except formencode.Invalid, errors:
221 except formencode.Invalid, errors:
218 return htmlfill.render(
222 return htmlfill.render(
219 render('admin/settings/settings.html'),
223 render('admin/settings/settings.html'),
@@ -222,8 +226,6 b' class SettingsController(BaseController)'
222 prefix_error=False,
226 prefix_error=False,
223 encoding="UTF-8")
227 encoding="UTF-8")
224
228
225
226
227 return redirect(url('admin_settings'))
229 return redirect(url('admin_settings'))
228
230
229 @HasPermissionAllDecorator('hg.admin')
231 @HasPermissionAllDecorator('hg.admin')
@@ -238,12 +240,15 b' class SettingsController(BaseController)'
238
240
239 @HasPermissionAllDecorator('hg.admin')
241 @HasPermissionAllDecorator('hg.admin')
240 def show(self, setting_id, format='html'):
242 def show(self, setting_id, format='html'):
241 """GET /admin/settings/setting_id: Show a specific item"""
243 """
244 GET /admin/settings/setting_id: Show a specific item"""
242 # url('admin_setting', setting_id=ID)
245 # url('admin_setting', setting_id=ID)
243
246
244 @HasPermissionAllDecorator('hg.admin')
247 @HasPermissionAllDecorator('hg.admin')
245 def edit(self, setting_id, format='html'):
248 def edit(self, setting_id, format='html'):
246 """GET /admin/settings/setting_id/edit: Form to edit an existing item"""
249 """
250 GET /admin/settings/setting_id/edit: Form to
251 edit an existing item"""
247 # url('admin_edit_setting', setting_id=ID)
252 # url('admin_edit_setting', setting_id=ID)
248
253
249 @NotAnonymous()
254 @NotAnonymous()
@@ -282,8 +287,9 b' class SettingsController(BaseController)'
282 # url('admin_settings_my_account_update', id=ID)
287 # url('admin_settings_my_account_update', id=ID)
283 user_model = UserModel()
288 user_model = UserModel()
284 uid = self.rhodecode_user.user_id
289 uid = self.rhodecode_user.user_id
285 _form = UserForm(edit=True, old_data={'user_id':uid,
290 _form = UserForm(edit=True,
286 'email':self.rhodecode_user.email})()
291 old_data={'user_id': uid,
292 'email': self.rhodecode_user.email})()
287 form_result = {}
293 form_result = {}
288 try:
294 try:
289 form_result = _form.to_python(dict(request.POST))
295 form_result = _form.to_python(dict(request.POST))
@@ -319,8 +325,8 b' class SettingsController(BaseController)'
319 """GET /_admin/create_repository: Form to create a new item"""
325 """GET /_admin/create_repository: Form to create a new item"""
320
326
321 c.repo_groups = [('', '')]
327 c.repo_groups = [('', '')]
322 parents_link = lambda k:h.literal('»'.join(
328 parents_link = lambda k: h.literal('»'.join(
323 map(lambda k:k.group_name,
329 map(lambda k: k.group_name,
324 k.parents + [k])
330 k.parents + [k])
325 )
331 )
326 )
332 )
@@ -32,7 +32,8 b' from pylons import request, session, tmp'
32 from pylons.controllers.util import abort, redirect
32 from pylons.controllers.util import abort, redirect
33 from pylons.i18n.translation import _
33 from pylons.i18n.translation import _
34
34
35 from rhodecode.lib.exceptions import DefaultUserException, UserOwnsReposException
35 from rhodecode.lib.exceptions import DefaultUserException, \
36 UserOwnsReposException
36 from rhodecode.lib import helpers as h
37 from rhodecode.lib import helpers as h
37 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
38 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
38 from rhodecode.lib.base import BaseController, render
39 from rhodecode.lib.base import BaseController, render
@@ -43,6 +44,7 b' from rhodecode.model.user import UserMod'
43
44
44 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
45
46
47
46 class UsersController(BaseController):
48 class UsersController(BaseController):
47 """REST Controller styled on the Atom Publishing Protocol"""
49 """REST Controller styled on the Atom Publishing Protocol"""
48 # To properly map this controller, ensure your config/routing.py
50 # To properly map this controller, ensure your config/routing.py
@@ -105,8 +107,8 b' class UsersController(BaseController):'
105 user_model = UserModel()
107 user_model = UserModel()
106 c.user = user_model.get(id)
108 c.user = user_model.get(id)
107
109
108 _form = UserForm(edit=True, old_data={'user_id':id,
110 _form = UserForm(edit=True, old_data={'user_id': id,
109 'email':c.user.email})()
111 'email': c.user.email})()
110 form_result = {}
112 form_result = {}
111 try:
113 try:
112 form_result = _form.to_python(dict(request.POST))
114 form_result = _form.to_python(dict(request.POST))
@@ -150,7 +152,6 b' class UsersController(BaseController):'
150 """GET /users/id: Show a specific item"""
152 """GET /users/id: Show a specific item"""
151 # url('user', id=ID)
153 # url('user', id=ID)
152
154
153
154 def edit(self, id, format='html'):
155 def edit(self, id, format='html'):
155 """GET /users/id/edit: Form to edit an existing item"""
156 """GET /users/id/edit: Form to edit an existing item"""
156 # url('edit_user', id=ID)
157 # url('edit_user', id=ID)
@@ -162,7 +163,8 b' class UsersController(BaseController):'
162 h.flash(_("You can't edit this user"), category='warning')
163 h.flash(_("You can't edit this user"), category='warning')
163 return redirect(url('users'))
164 return redirect(url('users'))
164 c.user.permissions = {}
165 c.user.permissions = {}
165 c.granted_permissions = user_model.fill_perms(c.user).permissions['global']
166 c.granted_permissions = user_model.fill_perms(c.user)\
167 .permissions['global']
166
168
167 defaults = c.user.get_dict()
169 defaults = c.user.get_dict()
168
170
@@ -32,7 +32,6 b' from pylons import request, session, tmp'
32 from pylons.controllers.util import abort, redirect
32 from pylons.controllers.util import abort, redirect
33 from pylons.i18n.translation import _
33 from pylons.i18n.translation import _
34
34
35 from rhodecode.lib.exceptions import DefaultUserException, UserOwnsReposException
36 from rhodecode.lib import helpers as h
35 from rhodecode.lib import helpers as h
37 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
36 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
38 from rhodecode.lib.base import BaseController, render
37 from rhodecode.lib.base import BaseController, render
@@ -44,6 +43,7 b' from rhodecode.model.users_group import '
44
43
45 log = logging.getLogger(__name__)
44 log = logging.getLogger(__name__)
46
45
46
47 class UsersGroupsController(BaseController):
47 class UsersGroupsController(BaseController):
48 """REST Controller styled on the Atom Publishing Protocol"""
48 """REST Controller styled on the Atom Publishing Protocol"""
49 # To properly map this controller, ensure your config/routing.py
49 # To properly map this controller, ensure your config/routing.py
@@ -72,8 +72,8 b' class UsersGroupsController(BaseControll'
72 try:
72 try:
73 form_result = users_group_form.to_python(dict(request.POST))
73 form_result = users_group_form.to_python(dict(request.POST))
74 users_group_model.create(form_result)
74 users_group_model.create(form_result)
75 h.flash(_('created users group %s') % form_result['users_group_name'],
75 h.flash(_('created users group %s') \
76 category='success')
76 % form_result['users_group_name'], category='success')
77 #action_logger(self.rhodecode_user, 'new_user', '', '', self.sa)
77 #action_logger(self.rhodecode_user, 'new_user', '', '', self.sa)
78 except formencode.Invalid, errors:
78 except formencode.Invalid, errors:
79 return htmlfill.render(
79 return htmlfill.render(
@@ -103,7 +103,6 b' class UsersGroupsController(BaseControll'
103 # method='put')
103 # method='put')
104 # url('users_group', id=ID)
104 # url('users_group', id=ID)
105
105
106
107 users_group_model = UsersGroupModel()
106 users_group_model = UsersGroupModel()
108 c.users_group = users_group_model.get(id)
107 c.users_group = users_group_model.get(id)
109 c.group_members = [(x.user_id, x.user.username) for x in
108 c.group_members = [(x.user_id, x.user.username) for x in
@@ -119,7 +118,8 b' class UsersGroupsController(BaseControll'
119 try:
118 try:
120 form_result = users_group_form.to_python(request.POST)
119 form_result = users_group_form.to_python(request.POST)
121 users_group_model.update(id, form_result)
120 users_group_model.update(id, form_result)
122 h.flash(_('updated users group %s') % form_result['users_group_name'],
121 h.flash(_('updated users group %s') \
122 % form_result['users_group_name'],
123 category='success')
123 category='success')
124 #action_logger(self.rhodecode_user, 'new_user', '', '', self.sa)
124 #action_logger(self.rhodecode_user, 'new_user', '', '', self.sa)
125 except formencode.Invalid, errors:
125 except formencode.Invalid, errors:
@@ -136,8 +136,6 b' class UsersGroupsController(BaseControll'
136
136
137 return redirect(url('users_groups'))
137 return redirect(url('users_groups'))
138
138
139
140
141 def delete(self, id):
139 def delete(self, id):
142 """DELETE /users_groups/id: Delete an existing item"""
140 """DELETE /users_groups/id: Delete an existing item"""
143 # Forms posted to this method should contain a hidden field:
141 # Forms posted to this method should contain a hidden field:
@@ -184,9 +184,10 b' class FilesController(BaseRepoController'
184 # do not just use the original mimetype, but force text/plain,
184 # do not just use the original mimetype, but force text/plain,
185 # otherwise it would serve text/html and that might be unsafe.
185 # otherwise it would serve text/html and that might be unsafe.
186 # Note: underlying vcs library fakes text/plain mimetype if the
186 # Note: underlying vcs library fakes text/plain mimetype if the
187 # mimetype can not be determined and it thinks it is not binary.
187 # mimetype can not be determined and it thinks it is not
188 # This might lead to erroneous text display in some cases, but
188 # binary.This might lead to erroneous text display in some
189 # helps in other cases, like with text files without extension.
189 # cases, but helps in other cases, like with text files
190 # without extension.
190 mimetype, dispo = 'text/plain', 'inline'
191 mimetype, dispo = 'text/plain', 'inline'
191
192
192 if dispo == 'attachment':
193 if dispo == 'attachment':
General Comments 0
You need to be logged in to leave comments. Login now