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