Author: tmckay Date: 2013-07-30 15:27:18 +0000 (Tue, 30 Jul 2013) New Revision: 5785
Modified: branches/statusquo/cumin/python/cumin/grid/tags.py branches/statusquo/wooly/python/wooly/forms.py Log: For a separated list, also check each value for empty BZ966548 (mod)
Modified: branches/statusquo/cumin/python/cumin/grid/tags.py =================================================================== --- branches/statusquo/cumin/python/cumin/grid/tags.py 2013-07-26 18:08:52 UTC (rev 5784) +++ branches/statusquo/cumin/python/cumin/grid/tags.py 2013-07-30 15:27:18 UTC (rev 5785) @@ -514,6 +514,7 @@
self.tag = self.TagNamesField(app, "tag") self.tag.required = True + self.tag.separator = "," self.add_field(self.tag)
def process_submit(self, session):
Modified: branches/statusquo/wooly/python/wooly/forms.py =================================================================== --- branches/statusquo/wooly/python/wooly/forms.py 2013-07-26 18:08:52 UTC (rev 5784) +++ branches/statusquo/wooly/python/wooly/forms.py 2013-07-30 15:27:18 UTC (rev 5785) @@ -139,6 +139,16 @@ title = self.widget.render_title(session) return "The '%s' field must have a value" % title
+class MissingMultiValueError(FormError): + def __init__(self, widget): + super(MissingMultiValueError, self).__init__(widget) + + self.widget = widget + + def get_message(self, session): + title = self.widget.render_title(session) + return "Each listed value in the '%s' field must be non-empty" % title + class QuoteValueError(FormError): def __init__(self, widget): super(QuoteValueError, self).__init__(None) @@ -489,7 +499,20 @@
self.input = StringInput(app, "input") self.add_child(self.input) + self.separator = None
+ def validate(self, session): + super(StringField, self).validate(session) + + if self.separator and isinstance(self.separator, str): + v = self.get(session) + if v: + for val in v.split(self.separator): + if not val: + error = MissingMultiValueError(self) + self.form.errors.add(session, error) + break + class NoXMLStringField(StringField): def validate(self, session): super(NoXMLStringField, self).validate(session)