summaryrefslogtreecommitdiffstats
path: root/accounts/utils/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/utils/__init__.py')
-rw-r--r--accounts/utils/__init__.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/accounts/utils/__init__.py b/accounts/utils/__init__.py
index 6adf317..da92528 100644
--- a/accounts/utils/__init__.py
+++ b/accounts/utils/__init__.py
@@ -14,8 +14,11 @@ def templated(template: Optional[str] = None):
def templated__(*args, **kwargs):
template_name = template
if template_name is None:
- template_name = request.endpoint \
- .replace('.', '/') + '.html'
+ if request.endpoint:
+ template_name = request.endpoint \
+ .replace('.', '/') + '.html'
+ else:
+ template_name = "error.html"
ctx = f(*args, **kwargs)
if ctx is None:
ctx = {}
@@ -30,10 +33,11 @@ class NotRegexp(Regexp):
"""
Like wtforms.validators.Regexp, but rejects data that DOES match the regex.
"""
+
def __call__(self, form, field):
if self.regex.match(field.data or ''):
if self.message is None:
- self.message = field.gettext('Invalid input.')
+ self.message: str = field.gettext('Invalid input.')
raise ValidationError(self.message)