Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8556 closed (fixed)

models.CommaSeperatedIntegerField doesn't return a forms field of any use

Reported by: Alex Gaynor Owned by: nobody
Component: Forms Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

CommaSeperatedIntegerField just returns a normal charfield, which obviously preforms no validation that it matches the purpose of the field.

Attachments (3)

74333.patch (626 bytes ) - added by gkelly 16 years ago.
Patch to return formfield using regex
8556-1.diff (2.1 KB ) - added by Matt McClanahan 16 years ago.
Add admin widget
8556-tests.diff (1.2 KB ) - added by Ivan Giuliani 16 years ago.
Unit tests for this ticket

Download all attachments as: .zip

Change History (11)

comment:1 by Jacob, 16 years ago

Triage Stage: UnreviewedAccepted

by gkelly, 16 years ago

Attachment: 74333.patch added

Patch to return formfield using regex

by Matt McClanahan, 16 years ago

Attachment: 8556-1.diff added

Add admin widget

comment:2 by Matt McClanahan, 16 years ago

Has patch: set

comment:3 by Alex Gaynor, 16 years ago

Needs tests: set

comment:4 by Ivan Giuliani, 16 years ago

The regexp used in the patch is not completely right, it matches too many things:

>>> x = re.compile("^[\d,]+$")
>>> 
>>> type(x.match("1,2,3"))
<type '_sre.SRE_Match'>
>>> type(x.match(",1,2,3"))
<type '_sre.SRE_Match'>
>>> type(x.match("1,2,3,"))
<type '_sre.SRE_Match'>
>>> type(x.match("1,,,,2,,,,,3,,,"))
<type '_sre.SRE_Match'>
>>> type(x.match("1.2"))
<type 'NoneType'>
>>> type(x.match(",,,,,"))
<type '_sre.SRE_Match'>

I guess the problem is in "[\d,]" since the square brackets don't care about the order of the specified chars. Or maybe django should allow that strings?

comment:5 by Jacob, 16 years ago

The regex is fine; all this needs is some tests.

by Ivan Giuliani, 16 years ago

Attachment: 8556-tests.diff added

Unit tests for this ticket

comment:6 by Ivan Giuliani, 16 years ago

Needs tests: unset

comment:7 by Jacob, 16 years ago

Resolution: fixed
Status: newclosed

(In [8682]) Fixed #8556: added a useful formfield to CommaSeparatedIntegerField. gkelly, mattmcc, and kratorius all contributed portions of this patch.

comment:8 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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