Skip to content

Commit

Permalink
fix Djano routes (#1685)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Jun 18, 2024
1 parent 9394790 commit 64dbbf1
Showing 1 changed file with 37 additions and 63 deletions.
100 changes: 37 additions & 63 deletions pygeoapi/django_/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ def tilematrixsets(request: HttpRequest,
:returns: Django HTTP Response
"""

response = None

if tilematrixset_id is None:
response_ = _feed_response(request, 'tilematrixsets')
response_ = execute_from_django(tiles_api.tilematrixsets, request)
else:
response_ = _feed_response(request, 'tilematrixset', tilematrixset_id)
response = _to_django_response(*response_)
response_ = execute_from_django(tiles_api.tilematrixsets, request,
tilematrixset_id)

return response
return response_


def collections(request: HttpRequest,
Expand All @@ -129,9 +127,8 @@ def collections(request: HttpRequest,
"""

response_ = _feed_response(request, 'describe_collections', collection_id)
response = _to_django_response(*response_)

return response
return _to_django_response(*response_)


def collection_schema(request: HttpRequest,
Expand All @@ -145,12 +142,8 @@ def collection_schema(request: HttpRequest,
:returns: Django HTTP Response
"""

response_ = _feed_response(
request, 'get_collection_schema', collection_id
)
response = _to_django_response(*response_)

return response
return execute_from_django(itemtypes_api.get_collection_schema, request,
collection_id)


def collection_queryables(request: HttpRequest,
Expand All @@ -164,12 +157,9 @@ def collection_queryables(request: HttpRequest,
:returns: Django HTTP Response
"""

response_ = execute_from_django(
return execute_from_django(
itemtypes_api.get_collection_queryables, request, collection_id
)
response = _to_django_response(*response_)

return response


def collection_items(request: HttpRequest, collection_id: str) -> HttpResponse:
Expand Down Expand Up @@ -204,9 +194,7 @@ def collection_items(request: HttpRequest, collection_id: str) -> HttpResponse:
request, 'options', collection_id,
skip_valid_check=True)

response = _to_django_response(*response_)

return response
return response_


def collection_map(request: HttpRequest, collection_id: str):
Expand All @@ -217,6 +205,7 @@ def collection_map(request: HttpRequest, collection_id: str):
:returns: HTTP response
"""

return execute_from_django(
maps_api.get_collection_map, request, collection_id
)
Expand All @@ -233,13 +222,9 @@ def collection_style_map(request: HttpRequest, collection_id: str,
:returns: HTTP response
"""

response_ = _feed_response(request, 'get_collection_map',
return execute_from_django(maps_api.get_collection_map, request,
collection_id, style_id)

response = _to_django_response(*response_)

return response


def collection_item(request: HttpRequest,
collection_id: str, item_id: str) -> HttpResponse:
Expand All @@ -254,27 +239,22 @@ def collection_item(request: HttpRequest,
"""

if request.method == 'GET':
response_ = _feed_response(
request, 'get_collection_item', collection_id, item_id
)
response_ = execute_from_django(itemtypes_api.get_collection_item,
request, collection_id, item_id)
elif request.method == 'PUT':
response_ = _feed_response(
request, 'manage_collection_item', request, 'update',
collection_id, item_id, skip_valid_check=True,
)
response_ = execute_from_django(itemtypes_api.manage_collection_item,
request, 'update', collection_id,
item_id, skip_valid_check=True)
elif request.method == 'DELETE':
response_ = _feed_response(
request, 'manage_collection_item', request, 'delete',
collection_id, item_id, skip_valid_check=True,
)
response_ = execute_from_django(itemtypes_api.manage_collection_item,
request, 'delete', collection_id,
item_id, skip_valid_check=True)
elif request.method == 'OPTIONS':
response_ = _feed_response(
request, 'manage_collection_item', request, 'options',
collection_id, item_id, skip_valid_check=True)

response = _to_django_response(*response_)
response_ = execute_from_django(itemtypes_api.manage_collection_item,
request, 'options', collection_id,
item_id, skip_valid_check=True)

return response
return response_


def collection_coverage(request: HttpRequest,
Expand All @@ -288,12 +268,9 @@ def collection_coverage(request: HttpRequest,
:returns: Django HTTP response
"""

response_ = execute_from_django(
return execute_from_django(
coverages_api.get_collection_coverage, request, collection_id
)
response = _to_django_response(*response_)

return response


def collection_tiles(request: HttpRequest, collection_id: str) -> HttpResponse:
Expand Down Expand Up @@ -325,7 +302,7 @@ def collection_tiles_metadata(request: HttpRequest, collection_id: str,
return execute_from_django(
tiles_api.get_collection_tiles_metadata,
request, collection_id, tileMatrixSetId,
skip_valid_check=True,
skip_valid_check=True
)


Expand Down Expand Up @@ -353,7 +330,7 @@ def collection_item_tiles(request: HttpRequest, collection_id: str,
tileMatrix,
tileRow,
tileCol,
skip_valid_check=True,
skip_valid_check=True
)


Expand Down Expand Up @@ -398,13 +375,16 @@ def jobs(request: HttpRequest, job_id: Optional[str] = None) -> HttpResponse:
"""

if job_id is None:
return execute_from_django(processes_api.get_jobs, request)
response_ = execute_from_django(processes_api.get_jobs, request)
else:
if request.method == 'DELETE': # dismiss job
return execute_from_django(processes_api.delete_job, request,
job_id)
response_ = execute_from_django(processes_api.delete_job, request,
job_id)
else: # Return status of a specific job
return execute_from_django(processes_api.get_jobs, request, job_id)
response_ = execute_from_django(processes_api.get_jobs, request,
job_id)

return response_


def job_results(request: HttpRequest,
Expand Down Expand Up @@ -434,15 +414,8 @@ def job_results_resource(request: HttpRequest, process_id: str, job_id: str,
"""

# TODO: this api method does not exist
response_ = _feed_response(
request,
'get_job_result_resource',
job_id,
resource
)
response = _to_django_response(*response_)

return response
return execute_from_django(processes_api.get_job_result_resource,
request, job_id, resource)


def get_collection_edr_query(
Expand All @@ -465,14 +438,15 @@ def get_collection_edr_query(
query_type = 'locations'
else:
query_type = request.path.split('/')[-1]

return execute_from_django(
edr_api.get_collection_edr_query,
request,
collection_id,
instance_id,
query_type,
location_id,
skip_valid_check=True,
skip_valid_check=True
)


Expand Down

0 comments on commit 64dbbf1

Please sign in to comment.