comparison pylons_app/controllers/admin/settings.py @ 489:460ad816820d celery

fixed bug when new repo had no last commiter, fixed bug when my_account updating information failed, by not uniq email address.
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 20 Sep 2010 22:47:20 +0200
parents 6b934c9607e7
children 48be953851fc
comparison
equal deleted inserted replaced
488:853b9425742a 489:460ad816820d
36 from pylons_app.model.db import User, UserLog, HgAppSettings, HgAppUi 36 from pylons_app.model.db import User, UserLog, HgAppSettings, HgAppUi
37 from pylons_app.model.forms import UserForm, ApplicationSettingsForm, \ 37 from pylons_app.model.forms import UserForm, ApplicationSettingsForm, \
38 ApplicationUiSettingsForm 38 ApplicationUiSettingsForm
39 from pylons_app.model.hg_model import HgModel 39 from pylons_app.model.hg_model import HgModel
40 from pylons_app.model.user_model import UserModel 40 from pylons_app.model.user_model import UserModel
41 from pylons_app.lib.celerylib import tasks,run_task 41 from pylons_app.lib.celerylib import tasks, run_task
42 import formencode 42 import formencode
43 import logging 43 import logging
44 import traceback 44 import traceback
45 45
46 log = logging.getLogger(__name__) 46 log = logging.getLogger(__name__)
103 invalidate_cache('cached_repo_list') 103 invalidate_cache('cached_repo_list')
104 h.flash(_('Repositories sucessfully rescanned'), category='success') 104 h.flash(_('Repositories sucessfully rescanned'), category='success')
105 105
106 if setting_id == 'whoosh': 106 if setting_id == 'whoosh':
107 repo_location = get_hg_ui_settings()['paths_root_path'] 107 repo_location = get_hg_ui_settings()['paths_root_path']
108 full_index = request.POST.get('full_index',False) 108 full_index = request.POST.get('full_index', False)
109 task = run_task(tasks.whoosh_index,repo_location,full_index) 109 task = run_task(tasks.whoosh_index, repo_location, full_index)
110 110
111 h.flash(_('Whoosh reindex task scheduled'), category='success') 111 h.flash(_('Whoosh reindex task scheduled'), category='success')
112 if setting_id == 'global': 112 if setting_id == 'global':
113 113
114 application_form = ApplicationSettingsForm()() 114 application_form = ApplicationSettingsForm()()
258 # h.form(url('admin_settings_my_account_update'), 258 # h.form(url('admin_settings_my_account_update'),
259 # method='put') 259 # method='put')
260 # url('admin_settings_my_account_update', id=ID) 260 # url('admin_settings_my_account_update', id=ID)
261 user_model = UserModel() 261 user_model = UserModel()
262 uid = c.hg_app_user.user_id 262 uid = c.hg_app_user.user_id
263 _form = UserForm(edit=True, old_data={'user_id':uid})() 263 _form = UserForm(edit=True, old_data={'user_id':uid,
264 'email':c.hg_app_user.email})()
264 form_result = {} 265 form_result = {}
265 try: 266 try:
266 form_result = _form.to_python(dict(request.POST)) 267 form_result = _form.to_python(dict(request.POST))
267 user_model.update_my_account(uid, form_result) 268 user_model.update_my_account(uid, form_result)
268 h.flash(_('Your account was updated succesfully'), 269 h.flash(_('Your account was updated succesfully'),
269 category='success') 270 category='success')
270 271
271 except formencode.Invalid as errors: 272 except formencode.Invalid as errors:
272 #c.user = self.sa.query(User).get(c.hg_app_user.user_id) 273 c.user = self.sa.query(User).get(c.hg_app_user.user_id)
274 c.user_repos = []
275 for repo in c.cached_repo_list.values():
276 if repo.dbrepo.user.username == c.user.username:
277 c.user_repos.append(repo)
273 return htmlfill.render( 278 return htmlfill.render(
274 render('admin/users/user_edit_my_account.html'), 279 render('admin/users/user_edit_my_account.html'),
275 defaults=errors.value, 280 defaults=errors.value,
276 errors=errors.error_dict or {}, 281 errors=errors.error_dict or {},
277 prefix_error=False, 282 prefix_error=False,