Django

Code

Ticket #8556 (closed: fixed)

Opened 3 months ago

Last modified 3 months ago

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

Reported by: Alex Assigned to: nobody
Milestone: 1.0 Component: Forms
Version: SVN Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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

Attachments

74333.patch (0.6 kB) - added by gkelly on 08/27/08 18:38:38.
Patch to return formfield using regex
8556-1.diff (2.1 kB) - added by mattmcc on 08/27/08 19:32:16.
Add admin widget
8556-tests.diff (1.2 kB) - added by kratorius on 08/28/08 13:08:03.
Unit tests for this ticket

Change History

08/27/08 14:18:44 changed by jacob

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

08/27/08 18:38:38 changed by gkelly

  • attachment 74333.patch added.

Patch to return formfield using regex

08/27/08 19:32:16 changed by mattmcc

  • attachment 8556-1.diff added.

Add admin widget

08/27/08 19:41:12 changed by mattmcc

  • has_patch set to 1.

08/27/08 19:41:55 changed by Alex

  • needs_tests set to 1.

08/28/08 09:46:22 changed 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?

08/28/08 11:06:36 changed by jacob

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

08/28/08 13:08:03 changed by kratorius

  • attachment 8556-tests.diff added.

Unit tests for this ticket

08/28/08 13:08:28 changed by kratorius

  • needs_tests deleted.

08/28/08 15:58:12 changed by jacob

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #8556 (models.CommaSeperatedIntegerField doesn't return a forms field of any use)




Change Properties
Action