annotate rhodecode/controllers/admin/settings.py @ 2223:528f987f2459 beta

fix ordering of system packages info
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 03 May 2012 00:17:17 +0200
parents 17ff5693566b
children a437a986d399 ef71d7e63806
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 -*-
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
2 """
860
5f7731e3ab4d fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents: 832
diff changeset
3 rhodecode.controllers.admin.settings
5f7731e3ab4d fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents: 832
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1164
diff changeset
5
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
6 settings controller for rhodecode admin
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1164
diff changeset
7
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
8 :created_on: Jul 14, 2010
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
9 :author: marcink
1824
89efedac4e6c 2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents: 1798
diff changeset
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
11 :license: GPLv3, see COPYING for more details.
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
12 """
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
13 # 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
14 # 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
15 # 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
16 # (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
17 #
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 # 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
19 # 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
20 # 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
21 # 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
22 #
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 # 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
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
25
890
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
26 import logging
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
27 import traceback
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
28 import formencode
2192
a801c4542f48 added useful system info + packages to settings page.
Marcin Kuzminski <marcin@python-works.com>
parents: 2086
diff changeset
29 import pkg_resources
a801c4542f48 added useful system info + packages to settings page.
Marcin Kuzminski <marcin@python-works.com>
parents: 2086
diff changeset
30 import platform
890
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
31
1022
4f834b0abcd3 Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
32 from sqlalchemy import func
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 from formencode import htmlfill
1036
405b80e4ccd5 Major refactoring, removed when possible calls to app globals.
Marcin Kuzminski <marcin@python-works.com>
parents: 1027
diff changeset
34 from pylons import request, session, tmpl_context as c, url, config
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 from pylons.controllers.util import abort, redirect
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 from pylons.i18n.translation import _
890
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
37
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
38 from rhodecode.lib import helpers as h
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
39 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
40 HasPermissionAnyDecorator, NotAnonymous
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
41 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
42 from rhodecode.lib.celerylib import tasks, run_task
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
43 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
1027
6ba61c252ee4 fixed missing repo_name_slug
Marcin Kuzminski <marcin@python-works.com>
parents: 1022
diff changeset
44 set_rhodecode_config, repo_name_slug
1633
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1547
diff changeset
45 from rhodecode.model.db import RhodeCodeUi, Repository, RepoGroup, \
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1547
diff changeset
46 RhodeCodeSetting
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
47 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
48 ApplicationUiSettingsForm
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 687
diff changeset
49 from rhodecode.model.scm import ScmModel
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
50 from rhodecode.model.user import UserModel
1501
a828b83dfa4b Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents: 1460
diff changeset
51 from rhodecode.model.db import User
1718
f78bee8eec78 reduce cookie size for better support of client side sessions
Marcin Kuzminski <marcin@python-works.com>
parents: 1717
diff changeset
52 from rhodecode.model.notification import EmailNotificationModel
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
53 from rhodecode.model.meta import Session
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
54
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 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
56
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 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
59 """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
60 # 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
61 # 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
62 # 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
63 # 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
64
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 @LoginRequired()
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 def __before__(self):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 c.admin_user = session.get('admin_user')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 c.admin_username = session.get('admin_username')
2207
17ff5693566b white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2192
diff changeset
69 c.modules = sorted([(p.project_name, p.version)
2223
528f987f2459 fix ordering of system packages info
Marcin Kuzminski <marcin@python-works.com>
parents: 2207
diff changeset
70 for p in pkg_resources.working_set],
528f987f2459 fix ordering of system packages info
Marcin Kuzminski <marcin@python-works.com>
parents: 2207
diff changeset
71 key=lambda k: k[0].lower())
2192
a801c4542f48 added useful system info + packages to settings page.
Marcin Kuzminski <marcin@python-works.com>
parents: 2086
diff changeset
72 c.py_version = platform.python_version()
2207
17ff5693566b white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2192
diff changeset
73 c.platform = platform.platform()
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 super(SettingsController, self).__before__()
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
75
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
76 @HasPermissionAllDecorator('hg.admin')
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 def index(self, format='html'):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 """GET /admin/settings: All items in the collection"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 # url('admin_settings')
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
80
1633
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1547
diff changeset
81 defaults = RhodeCodeSetting.get_app_settings()
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
82 defaults.update(self.get_hg_ui_settings())
2192
a801c4542f48 added useful system info + packages to settings page.
Marcin Kuzminski <marcin@python-works.com>
parents: 2086
diff changeset
83
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
84 return htmlfill.render(
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
85 render('admin/settings/settings.html'),
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
86 defaults=defaults,
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
87 encoding="UTF-8",
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
88 force_defaults=False
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
89 )
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
90
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
91 @HasPermissionAllDecorator('hg.admin')
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92 def create(self):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 """POST /admin/settings: Create a new item"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94 # url('admin_settings')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
95
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
96 @HasPermissionAllDecorator('hg.admin')
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 def new(self, format='html'):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
98 """GET /admin/settings/new: Form to create a new item"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
99 # url('admin_new_setting')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
100
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
101 @HasPermissionAllDecorator('hg.admin')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
102 def update(self, setting_id):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
103 """PUT /admin/settings/setting_id: Update an existing item"""
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104 # Forms posted to this method should contain a hidden field:
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105 # <input type="hidden" name="_method" value="PUT" />
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
106 # Or using helpers:
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
107 # h.form(url('admin_setting', setting_id=ID),
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108 # method='put')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
109 # url('admin_setting', setting_id=ID)
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
110 if setting_id == 'mapping':
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
111 rm_obsolete = request.POST.get('destroy', False)
1976
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
112 log.debug('Rescanning directories with destroy=%s' % rm_obsolete)
1036
405b80e4ccd5 Major refactoring, removed when possible calls to app globals.
Marcin Kuzminski <marcin@python-works.com>
parents: 1027
diff changeset
113 initial = ScmModel().repo_scan()
1039
51b70569c330 extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents: 1036
diff changeset
114 log.debug('invalidating all repositories')
665
070f32743632 Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents: 661
diff changeset
115 for repo_name in initial.keys():
070f32743632 Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents: 661
diff changeset
116 invalidate_cache('get_repo_cached_%s' % repo_name)
070f32743632 Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents: 661
diff changeset
117
1039
51b70569c330 extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents: 1036
diff changeset
118 added, removed = repo2db_mapper(initial, rm_obsolete)
665
070f32743632 Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents: 661
diff changeset
119
1039
51b70569c330 extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents: 1036
diff changeset
120 h.flash(_('Repositories successfully'
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
121 ' rescanned added: %s,removed: %s') % (added, removed),
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
122 category='success')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
123
467
3fc3ce53659b starting celery branch
Marcin Kuzminski <marcin@python-works.com>
parents: 446
diff changeset
124 if setting_id == 'whoosh':
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
125 repo_location = self.get_hg_ui_settings()['paths_root_path']
489
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
126 full_index = request.POST.get('full_index', False)
1164
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
127 run_task(tasks.whoosh_index, repo_location, full_index)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
128
467
3fc3ce53659b starting celery branch
Marcin Kuzminski <marcin@python-works.com>
parents: 446
diff changeset
129 h.flash(_('Whoosh reindex task scheduled'), category='success')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
130 if setting_id == 'global':
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
131
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
132 application_form = ApplicationSettingsForm()()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
133 try:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
134 form_result = application_form.to_python(dict(request.POST))
890
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
135
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
136 try:
1633
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1547
diff changeset
137 hgsettings1 = RhodeCodeSetting.get_by_name('title')
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
138 hgsettings1.app_settings_value = \
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
139 form_result['rhodecode_title']
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
140
1633
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1547
diff changeset
141 hgsettings2 = RhodeCodeSetting.get_by_name('realm')
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
142 hgsettings2.app_settings_value = \
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
143 form_result['rhodecode_realm']
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
144
1633
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1547
diff changeset
145 hgsettings3 = RhodeCodeSetting.get_by_name('ga_code')
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
146 hgsettings3.app_settings_value = \
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
147 form_result['rhodecode_ga_code']
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
148
381
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 380
diff changeset
149 self.sa.add(hgsettings1)
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 380
diff changeset
150 self.sa.add(hgsettings2)
890
042d38683d42 implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents: 860
diff changeset
151 self.sa.add(hgsettings3)
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
152 self.sa.commit()
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
153 set_rhodecode_config(config)
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
154 h.flash(_('Updated application settings'),
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
155 category='success')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
156
1164
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
157 except Exception:
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
158 log.error(traceback.format_exc())
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
159 h.flash(_('error occurred during updating '
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
160 'application settings'),
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
161 category='error')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
162
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
163 self.sa.rollback()
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
164
564
ba7e24cd4786 refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 549
diff changeset
165 except formencode.Invalid, errors:
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
166 return htmlfill.render(
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
167 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
168 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
169 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
170 prefix_error=False,
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
171 encoding="UTF-8")
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
172
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
173 if setting_id == 'mercurial':
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
174 application_form = ApplicationUiSettingsForm()()
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
175 try:
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
176 form_result = application_form.to_python(dict(request.POST))
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
177
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
178 try:
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
179
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
180 hgsettings1 = self.sa.query(RhodeCodeUi)\
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
181 .filter(RhodeCodeUi.ui_key == 'push_ssl').one()
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
182 hgsettings1.ui_value = form_result['web_push_ssl']
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
183
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
184 hgsettings2 = self.sa.query(RhodeCodeUi)\
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
185 .filter(RhodeCodeUi.ui_key == '/').one()
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
186 hgsettings2.ui_value = form_result['paths_root_path']
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
187
395
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
188 #HOOKS
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
189 hgsettings3 = self.sa.query(RhodeCodeUi)\
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
190 .filter(RhodeCodeUi.ui_key == 'changegroup.update').one()
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
191 hgsettings3.ui_active = \
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
192 bool(form_result['hooks_changegroup_update'])
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
193
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
194 hgsettings4 = self.sa.query(RhodeCodeUi)\
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
195 .filter(RhodeCodeUi.ui_key ==
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
196 'changegroup.repo_size').one()
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
197 hgsettings4.ui_active = \
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
198 bool(form_result['hooks_changegroup_repo_size'])
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
199
661
673de12e6bf6 added option to enable/disable of logger hooks from admin panel.
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
200 hgsettings5 = self.sa.query(RhodeCodeUi)\
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
201 .filter(RhodeCodeUi.ui_key ==
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
202 'pretxnchangegroup.push_logger').one()
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
203 hgsettings5.ui_active = \
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
204 bool(form_result['hooks_pretxnchangegroup'
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
205 '_push_logger'])
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
206
661
673de12e6bf6 added option to enable/disable of logger hooks from admin panel.
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
207 hgsettings6 = self.sa.query(RhodeCodeUi)\
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
208 .filter(RhodeCodeUi.ui_key ==
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
209 'preoutgoing.pull_logger').one()
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
210 hgsettings6.ui_active = \
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
211 bool(form_result['hooks_preoutgoing_pull_logger'])
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
212
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
213 self.sa.add(hgsettings1)
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
214 self.sa.add(hgsettings2)
395
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
215 self.sa.add(hgsettings3)
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
216 self.sa.add(hgsettings4)
661
673de12e6bf6 added option to enable/disable of logger hooks from admin panel.
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
217 self.sa.add(hgsettings5)
673de12e6bf6 added option to enable/disable of logger hooks from admin panel.
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
218 self.sa.add(hgsettings6)
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
219 self.sa.commit()
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
220
396
9416269860c9 little css update, and flash messages
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
221 h.flash(_('Updated mercurial settings'),
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
222 category='success')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
223
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
224 except:
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
225 log.error(traceback.format_exc())
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
226 h.flash(_('error occurred during updating '
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
227 'application settings'), category='error')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
228
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
229 self.sa.rollback()
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
230
564
ba7e24cd4786 refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 549
diff changeset
231 except formencode.Invalid, errors:
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
232 return htmlfill.render(
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
233 render('admin/settings/settings.html'),
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
234 defaults=errors.value,
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
235 errors=errors.error_dict or {},
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
236 prefix_error=False,
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
237 encoding="UTF-8")
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
238
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
239 if setting_id == 'hooks':
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
240 ui_key = request.POST.get('new_hook_ui_key')
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
241 ui_value = request.POST.get('new_hook_ui_value')
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
242 try:
1673
333b3e7c991f Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
243
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
244 if ui_value and ui_key:
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
245 RhodeCodeUi.create_or_update_hook(ui_key, ui_value)
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
246 h.flash(_('Added new hook'),
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
247 category='success')
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
248
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
249 # check for edits
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
250 update = False
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
251 _d = request.POST.dict_of_lists()
1798
2ee93fba129e fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
252 for k, v in zip(_d.get('hook_ui_key', []),
2ee93fba129e fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
253 _d.get('hook_ui_value_new', [])):
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
254 RhodeCodeUi.create_or_update_hook(k, v)
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
255 update = True
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
256
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
257 if update:
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
258 h.flash(_('Updated hooks'), category='success')
2086
eefb197bdd95 fixed missing commit after hook delete
Marcin Kuzminski <marcin@python-works.com>
parents: 1976
diff changeset
259 self.sa.commit()
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
260 except:
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
261 log.error(traceback.format_exc())
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
262 h.flash(_('error occurred during hook creation'),
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
263 category='error')
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
264
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
265 return redirect(url('admin_edit_setting', setting_id='hooks'))
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
266
1673
333b3e7c991f Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
267 if setting_id == 'email':
333b3e7c991f Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
268 test_email = request.POST.get('test_email')
333b3e7c991f Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
269 test_email_subj = 'RhodeCode TestEmail'
333b3e7c991f Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
270 test_email_body = 'RhodeCode Email test'
1798
2ee93fba129e fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
271
1717
7ff304d3028f Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1712
diff changeset
272 test_email_html_body = EmailNotificationModel()\
1798
2ee93fba129e fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
273 .get_email_tmpl(EmailNotificationModel.TYPE_DEFAULT,
2ee93fba129e fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
274 body=test_email_body)
1673
333b3e7c991f Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
275
1798
2ee93fba129e fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
276 recipients = [test_email] if [test_email] else None
2ee93fba129e fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
277
2ee93fba129e fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
278 run_task(tasks.send_email, recipients, test_email_subj,
1717
7ff304d3028f Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1712
diff changeset
279 test_email_body, test_email_html_body)
7ff304d3028f Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1712
diff changeset
280
1673
333b3e7c991f Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
281 h.flash(_('Email task created'), category='success')
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
282 return redirect(url('admin_settings'))
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
283
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
284 @HasPermissionAllDecorator('hg.admin')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
285 def delete(self, setting_id):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
286 """DELETE /admin/settings/setting_id: Delete an existing item"""
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
287 # Forms posted to this method should contain a hidden field:
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
288 # <input type="hidden" name="_method" value="DELETE" />
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
289 # Or using helpers:
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
290 # h.form(url('admin_setting', setting_id=ID),
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
291 # method='delete')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
292 # url('admin_setting', setting_id=ID)
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
293 if setting_id == 'hooks':
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
294 hook_id = request.POST.get('hook_id')
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
295 RhodeCodeUi.delete(hook_id)
2086
eefb197bdd95 fixed missing commit after hook delete
Marcin Kuzminski <marcin@python-works.com>
parents: 1976
diff changeset
296 self.sa.commit()
1673
333b3e7c991f Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
297
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
298 @HasPermissionAllDecorator('hg.admin')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
299 def show(self, setting_id, format='html'):
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
300 """
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
301 GET /admin/settings/setting_id: Show a specific item"""
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
302 # url('admin_setting', setting_id=ID)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
303
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
304 @HasPermissionAllDecorator('hg.admin')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
305 def edit(self, setting_id, format='html'):
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
306 """
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
307 GET /admin/settings/setting_id/edit: Form to
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
308 edit an existing item"""
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
309 # url('admin_edit_setting', setting_id=ID)
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
310
1460
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
311 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
312 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
313
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
314 return htmlfill.render(
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
315 render('admin/settings/hooks.html'),
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
316 defaults={},
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
317 encoding="UTF-8",
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
318 force_defaults=False
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
319 )
b50348816a80 Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
320
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
321 @NotAnonymous()
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
322 def my_account(self):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
323 """
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1164
diff changeset
324 GET /_admin/my_account Displays info about my account
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
325 """
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
326 # url('admin_settings_my_account')
665
070f32743632 Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents: 661
diff changeset
327
1501
a828b83dfa4b Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents: 1460
diff changeset
328 c.user = User.get(self.rhodecode_user.user_id)
1366
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
329 all_repos = self.sa.query(Repository)\
1045
3fc9183e05dd another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents: 1039
diff changeset
330 .filter(Repository.user_id == c.user.user_id)\
1366
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
331 .order_by(func.lower(Repository.repo_name)).all()
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
332
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 687
diff changeset
333 c.user_repos = ScmModel().get_repos(all_repos)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
334
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
335 if c.user.username == 'default':
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
336 h.flash(_("You can't edit this user since it's"
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
337 " crucial for entire application"), category='warning')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
338 return redirect(url('users'))
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
339
832
634596f81cfd new improved models with helper functions for easier data fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 829
diff changeset
340 defaults = c.user.get_dict()
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
341 return htmlfill.render(
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
342 render('admin/users/user_edit_my_account.html'),
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
343 defaults=defaults,
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
344 encoding="UTF-8",
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
345 force_defaults=False
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
346 )
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
347
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
348 def my_account_update(self):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
349 """PUT /_admin/my_account_update: Update an existing item"""
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
350 # Forms posted to this method should contain a hidden field:
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
351 # <input type="hidden" name="_method" value="PUT" />
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
352 # Or using helpers:
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
353 # h.form(url('admin_settings_my_account_update'),
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
354 # method='put')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
355 # url('admin_settings_my_account_update', id=ID)
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
356 user_model = UserModel()
1121
f3f847712f87 replaced all global calls to template context (rhodecode_user), into instance attributes
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
357 uid = self.rhodecode_user.user_id
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
358 _form = UserForm(edit=True,
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
359 old_data={'user_id': uid,
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
360 'email': self.rhodecode_user.email})()
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
361 form_result = {}
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
362 try:
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
363 form_result = _form.to_python(dict(request.POST))
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
364 user_model.update_my_account(uid, form_result)
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
365 h.flash(_('Your account was updated successfully'),
396
9416269860c9 little css update, and flash messages
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
366 category='success')
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
367 Session.commit()
564
ba7e24cd4786 refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 549
diff changeset
368 except formencode.Invalid, errors:
1501
a828b83dfa4b Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents: 1460
diff changeset
369 c.user = User.get(self.rhodecode_user.user_id)
687
b9442a8b5e02 fixed admin settings form resubmition bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 673
diff changeset
370 all_repos = self.sa.query(Repository)\
b9442a8b5e02 fixed admin settings form resubmition bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 673
diff changeset
371 .filter(Repository.user_id == c.user.user_id)\
b9442a8b5e02 fixed admin settings form resubmition bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 673
diff changeset
372 .order_by(func.lower(Repository.repo_name))\
b9442a8b5e02 fixed admin settings form resubmition bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 673
diff changeset
373 .all()
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 687
diff changeset
374 c.user_repos = ScmModel().get_repos(all_repos)
687
b9442a8b5e02 fixed admin settings form resubmition bug.
Marcin Kuzminski <marcin@python-works.com>
parents: 673
diff changeset
375
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
376 return htmlfill.render(
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
377 render('admin/users/user_edit_my_account.html'),
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
378 defaults=errors.value,
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
379 errors=errors.error_dict or {},
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
380 prefix_error=False,
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
381 encoding="UTF-8")
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
382 except Exception:
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
383 log.error(traceback.format_exc())
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
384 h.flash(_('error occurred during update of user %s') \
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
385 % form_result.get('username'), category='error')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
386
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
387 return redirect(url('my_account'))
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
388
779
389d02a5df52 Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents: 765
diff changeset
389 @NotAnonymous()
417
3ed2d46a2ca7 permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents: 396
diff changeset
390 @HasPermissionAnyDecorator('hg.admin', 'hg.create.repository')
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
391 def create_repository(self):
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
392 """GET /_admin/create_repository: Form to create a new item"""
1161
f3c25bbd9148 added proper groups names in add repo from settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
393
1633
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1547
diff changeset
394 c.repo_groups = RepoGroup.groups_choices()
1161
f3c25bbd9148 added proper groups names in add repo from settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
395 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
f3c25bbd9148 added proper groups names in add repo from settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
396
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
397 new_repo = request.GET.get('repo', '')
1022
4f834b0abcd3 Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents: 902
diff changeset
398 c.new_repo = repo_name_slug(new_repo)
1161
f3c25bbd9148 added proper groups names in add repo from settings
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
399
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
400 return render('admin/repos/repo_add_create_repository.html')
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
401
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
402 def get_hg_ui_settings(self):
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
403 ret = self.sa.query(RhodeCodeUi).all()
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
404
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
405 if not ret:
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
406 raise Exception('Could not get application ui settings !')
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
407 settings = {}
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
408 for each in ret:
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
409 k = each.ui_key
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
410 v = each.ui_value
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
411 if k == '/':
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
412 k = 'root_path'
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
413
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
414 if k.find('.') != -1:
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
415 k = k.replace('.', '_')
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
416
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
417 if each.ui_section == 'hooks':
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
418 v = each.ui_active
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
419
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
420 settings[each.ui_section + '_' + k] = v
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
421
01be209b9828 project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents: 709
diff changeset
422 return settings