Opened 16 years ago
Closed 12 years ago
#8273 closed Cleanup/optimization (wontfix)
Reduce amount of redundant code in django.contrib.localflavor
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.localflavor | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | jwilk@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
There is a plenty of somehow redundant code in django.contrib.localflavor
which leads to potentially more bugs and what is quite inconvenient -- many translation strings.
I would like to propose the patch that handles all fields with a checksum verification.
Pros:
- a lot fewer translation strings, which is more consistent and means less work when translating Django to 50 languages,
- DRY compatible (and all benefits that it implies).
Cons:
- backwards incompatible,
- new code may contain bugs (although all tests were OK).
I volunteer for further modifications of django.contrib.localflavor
code to use NumberWithChecksumField
if this patch is accepted.
Attachments (1)
Change History (11)
by , 16 years ago
Attachment: | localflavor-numberwithchecksumfield.patch added |
---|
comment:1 by , 16 years ago
comment:2 by , 16 years ago
milestone: | → post-1.0 |
---|---|
Triage Stage: | Unreviewed → Accepted |
It should be possible to do this in a backwards-compatible fashion by declaring specific classes in each localflavor that are specific cases of a parameterised parent class. The intention here is good, since there is some quite apparent duplication, but right now isn't the time to be shuffling this code around. Let's table until after 1.0.
comment:3 by , 16 years ago
Cc: | added |
---|
comment:5 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Cleanup/optimization |
comment:6 by , 14 years ago
Easy pickings: | unset |
---|---|
Patch needs improvement: | set |
Patch needs improvement as per Malcolm's comment.
comment:7 by , 14 years ago
Cc: | added |
---|
comment:8 by , 14 years ago
Cc: | removed |
---|
comment:10 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Localflavor has just been split in distinct repositories, making this refactoring significantly harder and less likely to happen.
Besides, I think that descriptive error messages are important for usability, even if they come at the cost of more translation strings.
I forgot to mention that this patch also fixes a bug in
PLNationalBusinessRegisterField
. This field should accept also 14-digit numbers (see http://www.stat.gov.pl/bip/389_117_ENG_HTML.htm for reference).