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

feat: Provide possibility to display specific countries in SelectCountryBone #1121

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

cheeaza
Copy link
Contributor

@cheeaza cheeaza commented Mar 22, 2024

There was no possibility to limit the set of available countries in a selectcountryBone.
I added the parameter countries to limit it. I also updated the docstring.

@cheeaza cheeaza added the feature New feature or request label Mar 22, 2024
@cheeaza cheeaza requested a review from phorward March 22, 2024 14:11
@cheeaza cheeaza added the Priority: Low This issue can be considered with enough idle time. label Mar 22, 2024
@cheeaza cheeaza marked this pull request as ready for review March 25, 2024 10:44
Copy link
Member

@phorward phorward left a comment

Choose a reason for hiding this comment

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

Hello @cheeaza,

thanks for creating this pull request. Your implementation might work, but I think the SelectCountryBone is implemented very bad and old fashioned, and should generally be refactored so that it gets back closer to the SelectBone.

  1. The current globals ISO2CODES and ISO3CODES should become part of the SelectCountryBone class, so they can be accessed via SelectCountryBone.ISO2 and SelectCountryBone.ISO3.
  2. The signature of the __init__ function should become
    def __init__(
        self,
        *,
        descr="Country",  # default description
        values=SelectCountryBone.ISO2,  # default code set
        **kwargs
     ):
  3. Afterwards, the behavior defaults to the same as before. In case one wants to filter only specific countries, this can be done with a simple comprehension, like
    deliver_to = SelectCountryBone(
        values={
            k: v for k, v in SelectCountryBone.ISO2 if k in ("de", "en")
        }
    )
  4. The current codes-parameter could still be supported with a deprecation warning.

I hope you're with me in this case. Would you like to propose an alternative to this pull request?

Comment on lines +759 to +760
:params dict countries: Dictionary with subset of countries from ISO 3166-1 list.
Represented as {'de':'Germany', 'en':'English'}
Copy link
Member

Choose a reason for hiding this comment

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

This is not consistent with the signature of the function below!

@phorward phorward changed the title added functionality to set a subset of countries, updated documentation feat: Provide possibility to display specific countries in SelectCountryBone Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request Priority: Low This issue can be considered with enough idle time.
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

None yet

2 participants