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

Add field for greek Social Security Number (AMKA) #337

Merged
merged 7 commits into from
Jul 21, 2018

Conversation

spapas
Copy link
Contributor

@spapas spapas commented Jun 1, 2018

  • [x ] Add an entry to the docs/changelog.rst describing the change.

  • [Was there ] Add an entry for your name in the docs/authors.rst file if it's not
    already there.

  • [x ] Adjust your imports to a standard form by running this command:

    `isort --recursive --line-width 120 localflavor tests`
    

@codecov-io
Copy link

codecov-io commented Jun 1, 2018

Codecov Report

Merging #337 into master will decrease coverage by 0.07%.
The diff coverage is 85.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #337      +/-   ##
==========================================
- Coverage   95.89%   95.82%   -0.08%     
==========================================
  Files         153      153              
  Lines        3851     3878      +27     
  Branches      512      517       +5     
==========================================
+ Hits         3693     3716      +23     
- Misses         96       98       +2     
- Partials       62       64       +2
Impacted Files Coverage Δ
localflavor/gr/forms.py 90.32% <85.18%> (-3.97%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d94f35c...973004d. Read the comment docs.

@spapas
Copy link
Contributor Author

spapas commented Jun 1, 2018

Finally, this PR should be ready for merge!

As a general notice, submitting code to this repository is way to difficult, it took me like 50 times more time to fix the various satellite things (submission changes, isort imports, prospector warnings, codecov etc) than to write the actual code for the new FormField!

I recommend opening an issue for discussing this problem a bit...

Copy link
Member

@benkonrath benkonrath left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution and sorry for the delay in getting to this. There are a few changes that are needed before this PR can be merged. I'll try to respond quicker when you make an updated version.

Sorry to hear that you had trouble with the code checks. I setup these checks so that the localflavor maintainers don't have to manually look for the code consistency that we're aiming for and so that we don't need to repeat the same feedback for every PR. I understand that it adds a little more work to submitting a PR but I feel it's worth the extra effort to keep the code more consistent across a large number of contributors and to help keep the code quality high. Thanks for understanding.

I'm looking forward to reviewing your updated version. Hopefully we can get this feature into the 2.1 release.

@@ -60,3 +61,56 @@ def clean(self, value):
if mod != check:
raise ValidationError(self.error_messages['invalid'])
return val


class GRSocialSecurityNumberCodeField(Field):
Copy link
Member

Choose a reason for hiding this comment

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

It would be better use RegexField instead of Field. You would then set the regex on the call to super.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

except:
raise ValidationError(self.error_messages['invalid'])

def check_lunh(self, val):
Copy link
Member

Choose a reason for hiding this comment

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

Please use the lunh function that's already in localflavor instead of including your own version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

def clean(self, value):
super(GRSocialSecurityNumberCodeField, self).clean(value)
if value in EMPTY_VALUES:
return ''
Copy link
Member

Choose a reason for hiding this comment

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

I think you won't need this check if you inherit from RegexField since there are checks for empty values in CharField.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this:

        if value in self.empty_values:
            return self.empty_value

was needed or else the test test_forms_char_field_empty_value_allows_none would fail.

Copy link
Member

Choose a reason for hiding this comment

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

Ok cool. Thanks for catching that.

@@ -14,7827 +14,10656 @@ msgid ""
msgstr ""
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the changes to this file. The localflavors take care of updating the translation files (which are managed through Transifex).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I restored it to the previous version

@spapas
Copy link
Contributor Author

spapas commented Jul 19, 2018

Hello @benkonrath, I've implemented the requested changes, I hope the PR will get merged soon!

Concerning my rant about the work needed for the PR, I understand that you want to have some standards for contributed code, however think about how much work is needed for guys that don't do this every day. You probably have setup your environments, tox, isort, prospector etc so that you can write code that passes all the tests automatically however most people don't have that comfort.

I consider myself a rather experienced developer and setting up all the things needed to make the contribution and fixing things up was a major PITA; if I knew that it needed so much work just to add a form field (which I already use in my project) then I probably wouldn't bother at all. I had contributed some other fields before some years when each localflavor package was separate (https://github.com/spapas/django-localflavor-gr) the process back then was very easy.

In any case, concerning the nature of the project (localflavor needs contributions for many people across the globe; you can't substitute quality for quantity here) I think that it does not make sense to have the same contribution standards as with Django. You need to lower your standards to encourage more contributions. After all, most of these contributions are values lists and form fields. The people that are maintaining this project can pick the individual contributions and make them as good as they want; however you don't want to discourage from contributing by making them jump hoops.

I hope you get the idea about my initial rant, really sorry if I ranted again trying to explain my thoughs!

Best regards and thanks for your work,
Serafeim

@benkonrath benkonrath merged commit 3238773 into django:master Jul 21, 2018
@benkonrath
Copy link
Member

@spapas Thanks again for your contribution.

I see your point about making it easier to contribute to localflavor. I think we just have a different value on what's a suitable quality level for this project. Perhaps we could improve the documentation on how to test locally rather than having to wait for Travis to fail. Suggestions or PRs for this would be helpful.

I'm not the last word on this. I'm only the most active localflavor maintainer at the moment. If you want to discuss this further, perhaps you could open a new issue about this like you suggested. Just a warning though, I don't know if you'll get much of a response because the other maintainers aren't too active these days. People who watch the repo can also comment here if they have an opinion about this.

@claudep
Copy link
Member

claudep commented Jul 22, 2018

It's not easy to draw the balance between code quality and ease of contribution. For me, testing/coverage is a must and we shouldn't lower that quality requirement. It's one of the Django mantras: "untested code is broken code".
I'm not so much convinced about other style-related requirements. That stuff could also be handled by the committer at a final stage. On the other hand, it may encourage devs to adopt good coding habits.

@spapas
Copy link
Contributor Author

spapas commented Jul 22, 2018

Hello @benkonrath thank you very much for merging my PR!

Now, for the quality/easy of contribution, I understand your concerns and am all in for code quality. However I agree with @claudep that the bar for contributions is too high for most developers and, due to the nature of the project as explained in my previous comment, it would be better to lower it a bit to encourage more contributions (and merging existing ones). I believe that being able to find some specific form fields for your country is a factor that weights when you are a lone developer in (f.e) Greece and want to decide which framework you'll want to learn!

In any case, what was in my mind would be to allow and quickly merge even non perfect PRs that would then be fixed/improved (by adding more tests, complying with PEP8 etc) by the original contributor or the maintainers; you'll add an issue with what is missing and then assign it to the original contributor; if he doesn't fix it after a while then a maintainer will step up and fix it for him.

However after Ben's previous comment (that most maintainers are not so active) I'm not sure if that's possible because it will add a lot of effort to the maintainers (to add the corresponding issue and fix it if needed) so probably the contribution workflow should stay as it for now :/

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.

4 participants