From 5b5c692cad5e636503afebc57ad81ceceb0d6637 Mon Sep 17 00:00:00 2001 From: Alexander Watzinger Date: Sun, 26 Nov 2023 21:56:43 +0100 Subject: [PATCH] Bookworm: adapting form validator functions --- openatlas/forms/validation.py | 2 +- openatlas/views/imports.py | 4 ++-- openatlas/views/profile.py | 2 +- openatlas/views/search.py | 2 +- openatlas/views/user.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openatlas/forms/validation.py b/openatlas/forms/validation.py index 57244dccc..e54eabf70 100644 --- a/openatlas/forms/validation.py +++ b/openatlas/forms/validation.py @@ -26,7 +26,7 @@ def hierarchy_name_exists(form: FlaskForm, field: TreeField) -> None: field.errors.append(_('error name exists')) -def validate(form: FlaskForm) -> bool: +def validate(form: FlaskForm, extra_validators=None) -> bool: valid = FlaskForm.validate(form) if hasattr(form, 'begin_year_from'): # Dates if not validate_dates(form): diff --git a/openatlas/views/imports.py b/openatlas/views/imports.py index 133edccbc..ce7a773ef 100644 --- a/openatlas/views/imports.py +++ b/openatlas/views/imports.py @@ -33,7 +33,7 @@ class ProjectForm(FlaskForm): description = TextAreaField(_('description')) save = SubmitField(_('insert')) - def validate(self) -> bool: + def validate(self, extra_validators=None) -> bool: valid = FlaskForm.validate(self) name = Import.get_project_by_id(self.project_id).name \ if self.project_id else '' @@ -150,7 +150,7 @@ class ImportForm(FlaskForm): duplicate = BooleanField(_('check for duplicates'), default=True) save = SubmitField(_('import')) - def validate(self) -> bool: + def validate(self, extra_validators=None) -> bool: valid = FlaskForm.validate(self) if pathlib.Path(request.files['file'].filename) \ .suffix.lower() != '.csv': diff --git a/openatlas/views/profile.py b/openatlas/views/profile.py index 595802c51..8a1ca7918 100644 --- a/openatlas/views/profile.py +++ b/openatlas/views/profile.py @@ -29,7 +29,7 @@ class PasswordForm(FlaskForm): show_passwords = BooleanField(_('show passwords')) save = SubmitField(_('save')) - def validate(self) -> bool: + def validate(self, extra_validators=None) -> bool: valid = FlaskForm.validate(self) hash_ = bcrypt.hashpw( self.password_old.data.encode('utf-8'), diff --git a/openatlas/views/search.py b/openatlas/views/search.py index c0130ba1a..03015fb68 100644 --- a/openatlas/views/search.py +++ b/openatlas/views/search.py @@ -54,7 +54,7 @@ class SearchForm(FlaskForm): validators=validator_day) include_dateless = BooleanField(_('Include dateless entities')) - def validate(self) -> bool: + def validate(self, extra_validators=None) -> bool: valid = FlaskForm.validate(self) from_date = form_to_datetime64( self.begin_year.data, diff --git a/openatlas/views/user.py b/openatlas/views/user.py index 52abd970a..819fef06a 100644 --- a/openatlas/views/user.py +++ b/openatlas/views/user.py @@ -43,7 +43,7 @@ class UserForm(FlaskForm): insert_and_continue = SubmitField(_('insert and continue')) continue_ = HiddenField() - def validate(self) -> bool: + def validate(self, extra_validators=None) -> bool: valid = FlaskForm.validate(self) username = '' user_email = ''