Opened 8 years ago

Closed 4 years ago

#5714 closed Cleanup/optimization (fixed)

Date/Time fields' clean methods need strip()

Reported by: Simon Litchfield <simon@…> Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Minor, but trailing/leading spaces throw date/time fields.

Believe it or not this has come up on two separate occasions now, so I thought I'd submit the patch.

Attachments (3)

newforms-datetime-strip.diff (1.2 KB) - added by Simon Litchfield 8 years ago.
fix5714.patch (4.3 KB) - added by mk 5 years ago.
5714.diff (9.2 KB) - added by SmileyChris 4 years ago.

Download all attachments as: .zip

Change History (11)

Changed 8 years ago by Simon Litchfield

comment:1 Changed 7 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

I'll push to a design decision, in the past these issues have been brushed off with a "create your own subclass" but I like the idea.

In fact, I'd be tempted to put a clean_strip attribute on Field (defaulting to False for most, overridden to True default for date/time fields) since this is a common request. But that's just me dreaming :)

comment:2 Changed 5 years ago by mtredinnick

  • Resolution set to duplicate
  • Status changed from new to closed
  • Triage Stage changed from Design decision needed to Accepted

Marking as a dupe of #6362.

comment:3 Changed 5 years ago by mtredinnick

  • Resolution duplicate deleted
  • Status changed from closed to reopened

comment:4 Changed 5 years ago by mtredinnick

The other ticket isn't a real-dupe. This particular data type is a no-brainer. We should strip the spaces before strptime'ing. Accepted.

comment:5 Changed 5 years ago by SmileyChris

  • Needs tests set

comment:6 Changed 5 years ago by mk

  • Needs tests unset

Changed 5 years ago by mk

Changed 4 years ago by SmileyChris

comment:7 Changed 4 years ago by gabrielhurley

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:8 Changed 4 years ago by jezdez

  • Resolution set to fixed
  • Status changed from reopened to closed

In [16137]:

Fixed #5714 -- Strip whitespaces around date and time form field values before converting it to a native type. Thanks to SmileyChris for the initial patch.

Note: See TracTickets for help on using tickets.
Back to Top