You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by di...@apache.org on 2023/02/23 15:36:02 UTC
[allura] 01/02: [#8499] updated syntax to retreive form errors from the request object instead of the template context c.form_errors -> request.validation.errors
This is an automated email from the ASF dual-hosted git repository.
dill0wn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 7d534c4a98b7b3eda9b80a888bf10f5ed1c6fdcb
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Mon Feb 13 10:11:39 2023 -0600
[#8499] updated syntax to retreive form errors from the request object instead of the template context c.form_errors -> request.validation.errors
---
Allura/allura/controllers/auth.py | 7 +++----
Allura/allura/controllers/project.py | 4 ++--
Allura/allura/controllers/site_admin.py | 12 ++++++------
.../admin/templates/admin_widgets/metadata_admin.html | 8 ++++----
Allura/allura/lib/decorators.py | 2 +-
Allura/allura/lib/repository.py | 4 ++--
Allura/allura/templates/login_multifactor.html | 4 ++--
Allura/allura/templates/reconfirm_auth.html | 4 ++--
Allura/allura/templates/user_totp.html | 4 ++--
Allura/allura/templates/webhooks/create_form.html | 4 ++--
.../templates/widgets/neighborhood_add_project.html | 2 +-
.../admin/templates/admin_widgets/metadata_admin.html | 8 ++++----
Allura/allura/webhooks.py | 4 ++--
ForgeImporters/forgeimporters/base.py | 3 ++-
.../forgeimporters/github/templates/project.html | 16 ++++++++--------
.../forgeimporters/templates/importer_base.html | 4 ++--
.../forgeimporters/templates/project_base.html | 16 ++++++++--------
.../forgeimporters/trac/templates/project.html | 8 ++++----
ForgeSVN/forgesvn/svn_main.py | 4 ++--
ForgeShortUrl/forgeshorturl/main.py | 6 +++---
20 files changed, 62 insertions(+), 62 deletions(-)
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index c45274556..cfd85933e 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -412,11 +412,11 @@ class AuthController(BaseController):
recovery.verify_and_remove_code(user, code)
h.auditlog_user('Logged in using a multifactor recovery code', user=user)
except (InvalidToken, InvalidRecoveryCode):
- c.form_errors['code'] = 'Invalid code, please try again.'
+ request.validation.errors['code'] = 'Invalid code, please try again.'
h.auditlog_user('Multifactor login - invalid code', user=user)
return self.multifactor(mode=mode, **kwargs)
except MultifactorRateLimitError:
- c.form_errors['code'] = 'Multifactor rate limit exceeded, slow down and try again later.'
+ request.validation.errors['code'] = 'Multifactor rate limit exceeded, slow down and try again later.'
h.auditlog_user('Multifactor login - rate limit', user=user)
return self.multifactor(mode=mode, **kwargs)
else:
@@ -828,7 +828,7 @@ class PreferencesController(BaseController):
totp_service.verify(totp, code, c.user)
except InvalidToken:
h.auditlog_user('Failed to set up multifactor TOTP (wrong code)')
- c.form_errors['code'] = 'Invalid code, please try again.'
+ request.validation.errors['code'] = 'Invalid code, please try again.'
return self.totp_new(**kw)
else:
h.auditlog_user('Set up multifactor TOTP')
@@ -1062,7 +1062,6 @@ class UserContactsController(BaseController):
Validator = validator_map.get(kw['socialnetwork'])
kw['accounturl'] = Validator().to_python(kw['accounturl'])
except fe.Invalid as e:
- # c.form_errors['accounturl'] = e.msg
flash(e.msg, 'error')
redirect('.')
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 089dc70a2..61abe252d 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -153,7 +153,7 @@ class NeighborhoodController:
def add_project(self, **form_data):
with h.login_overlay():
require_access(self.neighborhood, 'register')
- verify = c.form_errors == {'_the_form': 'phone-verification'}
+ verify = request.validation.errors == {'_the_form': 'phone-verification'}
c.show_phone_verification_overlay = verify
c.add_project = W.add_project
form_data.setdefault('tools', W.add_project.default_tools)
@@ -197,7 +197,7 @@ class NeighborhoodController:
@validate(W.add_project)
def check_names(self, **raw_data):
require_access(self.neighborhood, 'register')
- return c.form_errors
+ return request.validation.errors
@h.vardec
@expose()
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index b9a8f93e8..0f70f03b2 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -219,12 +219,12 @@ class SiteAdminController:
mount_point=validators.NotEmpty()))
def reclone_repo(self, prefix=None, shortname=None, mount_point=None, **data):
if request.method == 'POST':
- if c.form_errors:
+ if request.validation.errors:
error_msg = 'Error: '
- for msg in list(c.form_errors):
+ for msg in list(request.validation.errors):
names = {'prefix': 'Neighborhood prefix', 'shortname':
'Project shortname', 'mount_point': 'Repository mount point'}
- error_msg += f'{names[msg]}: {c.form_errors[msg]} '
+ error_msg += f'{names[msg]}: {request.validation.errors[msg]} '
flash(error_msg, 'error')
return dict(prefix=prefix, shortname=shortname, mount_point=mount_point)
nbhd = M.Neighborhood.query.get(url_prefix='/%s/' % prefix)
@@ -455,7 +455,7 @@ class SiteNotificationController:
def new(self, **kw):
"""Render the New SiteNotification form"""
return dict(
- form_errors=c.form_errors or {},
+ form_errors=request.validation.errors or {},
form_values=c.form_values or {},
form_title='New Site Notification',
form_action='create'
@@ -477,7 +477,7 @@ class SiteNotificationController:
def edit(self, **kw):
if c.form_values:
return dict(
- form_errors=c.form_errors or {},
+ form_errors=request.validation.errors or {},
form_values=c.form_values or {},
form_title='Edit Site Notification',
form_action='update'
@@ -583,7 +583,7 @@ class TaskManagerController:
def new(self, **kw):
"""Render the New Task form"""
return dict(
- form_errors=c.form_errors or {},
+ form_errors=request.validation.errors or {},
form_values=c.form_values or {},
)
diff --git a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
index 3998c4251..7937cd490 100644
--- a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
@@ -61,8 +61,8 @@
{% if tg.config.get('support_tool_choices') %}
<div class="support-page-fields">
Preferred Support Page (for users of your project):<br>
- {% if c.form_errors.get('support_page_url') %}
- <div class="error">{{c.form_errors.get('support_page_url')}}</div>
+ {% if request.validation.errors.get('support_page_url') %}
+ <div class="error">{{request.validation.errors.get('support_page_url')}}</div>
{% endif %}
<input name="support_page" type="radio" value=""{% if value.support_page == '' %} checked{% endif %} id="support_page_none">
<label for="support_page_none">None</label><br>
@@ -133,8 +133,8 @@
{% set proj_text = 'Project' if value.is_root else 'Subproject' %}
{{proj_text}} Status:
<div>
- {% if c.form_errors.get('moved_to_url') %}
- <div class="error">{{c.form_errors.get('moved_to_url')}}</div>
+ {% if request.validation.errors.get('moved_to_url') %}
+ <div class="error">{{request.validation.errors.get('moved_to_url')}}</div>
{% endif %}
<input name="removal" type="radio" value="" id="removal_active_cb"
{% if value.removal == '' %} checked{% endif %}>
diff --git a/Allura/allura/lib/decorators.py b/Allura/allura/lib/decorators.py
index 078eaa4f8..b2b15f152 100644
--- a/Allura/allura/lib/decorators.py
+++ b/Allura/allura/lib/decorators.py
@@ -142,7 +142,7 @@ def reconfirm_auth(func, *args, **kwargs):
session.save()
kwargs.pop('password', None)
else:
- c.form_errors['password'] = 'Invalid password.'
+ request.validation.errors['password'] = 'Invalid password.'
allowed_timedelta = timedelta(seconds=asint(config.get('auth.reconfirm.seconds', 60)))
last_reconfirm = session.get('auth-reconfirmed', datetime.min)
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 494c46772..b92c0ee25 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -314,7 +314,7 @@ class RepoAdminController(DefaultAdminController):
def set_checkout_url(self, **post_data):
flash_msgs = []
external_checkout_url = (post_data.get('external_checkout_url') or '').strip()
- if 'external_checkout_url' not in c.form_errors:
+ if 'external_checkout_url' not in request.validation.errors:
if (self.app.config.options.get('external_checkout_url') or '') != external_checkout_url:
M.AuditLog.log('{}: set "{}" {} => {}'.format(
self.app.config.options['mount_point'], "external_checkout_url",
@@ -322,7 +322,7 @@ class RepoAdminController(DefaultAdminController):
self.app.config.options.external_checkout_url = external_checkout_url
flash_msgs.append("External checkout URL successfully changed.")
else:
- flash_msgs.append("Invalid external checkout URL: %s." % c.form_errors['external_checkout_url'])
+ flash_msgs.append(f"Invalid external checkout URL: {request.validation.errors['external_checkout_url']}.")
merge_disabled = bool(post_data.get('merge_disabled'))
if merge_disabled != self.app.config.options.get('merge_disabled', False):
diff --git a/Allura/allura/templates/login_multifactor.html b/Allura/allura/templates/login_multifactor.html
index f71755ff5..749b74b34 100644
--- a/Allura/allura/templates/login_multifactor.html
+++ b/Allura/allura/templates/login_multifactor.html
@@ -30,8 +30,8 @@
<span class="totp">Please enter the {{ config['auth.multifactor.totp.length'] }}-digit code from your authenticator app:</span>
<span class="recovery">Please enter a recovery code:</span>
<br>
- {% if c.form_errors['code'] %}
- <span class="fielderror">{{ c.form_errors['code'] }}</span><br>
+ {% if request.validation.errors['code'] %}
+ <span class="fielderror">{{ request.validation.errors['code'] }}</span><br>
{% endif %}
<input type="text" name="code" autofocus autocomplete="off"/>
<input type="hidden" name="return_to" value="{{ return_to }}"/>
diff --git a/Allura/allura/templates/reconfirm_auth.html b/Allura/allura/templates/reconfirm_auth.html
index a3ea322c3..d592a4e9b 100644
--- a/Allura/allura/templates/reconfirm_auth.html
+++ b/Allura/allura/templates/reconfirm_auth.html
@@ -27,8 +27,8 @@
<form method="post">
<h2>Password Confirmation</h2>
<p>To access this account security page, you must reconfirm your password:<br>
- {% if c.form_errors['password'] %}
- <span class="fielderror">{{ c.form_errors['password'] }}</span><br>
+ {% if request.validation.errors['password'] %}
+ <span class="fielderror">{{ request.validation.errors['password'] }}</span><br>
{% endif %}
<input type="password" name="password" autofocus>
<br>
diff --git a/Allura/allura/templates/user_totp.html b/Allura/allura/templates/user_totp.html
index ce4ae726a..38cb92989 100644
--- a/Allura/allura/templates/user_totp.html
+++ b/Allura/allura/templates/user_totp.html
@@ -56,8 +56,8 @@
<form method="POST" action="totp_set" id="totp_set">
<p>
Enter the {{ config['auth.multifactor.totp.length'] }}-digit code from the app, to confirm it is set up correctly:<br>
- {% if c.form_errors['code'] %}
- <span class="fielderror">{{ c.form_errors['code'] }}</span><br>
+ {% if request.validation.errors['code'] %}
+ <span class="fielderror">{{ request.validation.errors['code'] }}</span><br>
{% endif %}
<input type="text" name="code" autofocus autocomplete="off" maxlength="{{ config['auth.multifactor.totp.length']|int + 1 }}"/>
{{ lib.csrf_token() }}
diff --git a/Allura/allura/templates/webhooks/create_form.html b/Allura/allura/templates/webhooks/create_form.html
index 9598e1f0a..34569b65a 100644
--- a/Allura/allura/templates/webhooks/create_form.html
+++ b/Allura/allura/templates/webhooks/create_form.html
@@ -58,8 +58,8 @@
{% endblock %}
{%- macro error(field_name) %}
- {% if c.form_errors[field_name] %}
- <div class="error">{{c.form_errors[field_name]}}</div>
+ {% if request.validation.errors[field_name] %}
+ <div class="error">{{request.validation.errors[field_name]}}</div>
{% endif %}
{%- endmacro %}
diff --git a/Allura/allura/templates/widgets/neighborhood_add_project.html b/Allura/allura/templates/widgets/neighborhood_add_project.html
index fea1f149a..2e8625de9 100644
--- a/Allura/allura/templates/widgets/neighborhood_add_project.html
+++ b/Allura/allura/templates/widgets/neighborhood_add_project.html
@@ -51,7 +51,7 @@
<h2 style="padding-left:20px">
Select the tools to use in your project. You may add or remove tools at any time.
</h2>
- <span class="fielderror">{{ c.form_errors.get('tools', '') }}</span>
+ <span class="fielderror">{{ request.validation.errors.get('tools', '') }}</span>
{% for opt in widget.fields.tools.options %}
{% set tool = g.entry_points["tool"][opt.html_value] %}
{% set _ctx = widget.context_for(widget.fields.tools) %}
diff --git a/Allura/allura/templates_responsive/override/allura/ext/admin/templates/admin_widgets/metadata_admin.html b/Allura/allura/templates_responsive/override/allura/ext/admin/templates/admin_widgets/metadata_admin.html
index 68ac3c213..eeec119db 100644
--- a/Allura/allura/templates_responsive/override/allura/ext/admin/templates/admin_widgets/metadata_admin.html
+++ b/Allura/allura/templates_responsive/override/allura/ext/admin/templates/admin_widgets/metadata_admin.html
@@ -64,8 +64,8 @@
{% if tg.config.get('support_tool_choices') %}
<div class="support-page-fields new-visual-group">
Preferred Support Page (for users of your project):<br>
- {% if c.form_errors.get('support_page_url') %}
- <div class="error">{{c.form_errors.get('support_page_url')}}</div>
+ {% if request.validation.errors.get('support_page_url') %}
+ <div class="error">{{request.validation.errors.get('support_page_url')}}</div>
{% endif %}
<input name="support_page" type="radio" value=""{% if value.support_page == '' %} checked{% endif %} id="support_page_none">
@@ -147,8 +147,8 @@
{% set proj_text = 'Project' if value.is_root else 'Subproject' %}
{{proj_text}} Status:
<div>
- {% if c.form_errors.get('moved_to_url') %}
- <div class="error">{{c.form_errors.get('moved_to_url')}}</div>
+ {% if request.validation.errors.get('moved_to_url') %}
+ <div class="error">{{request.validation.errors.get('moved_to_url')}}</div>
{% endif %}
<input name="removal" type="radio" value="" id="removal_active_cb"
{% if value.removal == '' %} checked{% endif %}>
diff --git a/Allura/allura/webhooks.py b/Allura/allura/webhooks.py
index 1ca1e4381..10812b364 100644
--- a/Allura/allura/webhooks.py
+++ b/Allura/allura/webhooks.py
@@ -148,7 +148,7 @@ class WebhookController(BaseController, AdminControllerMixin, metaclass=WebhookC
self.update_webhook(webhook, url, secret)
except Invalid as e:
# trigger error_handler directly
- c.form_errors['_the_form'] = e
+ request.validation.errors['_the_form'] = e
return self.index(url=url, secret=secret)
M.AuditLog.log('add webhook %s %s %s',
@@ -170,7 +170,7 @@ class WebhookController(BaseController, AdminControllerMixin, metaclass=WebhookC
self.update_webhook(webhook, url, secret)
except Invalid as e:
# trigger error_handler directly
- c.form_errors['_the_form'] = e
+ request.validation.errors['_the_form'] = e
return self._default(webhook=webhook, url=url, secret=secret)
M.AuditLog.log('edit webhook %s\n%s => %s\n%s',
webhook.type, old_url, url,
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 4cdf67dba..bbafbe65e 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -35,6 +35,7 @@ from tg import expose, validate, flash, redirect, config
from tg.decorators import with_trailing_slash
from tg import app_globals as g
from tg import tmpl_context as c
+from tg import request
from formencode import validators as fev, schema
from webob import exc
@@ -324,7 +325,7 @@ class ProjectImporter(BaseController):
Ajax form validation.
"""
- return c.form_errors
+ return request.validation.errors
def after_project_create(self, project, **kw):
"""
diff --git a/ForgeImporters/forgeimporters/github/templates/project.html b/ForgeImporters/forgeimporters/github/templates/project.html
index 5c957f0a0..00d00a828 100644
--- a/ForgeImporters/forgeimporters/github/templates/project.html
+++ b/ForgeImporters/forgeimporters/github/templates/project.html
@@ -30,8 +30,8 @@
</div>
<div class="grid-10">
<input id="project_url" name="project_url" value="{{c.form_values['project_url']}}" />
- <div id="project_url_error" class="error{% if not c.form_errors['project_url'] %} hidden{% endif %}">
- {{c.form_errors['project_url']}}
+ <div id="project_url_error" class="error{% if not request.validation.errors['project_url'] %} hidden{% endif %}">
+ {{request.validation.errors['project_url']}}
</div>
</div>
<div class="grid-10 field-divider">
@@ -48,8 +48,8 @@
</div>
<div class="grid-10">
<input id="user_name" name="user_name" value="{{c.form_values['user_name']}}" autofocus/>
- <div id="user_name_error" class="error{% if not c.form_errors['user_name'] %} hidden{% endif %}">
- {{c.form_errors['user_name']}}
+ <div id="user_name_error" class="error{% if not request.validation.errors['user_name'] %} hidden{% endif %}">
+ {{request.validation.errors['user_name']}}
</div>
</div>
@@ -65,8 +65,8 @@
</div>
<div class="grid-10">
<input id="project_name" name="project_name" value="{{c.form_values['project_name']}}" />
- <div id="project_name_error" class="error{% if not c.form_errors['project_name'] %} hidden{% endif %}">
- {{c.form_errors['project_name']}}
+ <div id="project_name_error" class="error{% if not request.validation.errors['project_name'] %} hidden{% endif %}">
+ {{request.validation.errors['project_name']}}
</div>
</div>
@@ -84,8 +84,8 @@
</div>
<div class="grid-10">
<input id="project_shortname" name="project_shortname" value="{{c.form_values['project_shortname']}}"/>
- <div id="project_shortname_error" class="error{% if not c.form_errors['project_shortname'] %} hidden{% endif %}">
- {{c.form_errors['project_shortname']}}
+ <div id="project_shortname_error" class="error{% if not request.validation.errors['project_shortname'] %} hidden{% endif %}">
+ {{request.validation.errors['project_shortname']}}
</div>
<div id="project-url">
http://{{request.environ['HTTP_HOST']}}{{importer.neighborhood.url()}}<span id="url-fragment">{{c.form_values['project_shortname']}}</span>
diff --git a/ForgeImporters/forgeimporters/templates/importer_base.html b/ForgeImporters/forgeimporters/templates/importer_base.html
index cec519517..caf2054e5 100644
--- a/ForgeImporters/forgeimporters/templates/importer_base.html
+++ b/ForgeImporters/forgeimporters/templates/importer_base.html
@@ -62,8 +62,8 @@
{% endblock %}
{%- macro error(field_name) %}
- {% if c.form_errors[field_name] %}
- <div class="error">{{c.form_errors[field_name]}}</div>
+ {% if request.validation.errors[field_name] %}
+ <div class="error">{{request.validation.errors[field_name]}}</div>
{% endif %}
{%- endmacro %}
diff --git a/ForgeImporters/forgeimporters/templates/project_base.html b/ForgeImporters/forgeimporters/templates/project_base.html
index 640e66a1c..764002694 100644
--- a/ForgeImporters/forgeimporters/templates/project_base.html
+++ b/ForgeImporters/forgeimporters/templates/project_base.html
@@ -92,8 +92,8 @@
</div>
<div class="grid-10">
<input id="project_name" name="project_name" value="{{c.form_values['project_name']}}"/>
- <div id="project_name_error" class="error{% if not c.form_errors['project_name'] %} hidden{% endif %}">
- {{c.form_errors['project_name']}}
+ <div id="project_name_error" class="error{% if not request.validation.errors['project_name'] %} hidden{% endif %}">
+ {{request.validation.errors['project_name']}}
</div>
</div>
@@ -102,8 +102,8 @@
</div>
<div class="grid-10">
<input id="project_shortname" name="project_shortname" value="{{c.form_values['project_shortname']}}"/>
- <div id="project_shortname_error" class="error{% if not c.form_errors['project_shortname'] %} hidden{% endif %}">
- {{c.form_errors['project_shortname']}}
+ <div id="project_shortname_error" class="error{% if not request.validation.errors['project_shortname'] %} hidden{% endif %}">
+ {{request.validation.errors['project_shortname']}}
</div>
<div id="project-url">
http://{{request.environ['HTTP_HOST']}}{{importer.neighborhood.url()}}<span id="url-fragment">{{c.form_values['project_shortname']}}</span>
@@ -113,19 +113,19 @@
</fieldset>
<div id="tool-fields">
- {% if c.form_errors['tools'] %}
- <div class="error">{{c.form_errors['tools']}}</div>
+ {% if request.validation.errors['tools'] %}
+ <div class="error">{{request.validation.errors['tools']}}</div>
{% endif %}
{% for name, tool_importer in importer.tool_importers.items() %}
<div class="tool">
<img src="{{ tool_importer.tool_icon(g.theme, 48) }}" alt="{{ tool_importer.tool_label }} icon">
<label>
- <input name="tools" value="{{name}}" type="checkbox"{% if not c.form_errors or name in c.form_values['tools'] %} checked="checked"{% endif %}/>
+ <input name="tools" value="{{name}}" type="checkbox"{% if not request.validation.errors or name in c.form_values['tools'] %} checked="checked"{% endif %}/>
{{tool_importer.tool_label}}
</label>
{% for option_name, option_label in tool_importer.tool_option.items() %}
<label>
- <input name="tool_option" value="{{option_name}}" type="checkbox"{% if not c.form_errors or name in c.form_values['tool_option'] %} checked="checked"{% endif %}/>
+ <input name="tool_option" value="{{option_name}}" type="checkbox"{% if not request.validation.errors or name in c.form_values['tool_option'] %} checked="checked"{% endif %}/>
{{option_label}}
</label>
{% endfor %}
diff --git a/ForgeImporters/forgeimporters/trac/templates/project.html b/ForgeImporters/forgeimporters/trac/templates/project.html
index a9af7341b..14b09e001 100644
--- a/ForgeImporters/forgeimporters/trac/templates/project.html
+++ b/ForgeImporters/forgeimporters/trac/templates/project.html
@@ -24,8 +24,8 @@
</div>
<div class="grid-10">
<input id="trac_url" name="trac_url" value="{{c.form_values['trac_url']}}" autofocus/>
- <div id="trac_url_error" class="error{% if not c.form_errors['trac_url'] %} hidden{% endif %}">
- {{c.form_errors['trac_url']}}
+ <div id="trac_url_error" class="error{% if not request.validation.errors['trac_url'] %} hidden{% endif %}">
+ {{request.validation.errors['trac_url']}}
</div>
</div>
@@ -35,8 +35,8 @@
<div class="grid-10">
<input id="user_map" name="user_map" value="{{c.form_values['user_map']}}" type="file"/>
<br><small>JSON file mapping Trac usernames to Allura usernames</small>
- <div id="user_map_error" class="error{% if not c.form_errors['user_map'] %} hidden{% endif %}">
- {{c.form_errors['user_map']}}
+ <div id="user_map_error" class="error{% if not request.validation.errors['user_map'] %} hidden{% endif %}">
+ {{request.validation.errors['user_map']}}
</div>
</div>
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index 4110266cd..f2bf240b0 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -143,7 +143,7 @@ class SVNRepoAdminController(RepoAdminController):
else:
flash("%s is not a valid path for this repository" %
checkout_url, "error")
- if 'external_checkout_url' not in c.form_errors:
+ if 'external_checkout_url' not in request.validation.errors:
if (self.app.config.options.get('external_checkout_url') or '') != external_checkout_url:
M.AuditLog.log('{}: set "{}" {} => {}'.format(
self.app.config.options['mount_point'], "external_checkout_url",
@@ -151,7 +151,7 @@ class SVNRepoAdminController(RepoAdminController):
self.app.config.options.external_checkout_url = external_checkout_url
flash("External checkout URL successfully changed")
else:
- flash("Invalid external checkout URL: %s" % c.form_errors['external_checkout_url'], "error")
+ flash(f"Invalid external checkout URL: {request.validation.errors['external_checkout_url']}", "error")
class SVNImportController(BaseController, AdminControllerMixin):
diff --git a/ForgeShortUrl/forgeshorturl/main.py b/ForgeShortUrl/forgeshorturl/main.py
index e4d88d331..5163cf5ee 100644
--- a/ForgeShortUrl/forgeshorturl/main.py
+++ b/ForgeShortUrl/forgeshorturl/main.py
@@ -225,11 +225,11 @@ class ShortURLAdminController(DefaultAdminController):
else:
require_access(self.app, 'create')
if request.method == 'POST':
- if c.form_errors:
+ if request.validation.errors:
error_msg = 'Error: '
- for msg in list(c.form_errors):
+ for msg in list(request.validation.errors):
names = {'short_url': 'Short url', 'full_url': 'Full URL'}
- error_msg += f'{names[msg]}: {c.form_errors[msg]} '
+ error_msg += f'{names[msg]}: {request.validation.errors[msg]} '
flash(error_msg, 'error')
redirect(six.ensure_text(request.referer or '/'))