Example #1
0
 def __init__(self, key_attrs={}, val_attrs={}, *args, **kwargs):
     """
     :param key_attrs: HTML attributes applied to the 1st input box
     :param val_attrs: HTML attributes applied to the 2nd input box
     """
     self.key_attrs = key_attrs
     self.val_attrs = val_attrs
     Widget.__init__(self, *args, **kwargs)
Example #2
0
 def __init__(self, key_attrs={}, val_attrs={}, *args, **kwargs):
     """
     :param key_attrs: HTML attributes applied to the 1st input box
     :param val_attrs: HTML attributes applied to the 2nd input box
     """
     self.key_attrs = key_attrs
     self.val_attrs = val_attrs
     Widget.__init__(self, *args, **kwargs)
Example #3
0
    def __init__(self, *args, **kwargs):
        """A widget that ...
    """
        self.key_attrs = {}
        self.val_attrs = {}
        if "key_attrs" in kwargs:
            self.key_attrs = kwargs.pop("key_attrs")
        if "val_attrs" in kwargs:
            self.val_attrs = kwargs.pop("val_attrs")
        Widget.__init__(self, *args, **kwargs)

        def render(self, name, value, attrs=None):
            """Renders this widget into an html string
Example #4
0
    def __init__(self, *args, **kwargs):
        """
        kwargs:
        key_attrs -- html attributes applied to the 1st input box pairs
        val_attrs -- html attributes applied to the 2nd input box pairs

        """
        self.key_attrs = {}
        self.val_attrs = {}
        if "key_attrs" in kwargs:
            self.key_attrs = kwargs.pop("key_attrs")
        if "val_attrs" in kwargs:
            self.val_attrs = kwargs.pop("val_attrs")
        Widget.__init__(self, *args, **kwargs)
Example #5
0
    def __init__(self,
                 attrs=None,
                 newline='<br/>\n',
                 sep='__',
                 col1='col-md-3',
                 col2='col-md-9',
                 debug=False):
        self.newline = newline
        self.separator = sep
        self.debug = debug
        self.css_column1 = col1
        self.css_column2 = col2

        Widget.__init__(self, attrs)
 def test_widget_attrs_default_accept(self):
     f = ImageField()
     # Nothing added for non-FileInput widgets.
     self.assertEqual(f.widget_attrs(Widget()), {})
     self.assertEqual(f.widget_attrs(FileInput()), {'accept': 'image/*'})
     self.assertEqual(f.widget_attrs(ClearableFileInput()), {'accept': 'image/*'})
     self.assertWidgetRendersTo(f, '<input type="file" name="f" accept="image/*" required id="id_f" />')
Example #7
0
    def __init__(self, *args, **kwargs):
        """A widget that displays JSON Key Value Pairs
        as a list of text input box pairs

        kwargs:
        key_attrs -- html attributes applied to the 1st input box pairs
        val_attrs -- html attributes applied to the 2nd input box pairs

        """
        self.key_attrs = {}
        self.val_attrs = {}
        if "key_attrs" in kwargs:
            self.key_attrs = kwargs.pop("key_attrs")
        if "val_attrs" in kwargs:
            self.val_attrs = kwargs.pop("val_attrs")
        Widget.__init__(self, *args, **kwargs)
Example #8
0
    def __init__(self, *args, **kwargs):
        """A widget that displays JSON Key Value Pairs
        as a list of text input box pairs

        kwargs:
        key_attrs -- html attributes applied to the 1st input box pairs
        val_attrs -- html attributes applied to the 2nd input box pairs

        """
        self.key_attrs = {}
        self.val_attrs = {}
        if "key_attrs" in kwargs:
            self.key_attrs = kwargs.pop("key_attrs")
        if "val_attrs" in kwargs:
            self.val_attrs = kwargs.pop("val_attrs")
        Widget.__init__(self, *args, **kwargs)
Example #9
0
 def test_decimalfield_widget_attrs(self):
     f = DecimalField(max_digits=6, decimal_places=2)
     self.assertEqual(f.widget_attrs(Widget()), {})
     self.assertEqual(f.widget_attrs(NumberInput()), {'step': '0.01'})
     f = DecimalField(max_digits=10, decimal_places=0)
     self.assertEqual(f.widget_attrs(NumberInput()), {'step': '1'})
     f = DecimalField(max_digits=19, decimal_places=19)
     self.assertEqual(f.widget_attrs(NumberInput()), {'step': '1e-19'})
     f = DecimalField(max_digits=20)
     self.assertEqual(f.widget_attrs(NumberInput()), {'step': 'any'})
     f = DecimalField(max_digits=6, widget=NumberInput(attrs={'step': '0.01'}))
     self.assertWidgetRendersTo(f, '<input step="0.01" name="f" type="number" id="id_f" required>')
Example #10
0
 def __init__(self, attrs=None, newline='<br/>\n', sep='__', debug=False):
     self.newline = newline
     self.separator = sep
     self.debug = debug
     Widget.__init__(self, attrs)
Example #11
0
 def test_value_omitted_from_data(self):
     widget = Widget()
     self.assertIs(widget.value_omitted_from_data({}, {}, 'field'), True)
     self.assertIs(
         widget.value_omitted_from_data({'field': 'value'}, {}, 'field'),
         False)
 def __init__(self, attrs=None, newline='<br/>\n', sep='__', debug=False):
     self.newline = newline
     self.separator = sep
     self.debug = debug
     Widget.__init__(self, attrs)
Example #13
0
 def test_format_value(self):
     widget = Widget()
     self.assertIsNone(widget.format_value(None))
     self.assertIsNone(widget.format_value(''))
     self.assertEqual(widget.format_value('español'), 'español')
     self.assertEqual(widget.format_value(42.5), '42.5')
Example #14
0
 def test_format_value(self):
     widget = Widget()
     self.assertIsNone(widget.format_value(None))
     self.assertIsNone(widget.format_value(''))
     self.assertEqual(widget.format_value('español'), 'español')
     self.assertEqual(widget.format_value(42.5), '42.5')
Example #15
0
 def test_value_omitted_from_data(self):
     widget = Widget()
     self.assertIs(widget.value_omitted_from_data({}, {}, 'field'), True)
     self.assertIs(widget.value_omitted_from_data({'field': 'value'}, {}, 'field'), False)
Example #16
0
 def __init__(self, *args, **kwargs):
     if "checked" in kwargs:
         self.checked = kwargs.pop("checked")
     Widget.__init__(self, *args, **kwargs)
Example #17
0
 def __init__(self, *args, **kwargs):
     if "checked" in kwargs:
         self.checked = kwargs.pop("checked")
     Widget.__init__(self, *args, **kwargs)
Example #18
0
 def teste_add_class(self):
     field = Widget()
     add_class(field, "teste")
     self.assertEqual('', 'Ricardo')
Example #19
0
 def test_format_value(self):
     widget = Widget()
     self.assertIsNone(widget.format_value(None))
     self.assertIsNone(widget.format_value(""))
     self.assertEqual(widget.format_value("español"), "español")
     self.assertEqual(widget.format_value(42.5), "42.5")
Example #20
0
 def test_value_omitted_from_data(self):
     widget = Widget()
     self.assertIs(widget.value_omitted_from_data({}, {}, "field"), True)
     self.assertIs(
         widget.value_omitted_from_data({"field": "value"}, {}, "field"),
         False)