Example #1
0
    def __init__(self, source):
        super(MyEditor, self).__init__(source, self.fields)

        self.name.validate(lambda v: validator.to_string(v, strip=True).
                           not_empty().to_string())
        self.age.validate(lambda v: validator.to_int(v).lesser_than(50).
                          greater_than(0).to_int())
Example #2
0
 def __init__(self, title, description, save_template_func):
     self.save_template_func = save_template_func
     self.title = editor.Property(title)
     self.title.validate(
         lambda v: nagare_validator.to_string(v).not_empty())
     self.description = editor.Property(description)
     self.shared = editor.Property(False).validate(validator.BoolValidator)
Example #3
0
    def __init__(self, name):
        """Initialization

        In:
          - ``name`` -- initial value of the text field
        """
        # Create a property. The text must be not empty
        self.name = editor.Property(name).validate(validator.to_string(strip=True).not_empty())
Example #4
0
    def __init__(self, names):
        """Initialization

        Create an editor property for each names

        In:
          - ``names`` -- list of name to edit
        """
        self.names = [editor.Property(name).validate(validator.to_string(strip=True).not_empty()) for name in names]
Example #5
0
    def __init__(self, name):
        """Initialization

        In:
          - ``name`` -- initial value of the text field
        """
        # Create a property. The text must be not empty
        self.name = editor.Property(name).validate(
            validator.to_string(strip=True).not_empty())
Example #6
0
    def __init__(self):
        self.title = editor.Property(None)
        self.img = editor.Property(None)

        # The validation functions are added:
        #
        #   - the title must be a not empty string
        #   - a image must be uploaded
        self.title.validate(validator.to_string().not_empty().to_string())
        self.img.validate(self.validate_img)
Example #7
0
    def __init__(self, columns_count):
        """Initialization

        In:
            - ``board`` -- the board the new column will belong
        """
        self.columns_count = columns_count
        self.index = editor.Property(u'').validate(nagare_validator.to_int)
        self.title = editor.Property(u'')
        self.title.validate(lambda v: nagare_validator.to_string(v.strip()).not_empty(_(u'''Can't be empty''')))
        self.nb_cards = editor.Property(u'').validate(self.validate_nb_cards)
Example #8
0
    def __init__(self, columns_count):
        """Initialization

        In:
            - ``board`` -- the board the new column will belong
        """
        self.columns_count = columns_count
        self.index = editor.Property(u'').validate(nagare_validator.to_int)
        self.title = editor.Property(u'')
        self.title.validate(lambda v: nagare_validator.to_string(v).not_empty(_(u'''Can't be empty''')))
        self.nb_cards = editor.Property(u'').validate(self.validate_nb_cards)
Example #9
0
    def __init__(self, names):
        """Initialization

        Create an editor property for each names

        In:
          - ``names`` -- list of name to edit
        """
        self.names = [
            editor.Property(name).validate(
                validator.to_string(strip=True).not_empty()) for name in names
        ]
Example #10
0
    def __init__(self, target):
        """Initialization

        Create a ``editor.property`` for each ``self.fields`` of the target object

        In:
          - ``target`` -- the object to edit
        """
        super(FormEditor, self).__init__(target, self.fields)

        # Set the conversion and validation rules on the properties
        self.age.validate(validator.to_int().lesser_than(50).greater_than(10))
        self.area.validate(validator.to_string(strip=True).not_empty().match(r'^[a-d]+$'))

        # A property can also be manually created
        self.file = editor.Property().validate(self.validate_file)

        # An editor can have more properties than the attributes of the target object
        self.confirm = editor.Property('').validate(self.validate_confirm)
Example #11
0
    def __init__(self, target):
        """Initialization

        Create a ``editor.property`` for each ``self.fields`` of the target object

        In:
          - ``target`` -- the object to edit
        """
        super(FormEditor, self).__init__(target, self.fields)

        # Set the conversion and validation rules on the properties
        self.age.validate(validator.to_int().lesser_than(50).greater_than(10))
        self.area.validate(
            validator.to_string(strip=True).not_empty().match(r'^[a-d]+$'))

        # A property can also be manually created
        self.file = editor.Property().validate(self.validate_file)

        # An editor can have more properties than the attributes of the target object
        self.confirm = editor.Property('').validate(self.validate_confirm)
Example #12
0
 def __init__(self, source):
     super(MyStringEditor4, self).__init__(source)
     self.name.validate(
         lambda v: validator.to_string(v, strip=True).length_equal(
             5, msg="test7 - Length must be %(len)d characters"))
Example #13
0
 def __init__(self, source):
     super(MyStringEditor3, self).__init__(source)
     self.name.validate(
         lambda v: validator.to_string(v, strip=True).shorter_than(
             5,
             msg="test6 - Length must be shorter than %(max)d characters"))
Example #14
0
 def __init__(self, source):
     super(MyStringEditor2, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).match(
         r'^[a-d]+$', msg="test5 - Incorrect format"))
Example #15
0
    def __init__(self, source):
        super(MyStringEditor1, self).__init__(source)

        self.name.validate(
            lambda v: validator.to_string(v, strip=True).not_empty())
Example #16
0
 def __init__(self, source):
     super(MyStringEditor5, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).longer_than(5).shorter_or_equal_than(8).not_empty().match(r'^[1-9]+$'))
Example #17
0
    def __init__(self):
        self.title = editor.Property(None)
        self.img = editor.Property(None)

        self.title.validate(validator.to_string().not_empty().to_string())
        self.img.validate(self.validate_img)
Example #18
0
 def __init__(self, source):
     super(MyStringEditor3, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).shorter_than(5, msg="test6 - Length must be shorter than %(max)d characters"))
Example #19
0
    def __init__(self, source):
        super(MyEditor, self).__init__(source, self.fields)

        self.name.validate(lambda v: validator.to_string(v, strip=True).not_empty().to_string())
        self.age.validate(lambda v: validator.to_int(v).lesser_than(50).greater_than(0).to_int())
Example #20
0
 def __init__(self, source):
     super(MyStringEditor2, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).match(r'^[a-d]+$', msg="test5 - Incorrect format"))
Example #21
0
 def __init__(self, title, description, save_template_func):
     self.save_template_func = save_template_func
     self.title = editor.Property(title)
     self.title.validate(lambda v: nagare_validator.to_string(v).not_empty())
     self.description = editor.Property(description)
     self.shared = editor.Property(False).validate(validator.BoolValidator)
Example #22
0
 def __init__(self, source):
     super(MyStringEditor5, self).__init__(source)
     self.name.validate(
         lambda v: validator.to_string(v, strip=True).longer_than(
             5).shorter_or_equal_than(8).not_empty().match(r'^[1-9]+$'))
Example #23
0
 def __init__(self, source):
     super(MyStringEditor4, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).length_equal(5, msg="test7 - Length must be %(len)d characters"))
Example #24
0
    def __init__(self, source):
        super(MyStringEditor1, self).__init__(source)

        self.name.validate(lambda v: validator.to_string(v, strip=True).not_empty())
Example #25
0
    def __init__(self):
        self.title = editor.Property(None)
        self.img = editor.Property(None)

        self.title.validate(validator.to_string().not_empty().to_string())
        self.img.validate(self.validate_img)