Module: check_mk
Branch: master
Commit: 7ffe7c7021098acd27d82acc2a1595f73017487e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7ffe7c7021098a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Mar 21 12:29:23 2016 +0100
3316 FIX Fix validation of empty or missing file uploads (such as in Bulk host import)
---
.werks/3316 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/valuespec.py | 14 +++++++++-----
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/.werks/3316 b/.werks/3316
new file mode 100644
index 0000000..87b4883
--- /dev/null
+++ b/.werks/3316
@@ -0,0 +1,10 @@
+Title: Fix validation of empty or missing file uploads (such as in Bulk host import)
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1458559742
+
+
diff --git a/ChangeLog b/ChangeLog
index c3ba176..5536aff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -157,6 +157,7 @@
* 3295 FIX: Fixed exception in WATO git integration when modifying .gitingore file
* 3296 FIX: Hiding pending changes related buttons after discarding changes
* 3314 FIX: Correctly add custom user attribute values after change in attribute
declaration...
+ * 3316 FIX: Fix validation of empty or missing file uploads (such as in Bulk host
import)
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index ae8f5be..97fd7c8 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -3313,7 +3313,7 @@ class FileUpload(ValueSpec):
ValueSpec.__init__(self, **kwargs)
self._allow_empty = kwargs.get('allow_empty', True)
self._allowed_extensions = kwargs.get('allowed_extensions')
- self._allow_empty_content= kwargs.get('allow_empty_content', True)
+ self._allow_empty_content = kwargs.get('allow_empty_content', True)
def canonical_value(self):
@@ -3326,7 +3326,7 @@ class FileUpload(ValueSpec):
def validate_value(self, value, varprefix):
file_name, mime_type, content = value
- if not self._allow_empty and (value == None or file_name == ''):
+ if not self._allow_empty and (content == '' or file_name == ''):
raise MKUserError(varprefix, _('Please select a file.'))
if not self._allow_empty_content and len(content) == 0:
@@ -3358,12 +3358,16 @@ class FileUpload(ValueSpec):
class UploadOrPasteTextFile(Alternative):
def __init__(self, **kwargs):
file_title = kwargs.get("file_title", _("File"))
+ allow_empty = kwargs.get("allow_empty", True)
kwargs["elements"] = [
- FileUpload(title = _("Upload %s") % file_title),
+ FileUpload(
+ title = _("Upload %s") % file_title,
+ allow_empty = allow_empty),
TextAreaUnicode(
title = _("Content of %s") % file_title,
- cols=80,
- rows="auto"),
+ allow_empty = allow_empty,
+ cols = 80,
+ rows = "auto"),
]
if kwargs.get("default_mode", "text") == "upload":