Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Dutch local flavor. #152

Merged
merged 1 commit into from
Dec 2, 2015
Merged

Conversation

jieter
Copy link
Contributor

@jieter jieter commented May 9, 2015

This is my initial attempt on #150. As of now, nothing is (or at least should be) renamed or deprecated. This is what I did:

  • Move validators to validators.py
  • Add model fields for existing form fields
  • Add form fields for existing model fields
  • Move tests to tests/test_nl/
  • Increase test coverage.
  • Tried to make the error messages a bit more consistent.

Known issues / TODOs:

  • Add docstrings
  • Tests fail with django 1.5: RegExvalidator somehow fails with message Enter a valid value. and not Enter a valid zip code.. Any pointers to fix this?

Please review!

@jieter
Copy link
Contributor Author

jieter commented May 17, 2015

@erikr @benkonrath ?

@benkonrath
Copy link
Member

@jieter Sorry, this fell off my radar. I'll try to look at it later today.

"""
Validation for Dutch Sofinummers.

TODO: consider renaming to BSN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree that it should be changed to BSN but let's do this as separate issue.

@benkonrath
Copy link
Member

Besides those small points, it looks good. If you can fix these points, figure why the tests fail on 1.5 and get the docstrings written, then we can try to get it in the next release which is due shortly. Otherwise we'll shoot for the release after next when 1.5 support is dropped as per #170.

@benkonrath benkonrath self-assigned this Sep 2, 2015
message=self.default_error_messages['invalid'])
self.no_leading_zeros_regex = re.compile('[1-9]+')
def to_python(self, value):
return '%s %s' % (value[:4], value[4:])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a problem here. This is adding an extra space when the model field is used with the form field. For example, if I enter '1000AA', I will get the error message: 'Ensure this value has at most 7 characters (it has 8).' because the form adds a space and then this adds a space. You'll need to check if the space is already there before adding it. You should also add a test for this. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just save it in the database without space and present it with a space?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this seems to be fixed by the last commit I pushed.

@jieter
Copy link
Contributor Author

jieter commented Sep 3, 2015

Thanks for the feedback, I'll come back to this, hopefully next week. The delay pushed it somewhat down on my todo-list...

@benkonrath
Copy link
Member

Understandable. I'll keep my eyes peeled for your update. Thanks.

@jieter
Copy link
Contributor Author

jieter commented Sep 9, 2015

Just pushed some improvements. I'm not going to invest time in adding 1.5 support if it's about to be removed anyway, so I'll guess we have to wait until after the next release then?

Still working on the last bits to get this tested.

@jieter jieter force-pushed the nl-model-fields branch 2 times, most recently from acdf6e9 to be8db15 Compare September 9, 2015 08:24
@benkonrath
Copy link
Member

I think it makes sense to wait until localflavor 1.2 is released so that we can skip trying to fix the errors with Django 1.5. Although I'm not sure when that's going to happen.

The bug in the NL postal code model field in fact fixed but it would be nice to rework that bit of code to be more like the IBAN model.

You should make sure you get 100% test coverage. There's a bit of the NL postal code model field that isn't tested and the bank account model field isn't tested as well. I know that we want to deprecate and drop the EU bank account fields but we should keep the tests in until the fields are removed.

Thanks for your work on this.

@jieter
Copy link
Contributor Author

jieter commented Sep 10, 2015

  • Just noticed that I added forms.NLBankaccountField in this branch, so I removed it. We should not add new code to deprecate it immediately.
  • re-added the test for the bank account model field, you're right about that.
  • test coverage is now at 100%.
  • the Zip code form field needs the six.string_types check because apparently an array might be passed.

@benkonrath
Copy link
Member

Nice catch on the forms.NLBankaccountField - I did see it but I just assumed it was already there. Nice work here - l'll merge this after localflavor 1.2 is released.

@benkonrath
Copy link
Member

I forgot to mention that you should rebase this and squash all your commits into one. Thanks.

@jieter
Copy link
Contributor Author

jieter commented Sep 11, 2015

yes, will do. And what about the .. versionadded:: TODO markers?

@benkonrath
Copy link
Member

We'll have to wait to see what the version will be after 1.2. You can wait to squash everything once the versionadded comments are in.

@jieter
Copy link
Contributor Author

jieter commented Sep 11, 2015

Will squash again then.

@benkonrath benkonrath added this to the 1.3 milestone Nov 22, 2015
@jieter
Copy link
Contributor Author

jieter commented Nov 28, 2015

All tests pass now, should I extend the docstrings with ..versionadded::1.3 now?

@benkonrath
Copy link
Member

Yeah, ..versionadded:: 1.3 would be great for any new classes.

Can you also add an entry to the changelog for this PR? The moved validator classes should be specifically mentioned as a breaking change so users know they will need to adjust their imports. I want to setup a deprecation policy for localflavor but we can sort that out before the next release.

The final (small) change it to reset the commit date. Simply running git commit --amend --reset-author on your branch should take care of it.

jieter added a commit to jieter/django-localflavor that referenced this pull request Dec 1, 2015
 - Move validators to validators.py
 - Add model fields for existing form fields
 - Add form fields for existing model fields (except for NLBankAccountField)
 - Move tests to `tests/test_nl/`
 - Increase test coverage to 100%
 - More consistent error messages.
@jieter
Copy link
Contributor Author

jieter commented Dec 1, 2015

This should do it.

benkonrath added a commit that referenced this pull request Dec 2, 2015
@benkonrath benkonrath merged commit 6b37fc4 into django:master Dec 2, 2015
@benkonrath
Copy link
Member

@jieter Thanks for your work on this!

@jieter jieter deleted the nl-model-fields branch April 5, 2016 09:55
@jieter
Copy link
Contributor Author

jieter commented Apr 5, 2016

@benkonrath any idea on when a version containing this PR is going to be released to pypi?

@jieter jieter restored the nl-model-fields branch April 5, 2016 10:19
@benkonrath
Copy link
Member

@jieter Within the next week or two I hope. See my comment about this in #205.

@jieter
Copy link
Contributor Author

jieter commented Apr 10, 2016

I see, thanks for the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants