Skip to content
Snippets Groups Projects
Commit 54e434ba authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

add proxy to ARES (no CORS)

parent 3e9935fd
No related branches found
No related tags found
No related merge requests found
Pipeline #11954 passed
......@@ -109,4 +109,10 @@ urlpatterns = [
dal.autocomplete.Select2QuerySetView.as_view(model=models.ContracteeSignature),
name="select2_djhacker_contractee_signature_autocomplete",
),
path(
"ares-info-proxy/<int:ico>",
views.get_ares_info,
name="get_ares_info",
)
]
import requests
from django.conf import settings
from django.core.paginator import Paginator
from django.http import HttpResponse
from django.shortcuts import render
from django_http_exceptions import HTTPExceptions
from django_downloadview import ObjectDownloadView
from guardian.shortcuts import get_objects_for_user
......@@ -368,3 +372,19 @@ def view_signees(request):
# END Submodel listing views
# ARES CORS proxy
def get_ares_info(request, ico: int):
if not request.user.is_staff:
raise HTTPExceptions.FORBIDDEN
ares_info = requests.get(
f"https://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?ico={ico}"
)
return HttpResponse(
content=ares_info.content,
status=ares_info.status_code,
content_type=ares_info.headers.get("Content-Type")
)
......@@ -88,7 +88,7 @@ $(window).ready(
const icoValue = $("#id_ico_number").val();
const rawAresXMLResponse = await fetch(
`https://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?ico=${icoValue}`
`/ares-info-proxy/${icoValue}`
);
if (!rawAresXMLResponse.ok) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment