mirror of https://git.48k.eu/ogcp
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
parent
5111733b93
commit
e532e9a0c8
|
@ -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'),
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue