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 level indicator field on Org to complement "Limit States" #660

Open
Sandro-Meireles opened this issue Dec 2, 2020 · 1 comment
Open

Comments

@Sandro-Meireles
Copy link
Contributor

Normally in a RapidPro Org, it has a map with a single country as level 0, so the states are with level 1 and cities with level 2. In our infrastructure we have some customers who have the need to contain several countries in one Rapidpro Org, in this case, the union of all countries on the map would be level 0, a specific country would be level 1, and then level 2 would be for states or districts.

Several of our U-Report instances can use a single API-Token from a RapidPro Org. So for each country where the map in Rapidpro represents level 1, can make the selection of the map using the "Limit States" filter, however, when using this limit, the query returns only the information that is at the level 1 (countries in this case), without state details (in this case, level 2). We need to list the states contained in the country limited (level 1), that is, list all those that have level 2 and that are children of the country specified by the "Limit States".

To solve this, we can add a new field for Org in settings_common.py, it would be required=False after that, to query the data in the render_to_response method, in ureport.public.views.BoundaryView, making 1 a value default, it would be used on line 488, representing the level value to be filtered, example:

  • ureport.public.views.BoundaryView.render_to_response line 488
- location_boundaries = org_boundaries.filter(level=1)
+ location_boundaries = org_boundaries.filter(level=level_limit_states)
@norkans7
Copy link
Contributor

norkans7 commented Dec 15, 2020

@Sandro-Meireles for sites with multiple countries we show the country level only as we use the World data from

limit_states = org.get_config("common.limit_states")
and use limit_states config to only display those countries also you need to make that common.is_global = True

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

No branches or pull requests

2 participants