[Django] #27724: SelectDateWidget clears date and month if year is not selected

61 views
Skip to first unread message

Django

unread,
Jan 11, 2017, 5:45:10 AM1/11/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
--------------------------------------+------------------------
Reporter: tpazderka | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+------------------------
If year is not selected in `SelectDateWidget`, then all the inputs are
cleared as opposed to a state where date or month is missing.

The issue is that `SelectDateWidget.value_from_datadict` does not return a
value that would be matched by `SelectDateWidget.date_re`.

The returns from `SelectDateWidget.value_from_datadict` should probably
be formatted as follows

{{{
#!python
return '{:04d}-{:d}-{:d}'.format(y, m, d)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27724>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 11, 2017, 7:30:51 AM1/11/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+--------------------------------------

Reporter: tpazderka | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.10
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------

Comment (by tpazderka):

Another option would be to modify `SelectDateWidget.date_re` to math the
output from `value_from_datadict`

{{{
date_re = re.compile(r'(\d+)-(\d\d?)-(\d\d?)$')
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:1>

Django

unread,
Jan 11, 2017, 8:00:02 AM1/11/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+------------------------------------

Reporter: tpazderka | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:2>

Django

unread,
Jan 12, 2017, 9:37:52 AM1/12/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+-----------------------------------------------
Reporter: tpazderka | Owner: Adonys Alea Boffill
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+-----------------------------------------------
Changes (by Adonys Alea Boffill):

* status: new => assigned
* owner: nobody => Adonys Alea Boffill


--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:3>

Django

unread,
Jan 12, 2017, 11:46:53 AM1/12/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+-----------------------------------------------
Reporter: tpazderka | Owner: Adonys Alea Boffill
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+-----------------------------------------------
Changes (by Adonys Alea Boffill):

* Attachment "ticket_27724.diff" added.

Django

unread,
Jan 12, 2017, 11:55:30 AM1/12/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+-----------------------------------------------
Reporter: tpazderka | Owner: Adonys Alea Boffill
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+-----------------------------------------------
Changes (by Adonys Alea Boffill):

* has_patch: 0 => 1


Comment:

To fix this ticket I changed the regular expresion of
`SelectDateWidget.date_re` from:

{{{
date_re = re.compile(r'(\d{4})-(\d\d?)-(\d\d?)$')
}}}
to:

{{{
date_re = re.compile(r'(\d{4}|0)-(\d\d?)-(\d\d?)$')
}}}
I added `0` to the year possible value because `0` is set as default value
of year's `Select`, and I kept the restriction of 4 digits for a valid
year value. I added tests for the `SelectDateWidget.date_re` expression.

--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:4>

Django

unread,
Feb 4, 2017, 12:53:32 PM2/4/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+-----------------------------------------------
Reporter: tpazderka | Owner: Adonys Alea Boffill
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+-----------------------------------------------

Comment (by Tim Graham):

Could you please send a pull request rather than attaching a patch to the
ticket?

--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:5>

Django

unread,
Feb 10, 2017, 6:37:12 PM2/10/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+-----------------------------------------------
Reporter: tpazderka | Owner: Adonys Alea Boffill
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------+-----------------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:6>

Django

unread,
Feb 10, 2017, 7:42:42 PM2/10/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+-----------------------------------------------
Reporter: tpazderka | Owner: Adonys Alea Boffill
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------+-----------------------------------------------

Comment (by Adonys Alea Boffill):

OK Tim!, I'll work on that this week... thanks for your comment.

--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:7>

Django

unread,
Feb 23, 2017, 4:41:40 PM2/23/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+-----------------------------------------------
Reporter: tpazderka | Owner: Adonys Alea Boffill
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------+-----------------------------------------------

Comment (by Adonys Alea Boffill):

I added the pull request... https://github.com/django/django/pull/8108, I
hope to cover with all expectations.

--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:8>

Django

unread,
Mar 17, 2017, 3:13:25 PM3/17/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+-----------------------------------------------
Reporter: tpazderka | Owner: Adonys Alea Boffill
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------+-----------------------------------------------

Comment (by Adonys Alea Boffill):

Added PR (https://github.com/django/django/pull/8206) with non regressions
tests suggested by Tim!

--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:9>

Django

unread,
Mar 18, 2017, 5:55:11 PM3/18/17
to django-...@googlegroups.com
#27724: SelectDateWidget clears date and month if year is not selected
---------------------------+-----------------------------------------------
Reporter: tpazderka | Owner: Adonys Alea Boffill
Type: Bug | Status: closed
Component: Forms | Version: 1.10
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------+-----------------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"cd2ad26cc9369ea470ae72349633791c66887157" cd2ad26c]:
{{{
#!CommitTicketReference repository=""
revision="cd2ad26cc9369ea470ae72349633791c66887157"
Fixed #27724 -- Fixed SelectDateWidget redisplay if a year isn't chosen.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27724#comment:10>

Reply all
Reply to author
Forward
0 new messages