Exemplo n.º 1
0
    def __call__(self, field, **kwargs):
        html = []
        html.append('<div class="input-group">')

        for text in self.group_before:
            html.append('<span class="input-group-addon">%s</span>' % text)

        classes = kwargs.get("class_", "").split(" ")
        for class_ in self.default_classes:
            classes.append(class_)
        kwargs["class_"] = " ".join(classes)
        html.append(Input.__call__(self, field, **kwargs))

        for text in self.group_after:
            html.append('<span class="input-group-addon">%s</span>' % text)

        html.append('</div>')

        return HTMLString("".join(html))
Exemplo n.º 2
0
    def test_input_type(self):
        with pytest.raises(AttributeError):
            Input().input_type

        test_input = Input(input_type="test")
        assert test_input.input_type == "test"
Exemplo n.º 3
0
    def test_input_type(self):
        with pytest.raises(AttributeError):
            getattr(Input(), "input_type")

        test_input = Input(input_type="test")
        assert test_input.input_type == "test"
Exemplo n.º 4
0
 def __init__(self, input_type=None, group_before=None, group_after=None,
              default_classes=None):
     self.group_before = group_before or []
     self.group_after = group_after or []
     self.default_classes = default_classes or []
     Input.__init__(self, input_type=input_type)