mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
Test add service completed.
This commit is contained in:
@@ -157,15 +157,20 @@ class TextNotReceivedForm(Form):
|
||||
|
||||
|
||||
class AddServiceForm(Form):
|
||||
def __init__(self, service_names, *args, **kwargs):
|
||||
self.service_names = service_names
|
||||
def __init__(self, names_func, *args, **kwargs):
|
||||
"""
|
||||
Keyword arguments:
|
||||
names_func -- Returns a list of unique service_names already registered
|
||||
on the system.
|
||||
"""
|
||||
self._names_func = names_func
|
||||
super(AddServiceForm, self).__init__(*args, **kwargs)
|
||||
|
||||
service_name = StringField(validators=[
|
||||
DataRequired(message='Service name can not be empty')])
|
||||
|
||||
def validate_service_name(self, a):
|
||||
if self.service_name.data in self.service_names:
|
||||
if self.service_name.data in self._names_func():
|
||||
raise ValidationError('Service name already exists')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user