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

Redirect error from front page postcode form #285

Closed
handelaar opened this issue Feb 21, 2017 · 6 comments
Closed

Redirect error from front page postcode form #285

handelaar opened this issue Feb 21, 2017 · 6 comments

Comments

@handelaar
Copy link
Contributor

(Version: current master, UK configuration and data, brand new install.)

Something (and I am unable to tell exactly what, sorry) causes the front-and-centre postcode lookup form POSTed to mapit.views.postcodes.postcode to fail, and redirect incorrectly to a 404 for

http://mapithost.domain.tld/postcode/mapit.views.postcodes.postcode

Possibly a missing reverse() function on the urlconf?

@handelaar
Copy link
Contributor Author

(I hasten to add that I in no way actually need that page to work, but I figure it wants logging.)

@handelaar
Copy link
Contributor Author

Page not found (404)
Request Method:	GET
Request URL:	http://mapit/postcode/mapit.views.postcodes.postcode
Using the URLconf defined in project.urls, Django tried these URL patterns, in this order:
^ ^$ [name='mapit_index']
^ ^licensing$
^ ^overview$
^ ^generations(?:\.(?P<format>html|json))?$ [name='mapit_generations']
^ ^postcode/$
^ ^postcode/(?P<postcode>[A-Za-z0-9 +]+)(?:\.(?P<format>html|json))?$ [name='mapit-postcode']
^ ^postcode/partial/(?P<postcode>[A-Za-z0-9 ]+)(?:\.(?P<format>html|json))?$ [name='mapit-postcode-partial']
^ ^area/(?P<area_id>[0-9A-Z]+)(?:\.(?P<format>html|json))?$ [name='area']
^ ^area/(?P<area_id>[0-9]+)/example_postcode(?:\.(?P<format>html|json))?$
^ ^area/(?P<area_id>[0-9]+)/children(?:\.(?P<format>html|json))?$
^ ^area/(?P<area_id>[0-9]+)/geometry$
^ ^area/(?P<area_id>[0-9]+)/touches(?:\.(?P<format>html|json))?$
^ ^area/(?P<area_id>[0-9]+)/overlaps(?:\.(?P<format>html|json))?$
^ ^area/(?P<area_id>[0-9]+)/covers(?:\.(?P<format>html|json))?$
^ ^area/(?P<area_id>[0-9]+)/covered(?:\.(?P<format>html|json))?$
^ ^area/(?P<area_id>[0-9]+)/coverlaps(?:\.(?P<format>html|json))?$
^ ^area/(?P<area_id>[0-9]+)/intersects(?:\.(?P<format>html|json))?$
^ ^area/(?P<area_id>[0-9A-Z]+)\.(?P<format>kml|geojson|wkt)$ [name='area_polygon']
^ ^area/(?P<srid>[0-9]+)/(?P<area_id>[0-9]+)\.(?P<format>kml|json|geojson|wkt)$
^ ^point/$
^ ^point/(?P<srid>[0-9]+)/(?P<x>-?\d*\.?\d+),(?P<y>-?\d*\.?\d+)(?:/(?P<bb>box))?(?:\.(?P<format>html|json))?$ [name='areas-by-point']
^ ^point/latlon/(?P<lat>-?\d*\.?\d+),(?P<lon>-?\d*\.?\d+)(?:/(?P<bb>box))?(?:\.(?P<format>html|json))?$ [name='areas-by-point-latlon']
^ ^point/osgb/(?P<e>-?\d*\.?\d+),(?P<n>-?\d*\.?\d+)(?:/(?P<bb>box))?(?:\.(?P<format>html|json))?$ [name='areas-by-point-osgb']
^ ^nearest/(?P<srid>[0-9]+)/(?P<x>-?\d*\.?\d+),(?P<y>-?\d*\.?\d+)(?:\.(?P<format>html|json))?$
^ ^areas/(?P<area_ids>[0-9]+(?:,[0-9]+)*)(?:\.(?P<format>html|json))?$
^ ^areas/(?P<area_ids>[0-9]+(?:,[0-9]+)*)\.(?P<format>kml|geojson)$
^ ^areas/(?P<srid>[0-9]+)/(?P<area_ids>[0-9]+(?:,[0-9]+)*)\.(?P<format>kml|geojson)$
^ ^areas/(?P<area_ids>[0-9]+(?:,[0-9]+)*)/geometry$
^ ^areas/(?P<type>[A-Z0-9,]*[A-Z0-9]+)(?:\.(?P<format>html|json))?$
^ ^areas/(?P<name>.+?)(?:\.(?P<format>html|json))?$
^ ^areas$
^ ^code/(?P<code_type>[^/]+)/(?P<code_value>[^/]+?)(?:\.(?P<format>html|json))?$
^admin/
The current URL, postcode/mapit.views.postcodes.postcode, didn't match any of these.

@dracos
Copy link
Member

dracos commented Feb 22, 2017

That code does work on mapit.mysociety.org:

§ curl -v -d pc=B24QA https://mapit.mysociety.org/postcode/
[…]
< Location: https://mapit.mysociety.org/postcode/B24QA.html

Ah, if you include a non-alphanumeric/space character, then the reverse of 'mapit.views.postcodes.postcode' fails, and so what you see happens:

§ curl -v -d pc=B24QA. https://mapit.mysociety.org/postcode/
[…]
< Location: https://mapit.mysociety.org/postcode/mapit.views.postcodes.postcode

We should strip those characters first, presumably.

@handelaar
Copy link
Contributor Author

3-line patch submitted for review

@handelaar
Copy link
Contributor Author

OK yes, just changing the one problematic line is a better (and also functional) solution. :)

@dracos
Copy link
Member

dracos commented Feb 23, 2017

Thanks for spotting!

@dracos dracos closed this as completed Feb 23, 2017
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 a pull request may close this issue.

2 participants