annotate rhodecode/controllers/admin/settings.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl

Imported some of the GPLv3'd changes from RhodeCode v2.2.5. This imports changes between changesets 21af6c4eab3d and 6177597791c2 in RhodeCode's original repository, including only changes to Python files and HTML. RhodeCode clearly licensed its changes to these files under GPLv3 in their /LICENSE file, which states the following: The Python code and integrated HTML are licensed under the GPLv3 license. (See: https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE or http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE for an online copy of that LICENSE file) Conservancy reviewed these changes and confirmed that they can be licensed as a whole to the Kallithea project under GPLv3-only. While some of the contents committed herein are clearly licensed GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the statement above from RhodeCode indicates that they intend GPLv3-only as their license, per GPLv3ยง14 and other relevant sections of GPLv3.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:03:13 -0400
parents 7676606f7622
children 31e119cb02ef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
1 # -*- coding: utf-8 -*-
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
2 # This program is free software: you can redistribute it and/or modify
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
3 # it under the terms of the GNU General Public License as published by
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
5 # (at your option) any later version.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1164
diff changeset
6 #
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # This program is distributed in the hope that it will be useful,
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 # GNU General Public License for more details.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1164
diff changeset
11 #
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # You should have received a copy of the GNU General Public License
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
14 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
15 rhodecode.controllers.admin.settings
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
17
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
18 settings controller for rhodecode admin
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
19
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
20 :created_on: Jul 14, 2010
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
21 :author: marcink
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
22 :copyright: (c) 2013 RhodeCode GmbH.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
23 :license: GPLv3, see LICENSE for more details.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
24 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
25
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
26 import time
890
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
27 import logging
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
28 import traceback
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
29 import formencode
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
30
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 from formencode import htmlfill
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
32 from pylons import request, tmpl_context as c, url, config
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
33 from pylons.controllers.util import redirect
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 from pylons.i18n.translation import _
890
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
35
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
36 from rhodecode.lib import helpers as h
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
37 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
38 from rhodecode.lib.base import BaseController, render
705
9e9f1b919c0c implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
39 from rhodecode.lib.celerylib import tasks, run_task
4090
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
40 from rhodecode.lib.exceptions import HgsubversionImportError
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
41 from rhodecode.lib.utils import repo2db_mapper, set_rhodecode_config
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
42 from rhodecode.model.db import RhodeCodeUi, Repository, RhodeCodeSetting
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
43 from rhodecode.model.forms import ApplicationSettingsForm, \
2674
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2662
diff changeset
44 ApplicationUiSettingsForm, ApplicationVisualisationForm
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
45 from rhodecode.model.license import LicenseModel
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
46 from rhodecode.model.scm import ScmModel
1718
f78bee8eec78 reduce cookie size for better support of client side sessions
Marcin Kuzminski <marcin@python-works.com>
parents: 1717
diff changeset
47 from rhodecode.model.notification import EmailNotificationModel
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
48 from rhodecode.model.meta import Session
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
49 from rhodecode.lib.utils2 import str2bool, safe_unicode, safe_str
3154
0226b6d6b2b5 Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents: 3145
diff changeset
50 from rhodecode.lib.compat import json
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 log = logging.getLogger(__name__)
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 class SettingsController(BaseController):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 """REST Controller styled on the Atom Publishing Protocol"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 # To properly map this controller, ensure your config/routing.py
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 # file has a resource setup:
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1164
diff changeset
58 # map.resource('setting', 'settings', controller='admin/settings',
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 # path_prefix='/admin', name_prefix='admin_')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 @LoginRequired()
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 def __before__(self):
3712
08cf7741e5e1 removed obsolete admin_user tmpl context variables
Marcin Kuzminski <marcin@python-works.com>
parents: 3693
diff changeset
63 super(SettingsController, self).__before__()
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
64
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
65 def _get_hg_ui_settings(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
66 ret = RhodeCodeUi.query().all()
2192
a801c4542f48 added useful system info + packages to settings page.
Marcin Kuzminski <marcin@python-works.com>
parents: 2086
diff changeset
67
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
68 if not ret:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
69 raise Exception('Could not get application ui settings !')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
70 settings = {}
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
71 for each in ret:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
72 k = each.ui_key
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
73 v = each.ui_value
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
74 if k == '/':
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
75 k = 'root_path'
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
76
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
77 if k == 'push_ssl':
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
78 v = str2bool(v)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
79
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
80 if k.find('.') != -1:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
81 k = k.replace('.', '_')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
82
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
83 if each.ui_section in ['hooks', 'extensions']:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
84 v = each.ui_active
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
85
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
86 settings[each.ui_section + '_' + k] = v
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
87 return settings
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
88
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
89 @HasPermissionAllDecorator('hg.admin')
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
90 def settings_vcs(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
91 """GET /admin/settings: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
92 # url('admin_settings')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
93 c.active = 'vcs'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
94 if request.POST:
2662
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
95 application_form = ApplicationUiSettingsForm()()
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
96 try:
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
97 form_result = application_form.to_python(dict(request.POST))
564
ba7e24cd4786 refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 549
diff changeset
98 except formencode.Invalid, errors:
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
99 return htmlfill.render(
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
100 render('admin/settings/settings.html'),
359
339d1368c10d new style error display for settings, added flash msg for repo rescan
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
101 defaults=errors.value,
339d1368c10d new style error display for settings, added flash msg for repo rescan
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
102 errors=errors.error_dict or {},
339d1368c10d new style error display for settings, added flash msg for repo rescan
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
103 prefix_error=False,
2662
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
104 encoding="UTF-8"
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
105 )
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
106
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
107 try:
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
108 sett = RhodeCodeUi.get_by_key('push_ssl')
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
109 sett.ui_value = form_result['web_push_ssl']
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
110 Session().add(sett)
3920
985db7f7b9b2 Added flag to controll option for changing the repos path location
Marcin Kuzminski <marcin@python-works.com>
parents: 3910
diff changeset
111 if c.visual.allow_repo_location_change:
985db7f7b9b2 Added flag to controll option for changing the repos path location
Marcin Kuzminski <marcin@python-works.com>
parents: 3910
diff changeset
112 sett = RhodeCodeUi.get_by_key('/')
985db7f7b9b2 Added flag to controll option for changing the repos path location
Marcin Kuzminski <marcin@python-works.com>
parents: 3910
diff changeset
113 sett.ui_value = form_result['paths_root_path']
985db7f7b9b2 Added flag to controll option for changing the repos path location
Marcin Kuzminski <marcin@python-works.com>
parents: 3910
diff changeset
114 Session().add(sett)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
115
2662
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
116 #HOOKS
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
117 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE)
3570
8173b0cfe9bd settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents: 3565
diff changeset
118 sett.ui_active = form_result['hooks_changegroup_update']
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
119 Session().add(sett)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
120
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
121 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_REPO_SIZE)
3570
8173b0cfe9bd settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents: 3565
diff changeset
122 sett.ui_active = form_result['hooks_changegroup_repo_size']
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
123 Session().add(sett)
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
124
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
125 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_PUSH)
3570
8173b0cfe9bd settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents: 3565
diff changeset
126 sett.ui_active = form_result['hooks_changegroup_push_logger']
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
127 Session().add(sett)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
128
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
129 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_PULL)
3570
8173b0cfe9bd settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents: 3565
diff changeset
130 sett.ui_active = form_result['hooks_outgoing_pull_logger']
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
131
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
132 Session().add(sett)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
133
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
134 ## EXTENSIONS
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
135 sett = RhodeCodeUi.get_by_key('largefiles')
2844
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
136 if not sett:
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
137 #make one if it's not there !
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
138 sett = RhodeCodeUi()
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
139 sett.ui_key = 'largefiles'
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
140 sett.ui_section = 'extensions'
3570
8173b0cfe9bd settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents: 3565
diff changeset
141 sett.ui_active = form_result['extensions_largefiles']
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
142 Session().add(sett)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
143
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
144 sett = RhodeCodeUi.get_by_key('hgsubversion')
2844
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
145 if not sett:
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
146 #make one if it's not there !
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
147 sett = RhodeCodeUi()
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
148 sett.ui_key = 'hgsubversion'
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
149 sett.ui_section = 'extensions'
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
150
3570
8173b0cfe9bd settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents: 3565
diff changeset
151 sett.ui_active = form_result['extensions_hgsubversion']
4090
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
152 if sett.ui_active:
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
153 try:
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
154 import hgsubversion # pragma: no cover
4090
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
155 except ImportError:
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
156 raise HgsubversionImportError
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
157 Session().add(sett)
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
158
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
159 # sett = RhodeCodeUi.get_by_key('hggit')
2844
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
160 # if not sett:
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
161 # #make one if it's not there !
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
162 # sett = RhodeCodeUi()
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
163 # sett.ui_key = 'hggit'
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
164 # sett.ui_section = 'extensions'
7b0f803229be autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
165 #
3570
8173b0cfe9bd settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents: 3565
diff changeset
166 # sett.ui_active = form_result['extensions_hggit']
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
167 # Session().add(sett)
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
168
2662
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
169 Session().commit()
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
170
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
171 h.flash(_('Updated VCS settings'), category='success')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
172
4090
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
173 except HgsubversionImportError:
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
174 log.error(traceback.format_exc())
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
175 h.flash(_('Unable to activate hgsubversion support. '
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
176 'The "hgsubversion" library is missing'),
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
177 category='error')
7676606f7622 Added more detailed (and localized) information if hgsubversion is not
Grzegorz Rożniecki <xaerxess@gmail.com>
parents: 4045
diff changeset
178
2662
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
179 except Exception:
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
180 log.error(traceback.format_exc())
3565
a8f2d78d14ea consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents: 3455
diff changeset
181 h.flash(_('Error occurred during updating '
2662
91c442a489bb sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents: 2626
diff changeset
182 'application settings'), category='error')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
183
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
184 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
185 defaults.update(self._get_hg_ui_settings())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
186
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
187 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
188 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
189 defaults=defaults,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
190 encoding="UTF-8",
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
191 force_defaults=False)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
192
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
193 @HasPermissionAllDecorator('hg.admin')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
194 def settings_mapping(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
195 """GET /admin/settings/mapping: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
196 # url('admin_settings_mapping')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
197 c.active = 'mapping'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
198 if request.POST:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
199 rm_obsolete = request.POST.get('destroy', False)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
200 install_git_hooks = request.POST.get('hooks', False)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
201 invalidate_cache = request.POST.get('invalidate', False)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
202 log.debug('rescanning repo location with destroy obsolete=%s and '
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
203 'install git hooks=%s' % (rm_obsolete,install_git_hooks))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
204
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
205 if invalidate_cache:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
206 log.debug('invalidating all repositories cache')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
207 for repo in Repository.get_all():
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
208 ScmModel().mark_for_invalidation(repo.repo_name, delete=True)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
209
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
210 filesystem_repos = ScmModel().repo_scan()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
211 added, removed = repo2db_mapper(filesystem_repos, rm_obsolete,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
212 install_git_hook=install_git_hooks)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
213 _repr = lambda l: ', '.join(map(safe_unicode, l)) or '-'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
214 h.flash(_('Repositories successfully '
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
215 'rescanned added: %s ; removed: %s') %
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
216 (_repr(added), _repr(removed)),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
217 category='success')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
218 return redirect(url('admin_settings_mapping'))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
219
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
220 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
221 defaults.update(self._get_hg_ui_settings())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
222
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
223 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
224 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
225 defaults=defaults,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
226 encoding="UTF-8",
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
227 force_defaults=False)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
228
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
229 @HasPermissionAllDecorator('hg.admin')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
230 def settings_global(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
231 """GET /admin/settings/global: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
232 # url('admin_settings_global')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
233 c.active = 'global'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
234 if request.POST:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
235 application_form = ApplicationSettingsForm()()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
236 try:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
237 form_result = application_form.to_python(dict(request.POST))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
238 except formencode.Invalid, errors:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
239 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
240 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
241 defaults=errors.value,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
242 errors=errors.error_dict or {},
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
243 prefix_error=False,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
244 encoding="UTF-8")
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
245
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
246 try:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
247 sett1 = RhodeCodeSetting.create_or_update('title',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
248 form_result['rhodecode_title'])
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
249 Session().add(sett1)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
250
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
251 sett2 = RhodeCodeSetting.create_or_update('realm',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
252 form_result['rhodecode_realm'])
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
253 Session().add(sett2)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
254
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
255 sett3 = RhodeCodeSetting.create_or_update('ga_code',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
256 form_result['rhodecode_ga_code'])
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
257 Session().add(sett3)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
258
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
259 sett4 = RhodeCodeSetting.create_or_update('captcha_public_key',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
260 form_result['rhodecode_captcha_public_key'])
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
261 Session().add(sett4)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
262
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
263 sett5 = RhodeCodeSetting.create_or_update('captcha_private_key',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
264 form_result['rhodecode_captcha_private_key'])
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
265 Session().add(sett5)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
266
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
267 Session().commit()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
268 set_rhodecode_config(config)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
269 h.flash(_('Updated application settings'), category='success')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
270
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
271 except Exception:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
272 log.error(traceback.format_exc())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
273 h.flash(_('Error occurred during updating '
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
274 'application settings'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
275 category='error')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
276
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
277 return redirect(url('admin_settings_global'))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
278
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
279 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
280 defaults.update(self._get_hg_ui_settings())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
281
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
282 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
283 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
284 defaults=defaults,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
285 encoding="UTF-8",
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
286 force_defaults=False)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
287
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
288 @HasPermissionAllDecorator('hg.admin')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
289 def settings_visual(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
290 """GET /admin/settings/visual: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
291 # url('admin_settings_visual')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
292 c.active = 'visual'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
293 if request.POST:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
294 application_form = ApplicationVisualisationForm()()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
295 try:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
296 form_result = application_form.to_python(dict(request.POST))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
297 except formencode.Invalid, errors:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
298 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
299 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
300 defaults=errors.value,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
301 errors=errors.error_dict or {},
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
302 prefix_error=False,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
303 encoding="UTF-8"
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
304 )
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
305
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
306 try:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
307 settings = [
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
308 ('show_public_icon', 'rhodecode_show_public_icon', 'bool'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
309 ('show_private_icon', 'rhodecode_show_private_icon', 'bool'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
310 ('stylify_metatags', 'rhodecode_stylify_metatags', 'bool'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
311 ('repository_fields', 'rhodecode_repository_fields', 'bool'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
312 ('dashboard_items', 'rhodecode_dashboard_items', 'int'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
313 ('admin_grid_items', 'rhodecode_admin_grid_items', 'int'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
314 ('show_version', 'rhodecode_show_version', 'bool'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
315 ('use_gravatar', 'rhodecode_use_gravatar', 'bool'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
316 ('gravatar_url', 'rhodecode_gravatar_url', 'unicode'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
317 ('clone_uri_tmpl', 'rhodecode_clone_uri_tmpl', 'unicode'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
318 ]
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
319 for setting, form_key, type_ in settings:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
320 sett = RhodeCodeSetting.create_or_update(setting,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
321 form_result[form_key], type_)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
322 Session().add(sett)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
323
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
324 Session().commit()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
325 set_rhodecode_config(config)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
326 h.flash(_('Updated visualisation settings'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
327 category='success')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
328
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
329 except Exception:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
330 log.error(traceback.format_exc())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
331 h.flash(_('Error occurred during updating '
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
332 'visualisation settings'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
333 category='error')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
334
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
335 return redirect(url('admin_settings_visual'))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
336
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
337 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
338 defaults.update(self._get_hg_ui_settings())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
339
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
340 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
341 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
342 defaults=defaults,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
343 encoding="UTF-8",
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
344 force_defaults=False)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
345
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
346 @HasPermissionAllDecorator('hg.admin')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
347 def settings_email(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
348 """GET /admin/settings/email: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
349 # url('admin_settings_email')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
350 c.active = 'email'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
351 if request.POST:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
352 test_email = request.POST.get('test_email')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
353 test_email_subj = 'RhodeCode test email'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
354 test_email_body = ('RhodeCode Email test, '
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
355 'RhodeCode version: %s' % c.rhodecode_version)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
356 if not test_email:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
357 h.flash(_('Please enter email address'), category='error')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
358 return redirect(url('admin_settings_email'))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
359
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
360 test_email_html_body = EmailNotificationModel()\
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
361 .get_email_tmpl(EmailNotificationModel.TYPE_DEFAULT,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
362 body=test_email_body)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
363
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
364 recipients = [test_email] if test_email else None
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
365
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
366 run_task(tasks.send_email, recipients, test_email_subj,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
367 test_email_body, test_email_html_body)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
368
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
369 h.flash(_('Send email task created'), category='success')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
370 return redirect(url('admin_settings_email'))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
371
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
372 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
373 defaults.update(self._get_hg_ui_settings())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
374
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
375 import rhodecode
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
376 c.rhodecode_ini = rhodecode.CONFIG
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
377
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
378 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
379 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
380 defaults=defaults,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
381 encoding="UTF-8",
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
382 force_defaults=False)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
383
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
384 @HasPermissionAllDecorator('hg.admin')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
385 def settings_hooks(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
386 """GET /admin/settings/hooks: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
387 # url('admin_settings_hooks')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
388 c.active = 'hooks'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
389 if request.POST:
4045
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
390 if c.visual.allow_custom_hooks_settings:
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
391 ui_key = request.POST.get('new_hook_ui_key')
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
392 ui_value = request.POST.get('new_hook_ui_value')
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
393
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
394 hook_id = request.POST.get('hook_id')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
395
4045
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
396 try:
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
397 if ui_value and ui_key:
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
398 RhodeCodeUi.create_or_update_hook(ui_key, ui_value)
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
399 h.flash(_('Added new hook'), category='success')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
400 elif hook_id:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
401 RhodeCodeUi.delete(hook_id)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
402 Session().commit()
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
403
4045
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
404 # check for edits
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
405 update = False
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
406 _d = request.POST.dict_of_lists()
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
407 for k, v in zip(_d.get('hook_ui_key', []),
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
408 _d.get('hook_ui_value_new', [])):
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
409 RhodeCodeUi.create_or_update_hook(k, v)
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
410 update = True
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
411
4045
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
412 if update:
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
413 h.flash(_('Updated hooks'), category='success')
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
414 Session().commit()
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
415 except Exception:
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
416 log.error(traceback.format_exc())
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
417 h.flash(_('Error occurred during hook creation'),
9b4ba12ef8c3 Add ini option to controll custom advanced hooks settings
Marcin Kuzminski <marcin@python-works.com>
parents: 3960
diff changeset
418 category='error')
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
419
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
420 return redirect(url('admin_settings_hooks'))
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
421
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
422 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
423 defaults.update(self._get_hg_ui_settings())
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
424
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
425 c.hooks = RhodeCodeUi.get_builtin_hooks()
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
426 c.custom_hooks = RhodeCodeUi.get_custom_hooks()
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
427
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
428 return htmlfill.render(
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
429 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
430 defaults=defaults,
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
431 encoding="UTF-8",
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
432 force_defaults=False)
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
433
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
434 @HasPermissionAllDecorator('hg.admin')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
435 def settings_search(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
436 """GET /admin/settings/search: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
437 # url('admin_settings_search')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
438 c.active = 'search'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
439 if request.POST:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
440 repo_location = self._get_hg_ui_settings()['paths_root_path']
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
441 full_index = request.POST.get('full_index', False)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
442 run_task(tasks.whoosh_index, repo_location, full_index)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
443 h.flash(_('Whoosh reindex task scheduled'), category='success')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
444 return redirect(url('admin_settings_search'))
3159
4910b2607a29 fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents: 3154
diff changeset
445
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
446 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
447 defaults.update(self._get_hg_ui_settings())
3159
4910b2607a29 fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents: 3154
diff changeset
448
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
449 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
450 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
451 defaults=defaults,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
452 encoding="UTF-8",
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
453 force_defaults=False)
665
070f32743632 Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents: 661
diff changeset
454
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
455 @HasPermissionAllDecorator('hg.admin')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
456 def settings_system(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
457 """GET /admin/settings/system: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
458 # url('admin_settings_system')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
459 c.active = 'system'
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
460
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
461 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
462 defaults.update(self._get_hg_ui_settings())
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
463
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
464 import rhodecode
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
465 c.rhodecode_ini = rhodecode.CONFIG
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
466 c.rhodecode_update_url = defaults.get('rhodecode_update_url')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
467 server_info = RhodeCodeSetting.get_server_info()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
468 for key, val in server_info.iteritems():
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
469 setattr(c, key, val)
3154
0226b6d6b2b5 Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents: 3145
diff changeset
470
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
471 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
472 render('admin/settings/settings.html'),
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
473 defaults=defaults,
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
474 encoding="UTF-8",
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
475 force_defaults=False)
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
476
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
477 @HasPermissionAllDecorator('hg.admin')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
478 def settings_system_update(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
479 """GET /admin/settings/system/updates: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
480 # url('admin_settings_system_update')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
481 import json
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
482 import urllib2
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
483 from rhodecode.lib.verlib import NormalizedVersion
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
484 from rhodecode import __version__
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
485
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
486 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
487 defaults.update(self._get_hg_ui_settings())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
488 _update_url = defaults.get('rhodecode_update_url', '')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
489
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
490 _err = lambda s: '<div style="color:#ff8888; padding:4px 0px">%s</div>' % (s)
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
491 try:
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
492 import rhodecode
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
493 ver = rhodecode.__version__
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
494 log.debug('Checking for upgrade on `%s` server' % _update_url)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
495 opener = urllib2.build_opener()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
496 opener.addheaders = [('User-agent', 'RhodeCode-SCM/%s' % ver)]
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
497 response = opener.open(_update_url)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
498 response_data = response.read()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
499 data = json.loads(response_data)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
500 except urllib2.URLError, e:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
501 log.error(traceback.format_exc())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
502 return _err('Failed to contact upgrade server: %r' % e)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
503 except ValueError, e:
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
504 log.error(traceback.format_exc())
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
505 return _err('Bad data sent from update server')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
506
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
507 latest = data['versions'][0]
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
508
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
509 c.update_url = _update_url
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
510 c.latest_data = latest
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
511 c.latest_ver = latest['version']
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
512 c.cur_ver = __version__
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
513 c.should_upgrade = False
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
514
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
515 if NormalizedVersion(c.latest_ver) > NormalizedVersion(c.cur_ver):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
516 c.should_upgrade = True
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
517 c.important_notices = latest['general']
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
518
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
519 return render('admin/settings/settings_system_update.html'),
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
520
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
521 @HasPermissionAllDecorator('hg.admin')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
522 def settings_license(self):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
523 """GET /admin/settings/hooks: All items in the collection"""
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
524 # url('admin_settings_license')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
525 c.active = 'license'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
526 if request.POST:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
527 form_result = request.POST
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
528 try:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
529 sett1 = RhodeCodeSetting.create_or_update('license_key',
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
530 form_result['rhodecode_license_key'],
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
531 'unicode')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
532 Session().add(sett1)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
533 Session().commit()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
534 set_rhodecode_config(config)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
535 h.flash(_('Updated license information'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
536 category='success')
3404
7854097b189c Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents: 3389
diff changeset
537
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
538 except Exception:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
539 log.error(traceback.format_exc())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
540 h.flash(_('Error occurred during updating license info'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
541 category='error')
3389
1c4505e3be5b show flags, and desc sort pull request based on created_date ref #765
Marcin Kuzminski <marcin@python-works.com>
parents: 3333
diff changeset
542
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
543 return redirect(url('admin_settings_license'))
3389
1c4505e3be5b show flags, and desc sort pull request based on created_date ref #765
Marcin Kuzminski <marcin@python-works.com>
parents: 3333
diff changeset
544
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
545 defaults = RhodeCodeSetting.get_app_settings()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
546 defaults.update(self._get_hg_ui_settings())
2625
fc19979a8421 Added views for new ajax functions, got somehow lost in previos commit
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
547
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
548 import rhodecode
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
549 c.rhodecode_ini = rhodecode.CONFIG
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
550 c.license_token = c.rhodecode_ini.get('license_token')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
551 c.generated_license_token = LicenseModel.generate_license_token()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
552 c.license_info = {}
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
553 c.license_loaded = False
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
554 # try to read info about license
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
555 try:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
556 license_key = defaults.get('rhodecode_license_key')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
557 if c.license_token and license_key:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
558 c.license_info = json.loads(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
559 LicenseModel(key=c.license_token).decrypt(license_key))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
560 expires = h.fmt_date(h.time_to_datetime(c.license_info['valid_till']))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
561 now = time.time()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
562 if 0 < (c.license_info['valid_till'] - now) < 60*60*24*7:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
563 h.flash(_('Your license will expire on %s, please contact '
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
564 'support to extend your license.' % expires), category='warning')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
565 if c.license_info['valid_till'] - now < 0:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
566 h.flash(_('Your license has expired on %s, please contact '
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
567 'support to extend your license.' % expires), category='error')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
568 c.license_loaded = True
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
569 except Exception, e:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
570 log.error(traceback.format_exc())
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
571 h.flash(_('Unexpected error while reading license key. Please '
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
572 'make sure your license token and key are correct'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
573 category='error')
756
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
574
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
575 return htmlfill.render(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
576 render('admin/settings/settings.html'),
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
577 defaults=defaults,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
578 encoding="UTF-8",
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4090
diff changeset
579 force_defaults=False)