Show More
@@ -39,5 +39,12 b' def includeme(config):' | |||||
39 | name='admin_settings_vcs_svn_generate_cfg', |
|
39 | name='admin_settings_vcs_svn_generate_cfg', | |
40 | pattern=ADMIN_PREFIX + '/settings/vcs/svn_generate_cfg') |
|
40 | pattern=ADMIN_PREFIX + '/settings/vcs/svn_generate_cfg') | |
41 |
|
41 | |||
|
42 | config.add_route( | |||
|
43 | name='admin_settings_sessions', | |||
|
44 | pattern=ADMIN_PREFIX + '/settings/sessions') | |||
|
45 | config.add_route( | |||
|
46 | name='admin_settings_sessions_cleanup', | |||
|
47 | pattern=ADMIN_PREFIX + '/settings/sessions/cleanup') | |||
|
48 | ||||
42 | # Scan module for configuration decorators. |
|
49 | # Scan module for configuration decorators. | |
43 | config.scan() |
|
50 | config.scan() |
@@ -80,10 +80,15 b' class NavigationRegistry(object):' | |||||
80 | NavEntry('email', _('Email'), 'admin_settings_email'), |
|
80 | NavEntry('email', _('Email'), 'admin_settings_email'), | |
81 | NavEntry('hooks', _('Hooks'), 'admin_settings_hooks'), |
|
81 | NavEntry('hooks', _('Hooks'), 'admin_settings_hooks'), | |
82 | NavEntry('search', _('Full Text Search'), 'admin_settings_search'), |
|
82 | NavEntry('search', _('Full Text Search'), 'admin_settings_search'), | |
|
83 | ||||
|
84 | ||||
83 | NavEntry('integrations', _('Integrations'), |
|
85 | NavEntry('integrations', _('Integrations'), | |
84 | 'global_integrations_home', pyramid=True), |
|
86 | 'global_integrations_home', pyramid=True), | |
85 | NavEntry('system', _('System Info'), 'admin_settings_system'), |
|
87 | NavEntry('system', _('System Info'), 'admin_settings_system'), | |
86 | NavEntry('session', _('User Sessions'), 'admin_settings_sessions'), |
|
88 | ||
|
89 | ||||
|
90 | NavEntry('session', _('User Sessions'), | |||
|
91 | 'admin_settings_sessions', pyramid=True), | |||
87 | NavEntry('open_source', _('Open Source Licenses'), |
|
92 | NavEntry('open_source', _('Open Source Licenses'), | |
88 | 'admin_settings_open_source', pyramid=True), |
|
93 | 'admin_settings_open_source', pyramid=True), | |
89 |
|
94 |
@@ -23,12 +23,18 b' import logging' | |||||
23 |
|
23 | |||
24 | from pylons import tmpl_context as c |
|
24 | from pylons import tmpl_context as c | |
25 | from pyramid.view import view_config |
|
25 | from pyramid.view import view_config | |
|
26 | from pyramid.httpexceptions import HTTPFound | |||
|
27 | ||||
|
28 | from rhodecode.translation import _ | |||
|
29 | from rhodecode.svn_support.utils import generate_mod_dav_svn_config | |||
26 |
|
30 | |||
27 | from rhodecode.lib.auth import ( |
|
31 | from rhodecode.lib.auth import ( | |
28 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) |
|
32 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) | |
29 | from rhodecode.lib.utils import read_opensource_licenses |
|
33 | from rhodecode.lib.utils import read_opensource_licenses | |
30 |
from rhodecode. |
|
34 | from rhodecode.lib.utils2 import safe_int | |
31 |
from rhodecode. |
|
35 | from rhodecode.lib import system_info | |
|
36 | from rhodecode.lib import user_sessions | |||
|
37 | ||||
32 |
|
38 | |||
33 | from .navigation import navigation_list |
|
39 | from .navigation import navigation_list | |
34 |
|
40 | |||
@@ -72,7 +78,8 b' class AdminSettingsView(object):' | |||||
72 | } |
|
78 | } | |
73 | except Exception: |
|
79 | except Exception: | |
74 | log.exception( |
|
80 | log.exception( | |
75 |
'Exception while generating the Apache |
|
81 | 'Exception while generating the Apache ' | |
|
82 | 'configuration for Subversion.') | |||
76 | msg = { |
|
83 | msg = { | |
77 | 'message': _('Failed to generate the Apache configuration for Subversion.'), |
|
84 | 'message': _('Failed to generate the Apache configuration for Subversion.'), | |
78 | 'level': 'error', |
|
85 | 'level': 'error', | |
@@ -80,3 +87,59 b' class AdminSettingsView(object):' | |||||
80 |
|
87 | |||
81 | data = {'message': msg} |
|
88 | data = {'message': msg} | |
82 | return data |
|
89 | return data | |
|
90 | ||||
|
91 | @LoginRequired() | |||
|
92 | @HasPermissionAllDecorator('hg.admin') | |||
|
93 | @view_config( | |||
|
94 | route_name='admin_settings_sessions', request_method='GET', | |||
|
95 | renderer='rhodecode:templates/admin/settings/settings.mako') | |||
|
96 | def settings_sessions(self): | |||
|
97 | c.active = 'sessions' | |||
|
98 | c.navlist = navigation_list(self.request) | |||
|
99 | ||||
|
100 | c.cleanup_older_days = 60 | |||
|
101 | older_than_seconds = 24 * 60 * 60 * 24 * c.cleanup_older_days | |||
|
102 | ||||
|
103 | config = system_info.rhodecode_config().get_value()['value']['config'] | |||
|
104 | c.session_model = user_sessions.get_session_handler( | |||
|
105 | config.get('beaker.session.type', 'memory'))(config) | |||
|
106 | ||||
|
107 | c.session_conf = c.session_model.config | |||
|
108 | c.session_count = c.session_model.get_count() | |||
|
109 | c.session_expired_count = c.session_model.get_expired_count( | |||
|
110 | older_than_seconds) | |||
|
111 | ||||
|
112 | return {} | |||
|
113 | ||||
|
114 | @LoginRequired() | |||
|
115 | @HasPermissionAllDecorator('hg.admin') | |||
|
116 | @view_config( | |||
|
117 | route_name='admin_settings_sessions_cleanup', request_method='POST') | |||
|
118 | def settings_sessions_cleanup(self): | |||
|
119 | ||||
|
120 | expire_days = safe_int(self.request.params.get('expire_days')) | |||
|
121 | ||||
|
122 | if expire_days is None: | |||
|
123 | expire_days = 60 | |||
|
124 | ||||
|
125 | older_than_seconds = 24 * 60 * 60 * 24 * expire_days | |||
|
126 | ||||
|
127 | config = system_info.rhodecode_config().get_value()['value']['config'] | |||
|
128 | session_model = user_sessions.get_session_handler( | |||
|
129 | config.get('beaker.session.type', 'memory'))(config) | |||
|
130 | ||||
|
131 | try: | |||
|
132 | session_model.clean_sessions( | |||
|
133 | older_than_seconds=older_than_seconds) | |||
|
134 | self.request.session.flash( | |||
|
135 | _('Cleaned up old sessions'), queue='success') | |||
|
136 | except user_sessions.CleanupCommand as msg: | |||
|
137 | self.request.session.flash(msg, category='warning') | |||
|
138 | except Exception as e: | |||
|
139 | log.exception('Failed session cleanup') | |||
|
140 | self.request.session.flash( | |||
|
141 | _('Failed to cleanup up old sessions'), queue='error') | |||
|
142 | ||||
|
143 | redirect_to = self.request.resource_path( | |||
|
144 | self.context, route_name='admin_settings_sessions') | |||
|
145 | return HTTPFound(redirect_to) |
@@ -509,12 +509,6 b' def make_map(config):' | |||||
509 | m.connect('admin_settings_system_update', '/settings/system/updates', |
|
509 | m.connect('admin_settings_system_update', '/settings/system/updates', | |
510 | action='settings_system_update', conditions={'method': ['GET']}) |
|
510 | action='settings_system_update', conditions={'method': ['GET']}) | |
511 |
|
511 | |||
512 | m.connect('admin_settings_sessions', '/settings/sessions', |
|
|||
513 | action='settings_sessions', conditions={'method': ['GET']}) |
|
|||
514 |
|
||||
515 | m.connect('admin_settings_sessions_cleanup', '/settings/sessions/cleanup', |
|
|||
516 | action='settings_sessions_cleanup', conditions={'method': ['POST']}) |
|
|||
517 |
|
||||
518 | m.connect('admin_settings_supervisor', '/settings/supervisor', |
|
512 | m.connect('admin_settings_supervisor', '/settings/supervisor', | |
519 | action='settings_supervisor', conditions={'method': ['GET']}) |
|
513 | action='settings_supervisor', conditions={'method': ['GET']}) | |
520 | m.connect('admin_settings_supervisor_log', '/settings/supervisor/{procid}/log', |
|
514 | m.connect('admin_settings_supervisor_log', '/settings/supervisor/{procid}/log', |
@@ -50,8 +50,6 b' from rhodecode.lib.utils2 import (' | |||||
50 | from rhodecode.lib.compat import OrderedDict |
|
50 | from rhodecode.lib.compat import OrderedDict | |
51 | from rhodecode.lib.ext_json import json |
|
51 | from rhodecode.lib.ext_json import json | |
52 | from rhodecode.lib.utils import jsonify |
|
52 | from rhodecode.lib.utils import jsonify | |
53 | from rhodecode.lib import system_info |
|
|||
54 | from rhodecode.lib import user_sessions |
|
|||
55 |
|
53 | |||
56 | from rhodecode.model.db import RhodeCodeUi, Repository |
|
54 | from rhodecode.model.db import RhodeCodeUi, Repository | |
57 | from rhodecode.model.forms import ApplicationSettingsForm, \ |
|
55 | from rhodecode.model.forms import ApplicationSettingsForm, \ | |
@@ -693,52 +691,6 b' class SettingsController(BaseController)' | |||||
693 | return render('admin/settings/settings_system_update.mako') |
|
691 | return render('admin/settings/settings_system_update.mako') | |
694 |
|
692 | |||
695 | @HasPermissionAllDecorator('hg.admin') |
|
693 | @HasPermissionAllDecorator('hg.admin') | |
696 | def settings_sessions(self): |
|
|||
697 | # url('admin_settings_sessions') |
|
|||
698 |
|
||||
699 | c.active = 'sessions' |
|
|||
700 | c.cleanup_older_days = 60 |
|
|||
701 | older_than_seconds = 24 * 60 * 60 * 24 * c.cleanup_older_days |
|
|||
702 |
|
||||
703 | config = system_info.rhodecode_config().get_value()['value']['config'] |
|
|||
704 | c.session_model = user_sessions.get_session_handler( |
|
|||
705 | config.get('beaker.session.type', 'memory'))(config) |
|
|||
706 |
|
||||
707 | c.session_conf = c.session_model.config |
|
|||
708 | c.session_count = c.session_model.get_count() |
|
|||
709 | c.session_expired_count = c.session_model.get_expired_count( |
|
|||
710 | older_than_seconds) |
|
|||
711 |
|
||||
712 | return render('admin/settings/settings.mako') |
|
|||
713 |
|
||||
714 | @HasPermissionAllDecorator('hg.admin') |
|
|||
715 | def settings_sessions_cleanup(self): |
|
|||
716 | # url('admin_settings_sessions_update') |
|
|||
717 |
|
||||
718 | expire_days = safe_int(request.POST.get('expire_days')) |
|
|||
719 |
|
||||
720 | if expire_days is None: |
|
|||
721 | expire_days = 60 |
|
|||
722 |
|
||||
723 | older_than_seconds = 24 * 60 * 60 * 24 * expire_days |
|
|||
724 |
|
||||
725 | config = system_info.rhodecode_config().get_value()['value']['config'] |
|
|||
726 | session_model = user_sessions.get_session_handler( |
|
|||
727 | config.get('beaker.session.type', 'memory'))(config) |
|
|||
728 |
|
||||
729 | try: |
|
|||
730 | session_model.clean_sessions( |
|
|||
731 | older_than_seconds=older_than_seconds) |
|
|||
732 | h.flash(_('Cleaned up old sessions'), category='success') |
|
|||
733 | except user_sessions.CleanupCommand as msg: |
|
|||
734 | h.flash(msg, category='warning') |
|
|||
735 | except Exception as e: |
|
|||
736 | log.exception('Failed session cleanup') |
|
|||
737 | h.flash(_('Failed to cleanup up old sessions'), category='error') |
|
|||
738 |
|
||||
739 | return redirect(url('admin_settings_sessions')) |
|
|||
740 |
|
||||
741 | @HasPermissionAllDecorator('hg.admin') |
|
|||
742 | def settings_supervisor(self): |
|
694 | def settings_supervisor(self): | |
743 | c.rhodecode_ini = rhodecode.CONFIG |
|
695 | c.rhodecode_ini = rhodecode.CONFIG | |
744 | c.active = 'supervisor' |
|
696 | c.active = 'supervisor' |
@@ -28,7 +28,7 b'' | |||||
28 | <h3 class="panel-title">${_('Cleanup Old Sessions')}</h3> |
|
28 | <h3 class="panel-title">${_('Cleanup Old Sessions')}</h3> | |
29 | </div> |
|
29 | </div> | |
30 | <div class="panel-body"> |
|
30 | <div class="panel-body"> | |
31 |
${h.secure_form(h. |
|
31 | ${h.secure_form(h.route_path('admin_settings_sessions_cleanup'), method='post')} | |
32 |
|
32 | |||
33 | <p> |
|
33 | <p> | |
34 | ${_('Cleanup user sessions that were not active during chosen time frame.')} <br/> |
|
34 | ${_('Cleanup user sessions that were not active during chosen time frame.')} <br/> |
General Comments 0
You need to be logged in to leave comments.
Login now