Exemplo n.º 1
0
 def _get_form_fields(self):
     return OrderedDict((
         (self.lookup_kwarg_gte,
          forms.DateField(label='',
                          widget=widgets.AdminDateInput(
                              attrs={'placeholder': _('From date')}),
                          localize=True,
                          required=False)),
         (self.lookup_kwarg_lte,
          forms.DateField(label='',
                          widget=widgets.AdminDateInput(
                              attrs={'placeholder': _('To date')}),
                          localize=True,
                          required=False)),
     ))
Exemplo n.º 2
0
    def test_render_js_init_with_format_from_settings(self):
        widget = widgets.AdminDateInput()

        html = widget.render('test', None, attrs={'id': 'test-id'})
        self.assertIn(
            '"format": "d.m.Y."',
            html,
        )
Exemplo n.º 3
0
    def test_render_js_init_with_format(self):
        widget = widgets.AdminDateInput(format='%d.%m.%Y.')

        html = widget.render('test', None, attrs={'id': 'test-id'})
        self.assertIn(
            '"format": "d.m.Y."',
            html,
        )
Exemplo n.º 4
0
    def test_render_js_init_with_format(self):
        widget = widgets.AdminDateInput(format="%d.%m.%Y.")

        html = widget.render("test", None, attrs={"id": "test-id"})
        self.assertIn(
            '"format": "d.m.Y."',
            html,
        )
Exemplo n.º 5
0
    def test_render_js_init_with_format(self):
        widget = widgets.AdminDateInput(format='%d.%m.%Y.')

        js_init = widget.render_js_init('test-id', 'test', None)
        self.assertIn(
            '"format": "d.m.Y."',
            js_init,
        )
Exemplo n.º 6
0
    def test_render_js_init_with_format_from_settings(self):
        widget = widgets.AdminDateInput()

        js_init = widget.render_js_init('test-id', 'test', None)
        self.assertIn(
            '"format": "d.m.Y."',
            js_init,
        )
Exemplo n.º 7
0
    def test_render_js_init(self):
        widget = widgets.AdminDateInput()

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

        # we should see the JS initialiser code:
        # initDateChooser("test-id", {"dayOfWeekStart": 0, "format": "Y-m-d"});
        # except that we can't predict the order of the config options
        self.assertIn('initDateChooser("test-id", {', js_init)
        self.assertIn('"dayOfWeekStart": 0', js_init)
        self.assertIn('"format": "Y-m-d"', js_init)
Exemplo n.º 8
0
    def test_render_js_init(self):
        widget = widgets.AdminDateInput()

        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:
        # initDateChooser("test-id", {"dayOfWeekStart": 0, "format": "Y-m-d"});
        # except that we can't predict the order of the config options
        self.assertIn('initDateChooser("test\\u002Did", {', html)
        self.assertIn('"dayOfWeekStart": 0', html)
        self.assertIn('"format": "Y-m-d"', html)
Exemplo n.º 9
0
class ProjectsPage(Page):
    parent_page_types = ["projects.ProjectsListingPage"]
    summary = models.TextField(
        blank=False,
        max_length=500,
        help_text='Give a brief summary of the project. Additional details may be included in this page further down if necessary.'
    )

    languages_used = models.TextField(
        blank=False,
        max_length=100,
        help_text='List all the languages used seperating by comma and connecting the last language with an "and"'
    )

    project_image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=False,
        on_delete=models.SET_NULL,
        help_text='Insert an image to be used for the project. It will be cropped to 570px by 370px',
        related_name="+",
    )

    date_started = models.DateField()

    date_widget = widgets.AdminDateInput(
        attrs = {
            'placeholder': 'dd-mm-yyyy'
        }
    )

    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("text", blocks.TextBlock()),
        ("image", blocks.ImageBlock()),
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel("summary"),
            FieldPanel("languages_used"),
            ImageChooserPanel("project_image"),
            FieldPanel("date_started", widget=date_widget),
        ], heading="standard details"),
        StreamFieldPanel("body"),
    ]
Exemplo n.º 10
0
    def test_adapt_with_custom_format(self):
        widget = widgets.AdminDateInput(format="%d.%m.%Y")

        js_args = widgets.AdminDateInputAdapter().js_args(widget)

        self.assertEqual(js_args[0], {"dayOfWeekStart": 0, "format": "d.m.Y"})
Exemplo n.º 11
0
    def test_adapt(self):
        widget = widgets.AdminDateInput()

        js_args = widgets.AdminDateInputAdapter().js_args(widget)

        self.assertEqual(js_args[0], {"dayOfWeekStart": 0, "format": "Y-m-d"})
Exemplo n.º 12
0
    def test_adapt_with_custom_format(self):
        widget = widgets.AdminDateInput(format='%d.%m.%Y')

        js_args = widgets.AdminDateInputAdapter().js_args(widget)

        self.assertEqual(js_args[0], {'dayOfWeekStart': 0, 'format': 'd.m.Y'})
Exemplo n.º 13
0
    def test_adapt(self):
        widget = widgets.AdminDateInput()

        js_args = widgets.AdminDateInputAdapter().js_args(widget)

        self.assertEqual(js_args[0], {'dayOfWeekStart': 0, 'format': 'Y-m-d'})