Opened 7 years ago

Closed 7 years ago

Last modified 3 years ago

#8556 closed (fixed)

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

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

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 7 years ago.
Patch to return formfield using regex
8556-1.diff (2.1 KB) - added by mattmcc 7 years ago.
Add admin widget
8556-tests.diff (1.2 KB) - added by kratorius 7 years ago.
Unit tests for this ticket

Download all attachments as: .zip

Change History (11)

comment:1 Changed 7 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 7 years ago by gkelly

Patch to return formfield using regex

Changed 7 years ago by mattmcc

Add admin widget

comment:2 Changed 7 years ago by mattmcc

  • Has patch set

comment:3 Changed 7 years ago by Alex

  • Needs tests set

comment:4 Changed 7 years ago by kratorius

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 Changed 7 years ago by jacob

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

Changed 7 years ago by kratorius

Unit tests for this ticket

comment:6 Changed 7 years ago by kratorius

  • Needs tests unset

comment:7 Changed 7 years ago by jacob

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

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

comment:8 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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