comparison pylons_app/controllers/admin/settings.py @ 359:339d1368c10d

new style error display for settings, added flash msg for repo rescan
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 24 Jul 2010 00:51:57 +0200
parents 664a5b8c551a
children 5cd6616b8673
comparison
equal deleted inserted replaced
358:23e720be5f44 359:339d1368c10d
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # encoding: utf-8 2 # encoding: utf-8
3 # settings controller for pylons 3 # settings controller for pylons
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5 5 #
6 # This program is free software; you can redistribute it and/or 6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License 7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2 8 # as published by the Free Software Foundation; version 2
9 # of the License or (at your opinion) any later version of the license. 9 # of the License or (at your opinion) any later version of the license.
10 # 10 #
92 log.debug('Rescanning directories with destroy=%s', rm_obsolete) 92 log.debug('Rescanning directories with destroy=%s', rm_obsolete)
93 93
94 initial = HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui) 94 initial = HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui)
95 repo2db_mapper(initial, rm_obsolete) 95 repo2db_mapper(initial, rm_obsolete)
96 invalidate_cache('cached_repo_list') 96 invalidate_cache('cached_repo_list')
97 h.flash(_('Repositories sucessfully rescanned'), category='success')
97 98
98 if id == 'global': 99 if id == 'global':
99 100
100 application_form = ApplicationSettingsForm()() 101 application_form = ApplicationSettingsForm()()
101 try: 102 try:
121 122
122 self.sa.rollback() 123 self.sa.rollback()
123 124
124 125
125 except formencode.Invalid as errors: 126 except formencode.Invalid as errors:
126 c.form_errors = errors.error_dict
127 return htmlfill.render( 127 return htmlfill.render(
128 render('admin/settings/settings.html'), 128 render('admin/settings/settings.html'),
129 defaults=errors.value, 129 defaults=errors.value,
130 encoding="UTF-8") 130 errors=errors.error_dict or {},
131 prefix_error=False,
132 encoding="UTF-8")
131 133
132
133
134
135
136
137
138 return redirect(url('admin_settings')) 134 return redirect(url('admin_settings'))
139
140
141
142
143 135
144 def delete(self, id): 136 def delete(self, id):
145 """DELETE /admin/settings/id: Delete an existing item""" 137 """DELETE /admin/settings/id: Delete an existing item"""
146 # Forms posted to this method should contain a hidden field: 138 # Forms posted to this method should contain a hidden field:
147 # <input type="hidden" name="_method" value="DELETE" /> 139 # <input type="hidden" name="_method" value="DELETE" />