Skip to content

Commit

Permalink
Bookworm: adapting form validator functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Nov 26, 2023
1 parent 6d3202c commit 5b5c692
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion openatlas/forms/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions openatlas/views/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down Expand Up @@ -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':
Expand Down
2 changes: 1 addition & 1 deletion openatlas/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion openatlas/views/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion openatlas/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down

0 comments on commit 5b5c692

Please sign in to comment.