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

Bbox validation #100

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

Bbox validation #100

wants to merge 6 commits into from

Conversation

finnshort
Copy link
Contributor

Adds validation to bounding box input by user when downloading json data. Previously, an error parsing or using the bounding box params would result in a 500 error. Now server returns a more useful error message with status code 400 (bad request).

Example test:
bikemaps.org/incidents.json?bbox="-123.3,49.0,-122.7,49.3"

Opening a PR for review but pushing this branch to prod as a hotfix in the meantime.

@finnshort finnshort requested a review from dgboss July 8, 2023 01:19
User = get_user_model()

class CollisionList(APIView):
"""
List all collisions, or create a new collision.
"""
def get(self, request, format=None):
try:
# Extract bounding box Url parameter
bbstr = request.GET.get('bbox', '-180,-90,180,90')
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider pulling this out into a small helper function to reduce code duplication.

Copy link
Contributor

@dgboss dgboss left a comment

Choose a reason for hiding this comment

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

Looks good, just a suggestion to factor out a helper function.

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.

None yet

2 participants