Skip to content

Commit

Permalink
add validators for firmware input
Browse files Browse the repository at this point in the history
  • Loading branch information
mreid-tt committed Jan 18, 2024
1 parent ad1cf17 commit 2bc6a29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spkrepo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class SPK(object):
#: Regex for files in conf
conf_filename_re = re.compile(r"^conf/.+$")

#: Regex for firmware input
firmware_version_re = re.compile(r"^\d+\.\d$")
firmware_type_re = re.compile(r"^([a-z]){3,}$")

def __init__(self, stream):
self.info = {}
self.icons = {}
Expand Down
7 changes: 7 additions & 0 deletions spkrepo/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ def is_accessible(self):

can_delete = False

# Form
form_columns = ("version", "build", "type")
form_args = {
"version": {"validators": [Regexp(SPK.firmware_version_re)]},
"type": {"validators": [Regexp(SPK.firmware_type_re)]},
}


class ServiceView(ModelView):
"""View for :class:`~spkrepo.models.Service`"""
Expand Down

0 comments on commit 2bc6a29

Please sign in to comment.