Skip to content

Commit

Permalink
fix missing Django processes endpoints (#1592) (#1627)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis authored Apr 14, 2024
1 parent bf31885 commit 21b8672
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
7 changes: 6 additions & 1 deletion docs/source/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,13 @@ main Django application urls:
]
This integration can be seen in the provided example Django project. Refer to `examples/django/sample_project/README.md`
This integration can be seen in the provided example Django project. Refer to the `Django example in the pygeoapi-examples repository`_
for the integration of pygeoapi with an already exising Django application.


.. note::
To enable HTTP POST/PUT/PATCH/DELETE functionality, `django.middleware.csrf.CsrfViewMiddleware` must not be set. Note that this enables create/replace/update/delete functionality against resources in your application.

Hot-reloading
^^^^^^^^^^^^^

Expand Down Expand Up @@ -293,3 +297,4 @@ and modify accordingly.
.. _`Uvicorn`: https://www.uvicorn.org
.. _`mod_wsgi`: https://modwsgi.readthedocs.io/en/master
.. _`Django`: https://www.djangoproject.com
.. _`Django example in the pygeoapi-examples repository`: https://github.com/geopython/pygeoapi-examples/blob/main/django/sample_project/README.md
2 changes: 2 additions & 0 deletions pygeoapi/django_/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ def apply_slash_rule(url: str):
),
path(apply_slash_rule('processes/'), views.processes, name='processes'),
path('processes/<str:process_id>', views.processes, name='process-detail'),
path('processes/<str:process_id>/execution', views.process_execution,
name='process-execution'),
path(apply_slash_rule('jobs/'), views.jobs, name='jobs'),
path('jobs/<str:job_id>', views.jobs, name='job'),
path(
Expand Down
24 changes: 23 additions & 1 deletion pygeoapi/django_/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,20 @@ def processes(request: HttpRequest,
process_id)


def process_execution(request: HttpRequest, process_id: str) -> HttpResponse:
"""
OGC API - Processes execution endpoint
:request Django HTTP Request
:param process_id: process identifier
:returns: Django HTTP response
"""

return execute_from_django(processes_api.execute_process, request,
process_id)


def jobs(request: HttpRequest, job_id: Optional[str] = None) -> HttpResponse:
"""
OGC API - Jobs endpoint
Expand All @@ -382,7 +396,15 @@ def jobs(request: HttpRequest, job_id: Optional[str] = None) -> HttpResponse:
:returns: Django HTTP response
"""
return execute_from_django(processes_api.get_jobs, request, job_id)

if job_id is None:
return 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)
else: # Return status of a specific job
return execute_from_django(processes_api.get_jobs, request, job_id)


def job_results(request: HttpRequest,
Expand Down
3 changes: 2 additions & 1 deletion pygeoapi/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ def get_jobs(job_id=None):
return execute_from_flask(processes_api.get_jobs, request)
else:
if request.method == 'DELETE': # dismiss job
return execute_from_flask(processes_api.delete_jobs, request)
return execute_from_flask(processes_api.delete_job, request,
job_id)
else: # Return status of a specific job
return execute_from_flask(processes_api.get_jobs, request, job_id)

Expand Down

0 comments on commit 21b8672

Please sign in to comment.