ogcp: make client name field mandatory in client form

Add InputRequired validator to the name field of the
ClientDetailsForm.
Validate name value in the POST function.
master
Alejandro Sirgo Rica 2024-07-04 11:52:08 +02:00 committed by lupoDharkael
parent 5111733b93
commit e532e9a0c8
2 changed files with 8 additions and 1 deletions

View File

@ -126,7 +126,8 @@ class FolderForm(FlaskForm):
class ClientDetailsForm(FlaskForm):
server = HiddenField()
name = StringField(label=_l('Name'))
name = StringField(label=_l('Name'),
validators=[InputRequired()])
ip = StringField(label=_l('IP'),
validators=[InputRequired()])
mac = StringField(label=_l('MAC'),

View File

@ -1567,6 +1567,12 @@ def action_client_add():
flash(form.errors, category='error')
return redirect(url_for('scopes'))
client_name = form.name.data
if not client_name:
flash(_('Invalid empty client name'), category='error')
return redirect(url_for("scopes"))
try:
ipaddress.ip_address(form.ip.data)
except ValueError as e: