##// END OF EJS Templates
forms: fixed error handling in forms
super-admin -
r5018:b9966616 default
parent child Browse files
Show More
@@ -89,7 +89,7 b' class AdminDefaultSettingsView(BaseAppVi'
89 html = formencode.htmlfill.render(
89 html = formencode.htmlfill.render(
90 data,
90 data,
91 defaults=errors.value,
91 defaults=errors.value,
92 errors=errors.error_dict or {},
92 errors=errors.unpack_errors() or {},
93 prefix_error=False,
93 prefix_error=False,
94 encoding="UTF-8",
94 encoding="UTF-8",
95 force_defaults=False
95 force_defaults=False
@@ -123,7 +123,7 b' class AdminPermissionsView(BaseAppView, '
123 html = formencode.htmlfill.render(
123 html = formencode.htmlfill.render(
124 data,
124 data,
125 defaults=defaults,
125 defaults=defaults,
126 errors=errors.error_dict or {},
126 errors=errors.unpack_errors() or {},
127 prefix_error=False,
127 prefix_error=False,
128 encoding="UTF-8",
128 encoding="UTF-8",
129 force_defaults=False
129 force_defaults=False
@@ -194,7 +194,7 b' class AdminPermissionsView(BaseAppView, '
194 html = formencode.htmlfill.render(
194 html = formencode.htmlfill.render(
195 data,
195 data,
196 defaults=defaults,
196 defaults=defaults,
197 errors=errors.error_dict or {},
197 errors=errors.unpack_errors() or {},
198 prefix_error=False,
198 prefix_error=False,
199 encoding="UTF-8",
199 encoding="UTF-8",
200 force_defaults=False
200 force_defaults=False
@@ -287,7 +287,7 b' class AdminPermissionsView(BaseAppView, '
287 html = formencode.htmlfill.render(
287 html = formencode.htmlfill.render(
288 data,
288 data,
289 defaults=defaults,
289 defaults=defaults,
290 errors=errors.error_dict or {},
290 errors=errors.unpack_errors() or {},
291 prefix_error=False,
291 prefix_error=False,
292 encoding="UTF-8",
292 encoding="UTF-8",
293 force_defaults=False
293 force_defaults=False
@@ -337,7 +337,7 b' class AdminRepoGroupsView(BaseAppView, D'
337 html = formencode.htmlfill.render(
337 html = formencode.htmlfill.render(
338 data,
338 data,
339 defaults=errors.value,
339 defaults=errors.value,
340 errors=errors.error_dict or {},
340 errors=errors.unpack_errors() or {},
341 prefix_error=False,
341 prefix_error=False,
342 encoding="UTF-8",
342 encoding="UTF-8",
343 force_defaults=False
343 force_defaults=False
@@ -228,7 +228,7 b' class AdminReposView(BaseAppView, DataGr'
228 html = formencode.htmlfill.render(
228 html = formencode.htmlfill.render(
229 data,
229 data,
230 defaults=errors.value,
230 defaults=errors.value,
231 errors=errors.error_dict or {},
231 errors=errors.unpack_errors() or {},
232 prefix_error=False,
232 prefix_error=False,
233 encoding="UTF-8",
233 encoding="UTF-8",
234 force_defaults=False
234 force_defaults=False
@@ -160,7 +160,7 b' class AdminSettingsView(BaseAppView):'
160 html = formencode.htmlfill.render(
160 html = formencode.htmlfill.render(
161 data,
161 data,
162 defaults=errors.value,
162 defaults=errors.value,
163 errors=errors.error_dict or {},
163 errors=errors.unpack_errors() or {},
164 prefix_error=False,
164 prefix_error=False,
165 encoding="UTF-8",
165 encoding="UTF-8",
166 force_defaults=False
166 force_defaults=False
@@ -295,7 +295,7 b' class AdminSettingsView(BaseAppView):'
295 html = formencode.htmlfill.render(
295 html = formencode.htmlfill.render(
296 data,
296 data,
297 defaults=errors.value,
297 defaults=errors.value,
298 errors=errors.error_dict or {},
298 errors=errors.unpack_errors() or {},
299 prefix_error=False,
299 prefix_error=False,
300 encoding="UTF-8",
300 encoding="UTF-8",
301 force_defaults=False
301 force_defaults=False
@@ -364,7 +364,7 b' class AdminSettingsView(BaseAppView):'
364 html = formencode.htmlfill.render(
364 html = formencode.htmlfill.render(
365 data,
365 data,
366 defaults=errors.value,
366 defaults=errors.value,
367 errors=errors.error_dict or {},
367 errors=errors.unpack_errors() or {},
368 prefix_error=False,
368 prefix_error=False,
369 encoding="UTF-8",
369 encoding="UTF-8",
370 force_defaults=False
370 force_defaults=False
@@ -668,7 +668,7 b' class AdminSettingsView(BaseAppView):'
668 html = formencode.htmlfill.render(
668 html = formencode.htmlfill.render(
669 data,
669 data,
670 defaults=errors.value,
670 defaults=errors.value,
671 errors=errors.error_dict or {},
671 errors=errors.unpack_errors() or {},
672 prefix_error=False,
672 prefix_error=False,
673 encoding="UTF-8",
673 encoding="UTF-8",
674 force_defaults=False
674 force_defaults=False
@@ -234,7 +234,7 b' class AdminUserGroupsView(BaseAppView, D'
234 html = formencode.htmlfill.render(
234 html = formencode.htmlfill.render(
235 data,
235 data,
236 defaults=errors.value,
236 defaults=errors.value,
237 errors=errors.error_dict or {},
237 errors=errors.unpack_errors() or {},
238 prefix_error=False,
238 prefix_error=False,
239 encoding="UTF-8",
239 encoding="UTF-8",
240 force_defaults=False
240 force_defaults=False
@@ -106,7 +106,7 b' class AdminUsersView(BaseAppView, DataGr'
106 base_inactive_q = base_q.filter(User.active != true())
106 base_inactive_q = base_q.filter(User.active != true())
107
107
108 if search_q:
108 if search_q:
109 like_expression = u'%{}%'.format(safe_unicode(search_q))
109 like_expression = '%{}%'.format(safe_unicode(search_q))
110 base_q = base_q.filter(or_(
110 base_q = base_q.filter(or_(
111 User.username.ilike(like_expression),
111 User.username.ilike(like_expression),
112 User._email.ilike(like_expression),
112 User._email.ilike(like_expression),
@@ -216,14 +216,14 b' class AdminUsersView(BaseAppView, DataGr'
216 html = formencode.htmlfill.render(
216 html = formencode.htmlfill.render(
217 data,
217 data,
218 defaults=errors.value,
218 defaults=errors.value,
219 errors=errors.error_dict or {},
219 errors=errors.unpack_errors() or {},
220 prefix_error=False,
220 prefix_error=False,
221 encoding="UTF-8",
221 encoding="UTF-8",
222 force_defaults=False
222 force_defaults=False
223 )
223 )
224 return Response(html)
224 return Response(html)
225 except UserCreationError as e:
225 except UserCreationError as e:
226 h.flash(e, 'error')
226 h.flash(safe_unicode(e), 'error')
227 except Exception:
227 except Exception:
228 log.exception("Exception creation of user")
228 log.exception("Exception creation of user")
229 h.flash(_('Error occurred during creation of user %s')
229 h.flash(_('Error occurred during creation of user %s')
@@ -340,14 +340,14 b' class UsersView(UserAppView):'
340 html = formencode.htmlfill.render(
340 html = formencode.htmlfill.render(
341 data,
341 data,
342 defaults=errors.value,
342 defaults=errors.value,
343 errors=errors.error_dict or {},
343 errors=errors.unpack_errors() or {},
344 prefix_error=False,
344 prefix_error=False,
345 encoding="UTF-8",
345 encoding="UTF-8",
346 force_defaults=False
346 force_defaults=False
347 )
347 )
348 return Response(html)
348 return Response(html)
349 except UserCreationError as e:
349 except UserCreationError as e:
350 h.flash(e, 'error')
350 h.flash(safe_unicode(e), 'error')
351 except Exception:
351 except Exception:
352 log.exception("Exception updating user")
352 log.exception("Exception updating user")
353 h.flash(_('Error occurred during update of user %s')
353 h.flash(_('Error occurred during update of user %s')
@@ -636,7 +636,7 b' class UsersView(UserAppView):'
636 html = formencode.htmlfill.render(
636 html = formencode.htmlfill.render(
637 data,
637 data,
638 defaults=errors.value,
638 defaults=errors.value,
639 errors=errors.error_dict or {},
639 errors=errors.unpack_errors() or {},
640 prefix_error=False,
640 prefix_error=False,
641 encoding="UTF-8",
641 encoding="UTF-8",
642 force_defaults=False
642 force_defaults=False
@@ -1026,7 +1026,8 b' class UsersView(UserAppView):'
1026 h.flash(_("Added new email address `%s` for user account") % email,
1026 h.flash(_("Added new email address `%s` for user account") % email,
1027 category='success')
1027 category='success')
1028 except formencode.Invalid as error:
1028 except formencode.Invalid as error:
1029 h.flash(h.escape(error.error_dict['email']), category='error')
1029 msg = error.unpack_errors()['email']
1030 h.flash(h.escape(msg), category='error')
1030 except IntegrityError:
1031 except IntegrityError:
1031 log.warning("Email %s already exists", email)
1032 log.warning("Email %s already exists", email)
1032 h.flash(_('Email `{}` is already registered for another user.').format(email),
1033 h.flash(_('Email `{}` is already registered for another user.').format(email),
@@ -1117,7 +1118,7 b' class UsersView(UserAppView):'
1117 Session().commit()
1118 Session().commit()
1118 added.append(ip)
1119 added.append(ip)
1119 except formencode.Invalid as error:
1120 except formencode.Invalid as error:
1120 msg = error.error_dict['ip']
1121 msg = error.unpack_errors()['ip']
1121 h.flash(msg, category='error')
1122 h.flash(msg, category='error')
1122 except Exception:
1123 except Exception:
1123 log.exception("Exception during ip saving")
1124 log.exception("Exception during ip saving")
General Comments 0
You need to be logged in to leave comments. Login now