コード例 #1
0
ファイル: filter.py プロジェクト: susansan/wagtail-daterange
 def _get_form_fields(self):
     return OrderedDict((
         (self.lookup_kwarg_gte,
          forms.DateTimeField(label='',
                              widget=widgets.AdminDateTimeInput(
                                  attrs={'placeholder': _('From date')}),
                              localize=True,
                              required=False)),
         (self.lookup_kwarg_lte,
          forms.DateTimeField(label='',
                              widget=widgets.AdminDateTimeInput(
                                  attrs={'placeholder': _('To date')}),
                              localize=True,
                              required=False)),
     ))
コード例 #2
0
    def test_render_js_init_with_format_from_settings(self):
        widget = widgets.AdminDateTimeInput()

        html = widget.render('test', None, attrs={'id': 'test-id'})
        self.assertIn(
            '"format": "d.m.Y. H:i"',
            html,
        )
コード例 #3
0
    def test_render_js_init_with_format(self):
        widget = widgets.AdminDateTimeInput(format='%d.%m.%Y. %H:%M')

        html = widget.render('test', None, attrs={'id': 'test-id'})
        self.assertIn(
            '"format": "d.m.Y. H:i"',
            html,
        )
コード例 #4
0
    def test_render_js_init_with_format_from_settings(self):
        widget = widgets.AdminDateTimeInput()

        js_init = widget.render_js_init('test-id', 'test', None)
        self.assertIn(
            '"format": "d.m.Y. H:i"',
            js_init,
        )
コード例 #5
0
    def test_render_js_init_with_format(self):
        widget = widgets.AdminDateTimeInput(format='%d.%m.%Y. %H:%M')

        js_init = widget.render_js_init('test-id', 'test', None)
        self.assertIn(
            '"format": "d.m.Y. H:i"',
            js_init,
        )
コード例 #6
0
ファイル: test_widgets.py プロジェクト: tomkins/wagtail
    def test_adapt(self):
        widget = widgets.AdminDateTimeInput()

        js_args = widgets.AdminDateTimeInputAdapter().js_args(widget)

        self.assertEqual(
            js_args[0],
            {"dayOfWeekStart": 0, "format": "Y-m-d H:i", "formatTime": "H:i"},
        )
コード例 #7
0
    def test_adapt(self):
        widget = widgets.AdminDateTimeInput()

        js_args = widgets.AdminDateTimeInputAdapter().js_args(widget)

        self.assertEqual(js_args[0], {
            'dayOfWeekStart': 0,
            'format': 'Y-m-d H:i',
            'formatTime': 'H:i'
        })
コード例 #8
0
ファイル: test_widgets.py プロジェクト: tomkins/wagtail
    def test_adapt_with_custom_format(self):
        widget = widgets.AdminDateTimeInput(
            format="%d.%m.%Y. %H:%M", time_format="%H:%M %p"
        )

        js_args = widgets.AdminDateTimeInputAdapter().js_args(widget)

        self.assertEqual(
            js_args[0],
            {"dayOfWeekStart": 0, "format": "d.m.Y. H:i", "formatTime": "H:i A"},
        )
コード例 #9
0
    def test_render_js_init(self):
        widget = widgets.AdminDateTimeInput()

        js_init = widget.render_js_init('test-id', 'test', None)

        # we should see the JS initialiser code:
        # initDateTimeChooser("test-id", {"dayOfWeekStart": 0, "format": "Y-m-d H:i"});
        # except that we can't predict the order of the config options
        self.assertIn('initDateTimeChooser("test-id", {', js_init)
        self.assertIn('"dayOfWeekStart": 0', js_init)
        self.assertIn('"format": "Y-m-d H:i"', js_init)
コード例 #10
0
    def test_adapt_with_custom_format(self):
        widget = widgets.AdminDateTimeInput(format='%d.%m.%Y. %H:%M',
                                            time_format='%H:%M %p')

        js_args = widgets.AdminDateTimeInputAdapter().js_args(widget)

        self.assertEqual(js_args[0], {
            'dayOfWeekStart': 0,
            'format': 'd.m.Y. H:i',
            'formatTime': 'H:i A'
        })
コード例 #11
0
ファイル: test_widgets.py プロジェクト: tomkins/wagtail
    def test_render_js_init_with_format_from_settings(self):
        widget = widgets.AdminDateTimeInput()

        html = widget.render("test", None, attrs={"id": "test-id"})
        self.assertIn(
            '"format": "d.m.Y. H:i"',
            html,
        )
        self.assertIn(
            '"formatTime": "H:i A"',
            html,
        )
コード例 #12
0
ファイル: test_widgets.py プロジェクト: jams2/wagtail
    def test_render_js_init_with_format(self):
        widget = widgets.AdminDateTimeInput(format="%d.%m.%Y. %H:%M",
                                            time_format="%H:%M %p")

        html = widget.render("test", None, attrs={"id": "test-id"})
        self.assertIn(
            '"format": "d.m.Y. H:i"',
            html,
        )
        self.assertIn(
            '"formatTime": "H:i A"',
            html,
        )
コード例 #13
0
    def test_render_js_init(self):
        widget = widgets.AdminDateTimeInput()

        html = widget.render('test', None, attrs={'id': 'test-id'})

        self.assertInHTML('<input type="text" name="test" autocomplete="off" id="test-id" />', html)

        # we should see the JS initialiser code:
        # initDateTimeChooser("test-id", {"dayOfWeekStart": 0, "format": "Y-m-d H:i"});
        # except that we can't predict the order of the config options
        self.assertIn('initDateTimeChooser("test\\u002Did", {', html)
        self.assertIn('"dayOfWeekStart": 0', html)
        self.assertIn('"format": "Y-m-d H:i"', html)