comparison rhodecode/controllers/admin/settings.py @ 756:01be209b9828 beta

project refactoring, cleaned up lib.utils from rarly used functions, and place them in proper controllers moves is_git is_hg functions to the middleware classes
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 25 Nov 2010 01:57:37 +0100
parents a23b686fb14d
children d92fc9b5e6f9
comparison
equal deleted inserted replaced
755:99ece4c484e1 756:01be209b9828
31 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \ 31 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
32 HasPermissionAnyDecorator 32 HasPermissionAnyDecorator
33 from rhodecode.lib.base import BaseController, render 33 from rhodecode.lib.base import BaseController, render
34 from rhodecode.lib.celerylib import tasks, run_task 34 from rhodecode.lib.celerylib import tasks, run_task
35 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \ 35 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
36 set_rhodecode_config, get_hg_settings, get_hg_ui_settings 36 set_rhodecode_config
37 from rhodecode.model.db import RhodeCodeUi, Repository 37 from rhodecode.model.db import RhodeCodeUi, Repository
38 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \ 38 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
39 ApplicationUiSettingsForm 39 ApplicationUiSettingsForm
40 from rhodecode.model.scm import ScmModel 40 from rhodecode.model.scm import ScmModel
41 from rhodecode.model.settings import SettingsModel 41 from rhodecode.model.settings import SettingsModel
66 @HasPermissionAllDecorator('hg.admin') 66 @HasPermissionAllDecorator('hg.admin')
67 def index(self, format='html'): 67 def index(self, format='html'):
68 """GET /admin/settings: All items in the collection""" 68 """GET /admin/settings: All items in the collection"""
69 # url('admin_settings') 69 # url('admin_settings')
70 70
71 defaults = get_hg_settings() 71 defaults = SettingsModel().get_app_settings()
72 defaults.update(get_hg_ui_settings()) 72 defaults.update(self.get_hg_ui_settings())
73 return htmlfill.render( 73 return htmlfill.render(
74 render('admin/settings/settings.html'), 74 render('admin/settings/settings.html'),
75 defaults=defaults, 75 defaults=defaults,
76 encoding="UTF-8", 76 encoding="UTF-8",
77 force_defaults=False 77 force_defaults=False
107 repo2db_mapper(initial, rm_obsolete) 107 repo2db_mapper(initial, rm_obsolete)
108 108
109 h.flash(_('Repositories successfully rescanned'), category='success') 109 h.flash(_('Repositories successfully rescanned'), category='success')
110 110
111 if setting_id == 'whoosh': 111 if setting_id == 'whoosh':
112 repo_location = get_hg_ui_settings()['paths_root_path'] 112 repo_location = self.get_hg_ui_settings()['paths_root_path']
113 full_index = request.POST.get('full_index', False) 113 full_index = request.POST.get('full_index', False)
114 task = run_task(tasks.whoosh_index, repo_location, full_index) 114 task = run_task(tasks.whoosh_index, repo_location, full_index)
115 115
116 h.flash(_('Whoosh reindex task scheduled'), category='success') 116 h.flash(_('Whoosh reindex task scheduled'), category='success')
117 if setting_id == 'global': 117 if setting_id == 'global':
310 new_repo = request.GET.get('repo', '') 310 new_repo = request.GET.get('repo', '')
311 c.new_repo = h.repo_name_slug(new_repo) 311 c.new_repo = h.repo_name_slug(new_repo)
312 312
313 return render('admin/repos/repo_add_create_repository.html') 313 return render('admin/repos/repo_add_create_repository.html')
314 314
315 def get_hg_ui_settings(self):
316 ret = self.sa.query(RhodeCodeUi).all()
317
318 if not ret:
319 raise Exception('Could not get application ui settings !')
320 settings = {}
321 for each in ret:
322 k = each.ui_key
323 v = each.ui_value
324 if k == '/':
325 k = 'root_path'
326
327 if k.find('.') != -1:
328 k = k.replace('.', '_')
329
330 if each.ui_section == 'hooks':
331 v = each.ui_active
332
333 settings[each.ui_section + '_' + k] = v
334
335 return settings