Skip to content

City select#372

Closed
Utwo wants to merge 12 commits into
code4romania:developfrom
Utwo:city-select
Closed

City select#372
Utwo wants to merge 12 commits into
code4romania:developfrom
Utwo:city-select

Conversation

@Utwo

@Utwo Utwo commented May 21, 2020

Copy link
Copy Markdown
Member

This is part 2 of the #327
Finishes the work from #368

@aramboi aramboi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I put together a hacky solution of how it would work with an autocomplete city field in my branch #368. Commit link: 1115009

I used select2 directly, though probably I would have been better off using a django package that automates some of the stuff, like https://django-select2.readthedocs.io/.

Let me know what you think.

Comment thread ro_help/hub/forms.py
"class": "cityAutoComplete",
"disabled": "true",
"data-url": reverse_lazy("city-autocomplete")
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could be problematic as it will load all 13K cities in the page select. It will make loading the registration page slower and the Code4ro partners who provided this data would not be be happy about leaving it out in the open to be scraped. (my understanding was that they are very protective of it)

Comment thread ro_help/hub/views.py
response = [{"v": row.id, "t": row.city} for row in rows]
if county:
rows = City.objects.filter(county__iexact=county).values_list("id", "city", named=True)
response = [{"id": row.id, "city": row.city} for row in rows]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One of the reasons I made this query to require 2 parameters was to make it harder to scraping this data. Although, thinking about it, having a limit of 1 characters is not offering much more complexity as it would require only about 50*26 requests to get it all.

Another reason is that you would still load on average 250 cities for every county and that is still quite a big select box.

@aramboi

aramboi commented May 22, 2020

Copy link
Copy Markdown
Member

This PR can be closed without merging. The changes needed from here were ported to PR #368 in this commit 1cf0bb3

@andreiio andreiio removed their request for review May 23, 2020 08:43
@catileptic catileptic closed this May 23, 2020
@Utwo Utwo deleted the city-select branch May 23, 2020 09:21
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.

3 participants