Show More
@@ -30,6 +30,7 b' from rhodecode.lib.auth import (' | |||
|
30 | 30 | from rhodecode.lib.utils2 import safe_int |
|
31 | 31 | from rhodecode.lib import system_info |
|
32 | 32 | from rhodecode.lib import user_sessions |
|
33 | from rhodecode.lib import helpers as h | |
|
33 | 34 | |
|
34 | 35 | |
|
35 | 36 | log = logging.getLogger(__name__) |
@@ -88,14 +89,12 b' class AdminSessionSettingsView(BaseAppVi' | |||
|
88 | 89 | try: |
|
89 | 90 | session_model.clean_sessions( |
|
90 | 91 | older_than_seconds=older_than_seconds) |
|
91 | self.request.session.flash( | |
|
92 | _('Cleaned up old sessions'), queue='success') | |
|
92 | h.flash(_('Cleaned up old sessions'), category='success') | |
|
93 | 93 | except user_sessions.CleanupCommand as msg: |
|
94 |
|
|
|
94 | h.flash(msg.message, category='warning') | |
|
95 | 95 | except Exception as e: |
|
96 | 96 | log.exception('Failed session cleanup') |
|
97 | self.request.session.flash( | |
|
98 | _('Failed to cleanup up old sessions'), queue='error') | |
|
97 | h.flash(_('Failed to cleanup up old sessions'), category='error') | |
|
99 | 98 | |
|
100 | 99 | redirect_to = self.request.resource_path( |
|
101 | 100 | self.context, route_name='admin_settings_sessions') |
@@ -166,8 +166,7 b' class AdminSystemInfoSettingsView(BaseAp' | |||
|
166 | 166 | c.data_items.pop(0) # remove server info |
|
167 | 167 | self.request.override_renderer = 'admin/settings/settings_system_snapshot.mako' |
|
168 | 168 | else: |
|
169 | self.request.session.flash( | |
|
170 | 'You are not allowed to do this', queue='warning') | |
|
169 | h.flash('You are not allowed to do this', category='warning') | |
|
171 | 170 | return self._get_template_context(c) |
|
172 | 171 | |
|
173 | 172 | @LoginRequired() |
@@ -22,7 +22,7 b'' | |||
|
22 | 22 | import pytest |
|
23 | 23 | |
|
24 | 24 | |
|
25 | class EnabledAuthPlugin(): | |
|
25 | class EnabledAuthPlugin(object): | |
|
26 | 26 | """ |
|
27 | 27 | Context manager that updates the 'auth_plugins' setting in DB to enable |
|
28 | 28 | a plugin. Previous setting is restored on exit. The rhodecode auth plugin |
@@ -29,6 +29,7 b' from pyramid.response import Response' | |||
|
29 | 29 | from rhodecode.apps._base import BaseAppView |
|
30 | 30 | from rhodecode.authentication.base import ( |
|
31 | 31 | get_auth_cache_manager, get_perms_cache_manager, get_authn_registry) |
|
32 | from rhodecode.lib import helpers as h | |
|
32 | 33 | from rhodecode.lib.auth import ( |
|
33 | 34 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) |
|
34 | 35 | from rhodecode.model.forms import AuthSettingsForm |
@@ -88,10 +89,10 b' class AuthnPluginViewBase(BaseAppView):' | |||
|
88 | 89 | valid_data = schema.deserialize(data) |
|
89 | 90 | except colander.Invalid as e: |
|
90 | 91 | # Display error message and display form again. |
|
91 |
|
|
|
92 | h.flash( | |
|
92 | 93 | _('Errors exist when saving plugin settings. ' |
|
93 | 94 | 'Please check the form inputs.'), |
|
94 |
|
|
|
95 | category='error') | |
|
95 | 96 | defaults = {key: data[key] for key in data if key in schema} |
|
96 | 97 | return self.settings_get(errors=e.asdict(), defaults=defaults) |
|
97 | 98 | |
@@ -101,9 +102,7 b' class AuthnPluginViewBase(BaseAppView):' | |||
|
101 | 102 | Session().commit() |
|
102 | 103 | |
|
103 | 104 | # Display success message and redirect. |
|
104 | self.request.session.flash( | |
|
105 | _('Auth settings updated successfully.'), | |
|
106 | queue='success') | |
|
105 | h.flash(_('Auth settings updated successfully.'), category='success') | |
|
107 | 106 | redirect_to = self.request.resource_path( |
|
108 | 107 | self.context, route_name='auth_home') |
|
109 | 108 | return HTTPFound(redirect_to) |
@@ -168,24 +167,19 b' class AuthSettingsView(BaseAppView):' | |||
|
168 | 167 | cache_manager = get_perms_cache_manager() |
|
169 | 168 | cache_manager.clear() |
|
170 | 169 | |
|
171 | self.request.session.flash( | |
|
172 | _('Auth settings updated successfully.'), | |
|
173 | queue='success') | |
|
170 | h.flash(_('Auth settings updated successfully.'), category='success') | |
|
174 | 171 | except formencode.Invalid as errors: |
|
175 | 172 | e = errors.error_dict or {} |
|
176 | self.request.session.flash( | |
|
177 | _('Errors exist when saving plugin setting. ' | |
|
178 | 'Please check the form inputs.'), | |
|
179 | queue='error') | |
|
173 | h.flash(_('Errors exist when saving plugin setting. ' | |
|
174 | 'Please check the form inputs.'), category='error') | |
|
180 | 175 | return self.index( |
|
181 | 176 | defaults=errors.value, |
|
182 | 177 | errors=e, |
|
183 | 178 | prefix_error=False) |
|
184 | 179 | except Exception: |
|
185 | 180 | log.exception('Exception in auth_settings') |
|
186 | self.request.session.flash( | |
|
187 | _('Error occurred during update of auth settings.'), | |
|
188 | queue='error') | |
|
181 | h.flash(_('Error occurred during update of auth settings.'), | |
|
182 | category='error') | |
|
189 | 183 | |
|
190 | 184 | redirect_to = self.request.resource_path( |
|
191 | 185 | self.context, route_name='auth_home') |
@@ -32,7 +32,7 b' from rhodecode.lib.auth import (' | |||
|
32 | 32 | LoginRequired, CSRFRequired, HasPermissionAnyDecorator, |
|
33 | 33 | HasRepoPermissionAnyDecorator, HasRepoGroupPermissionAnyDecorator) |
|
34 | 34 | from rhodecode.lib.utils2 import safe_int |
|
35 |
from rhodecode.lib |
|
|
35 | from rhodecode.lib import helpers as h | |
|
36 | 36 | from rhodecode.model.db import Repository, RepoGroup, Session, Integration |
|
37 | 37 | from rhodecode.model.scm import ScmModel |
|
38 | 38 | from rhodecode.model.integration import IntegrationModel |
@@ -169,10 +169,10 b' class IntegrationSettingsViewBase(BaseAp' | |||
|
169 | 169 | _ = self.request.translate |
|
170 | 170 | Session().delete(integration) |
|
171 | 171 | Session().commit() |
|
172 | self.request.session.flash( | |
|
172 | h.flash( | |
|
173 | 173 | _('Integration {integration_name} deleted successfully.').format( |
|
174 | 174 | integration_name=integration.name), |
|
175 |
|
|
|
175 | category='success') | |
|
176 | 176 | |
|
177 | 177 | if self.repo: |
|
178 | 178 | redirect_to = self.request.route_path( |
@@ -208,6 +208,7 b' class IntegrationSettingsViewBase(BaseAp' | |||
|
208 | 208 | integrations.append((IntType, integration)) |
|
209 | 209 | |
|
210 | 210 | sort_arg = self.request.GET.get('sort', 'name:asc') |
|
211 | sort_dir = 'asc' | |
|
211 | 212 | if ':' in sort_arg: |
|
212 | 213 | sort_field, sort_dir = sort_arg.split(':') |
|
213 | 214 | else: |
@@ -223,7 +224,7 b' class IntegrationSettingsViewBase(BaseAp' | |||
|
223 | 224 | self.request.path, self.request.GET) |
|
224 | 225 | page = safe_int(self.request.GET.get('page', 1), 1) |
|
225 | 226 | |
|
226 | integrations = Page( | |
|
227 | integrations = h.Page( | |
|
227 | 228 | integrations, page=page, items_per_page=10, url=page_url) |
|
228 | 229 | |
|
229 | 230 | c.rev_sort_dir = sort_dir != 'desc' and 'desc' or 'asc' |
@@ -297,10 +298,10 b' class IntegrationSettingsViewBase(BaseAp' | |||
|
297 | 298 | try: |
|
298 | 299 | valid_data = form.validate_pstruct(pstruct) |
|
299 | 300 | except deform.ValidationFailure as e: |
|
300 |
|
|
|
301 | h.flash( | |
|
301 | 302 | _('Errors exist when saving integration settings. ' |
|
302 | 303 | 'Please check the form inputs.'), |
|
303 |
|
|
|
304 | category='error') | |
|
304 | 305 | return self._settings_get(form=e) |
|
305 | 306 | |
|
306 | 307 | if not self.integration: |
@@ -322,10 +323,10 b' class IntegrationSettingsViewBase(BaseAp' | |||
|
322 | 323 | self.integration.settings = valid_data['settings'] |
|
323 | 324 | Session().commit() |
|
324 | 325 | # Display success message and redirect. |
|
325 | self.request.session.flash( | |
|
326 | h.flash( | |
|
326 | 327 | _('Integration {integration_name} updated successfully.').format( |
|
327 | 328 | integration_name=self.IntegrationType.display_name), |
|
328 |
|
|
|
329 | category='success') | |
|
329 | 330 | |
|
330 | 331 | # if integration scope changes, we must redirect to the right place |
|
331 | 332 | # keeping in mind if the original view was for /repo/ or /_admin/ |
General Comments 0
You need to be logged in to leave comments.
Login now