Error on map client search
* adds info for user if address search content could not be parsed properly due to external errors
This commit is contained in:
parent
d361767471
commit
b11217e41f
@ -6,6 +6,7 @@ Created on: 19.08.22
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
|
from json import JSONDecodeError
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
@ -13,6 +14,8 @@ from django.http import JsonResponse, HttpRequest
|
|||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from requests.auth import HTTPDigestAuth
|
from requests.auth import HTTPDigestAuth
|
||||||
|
|
||||||
from konova.sub_settings.proxy_settings import PROXIES, CLIENT_PROXY_AUTH_USER, CLIENT_PROXY_AUTH_PASSWORD
|
from konova.sub_settings.proxy_settings import PROXIES, CLIENT_PROXY_AUTH_USER, CLIENT_PROXY_AUTH_PASSWORD
|
||||||
@ -57,7 +60,18 @@ class ClientProxyParcelSearch(BaseClientProxyView):
|
|||||||
def get(self, request: HttpRequest):
|
def get(self, request: HttpRequest):
|
||||||
url = request.META.get("QUERY_STRING")
|
url = request.META.get("QUERY_STRING")
|
||||||
content, response_code = self.perform_url_call(url)
|
content, response_code = self.perform_url_call(url)
|
||||||
body = json.loads(content)
|
try:
|
||||||
|
body = json.loads(content)
|
||||||
|
except JSONDecodeError as e:
|
||||||
|
body = {
|
||||||
|
"totalResultsCount": -1,
|
||||||
|
"geonames": [
|
||||||
|
{
|
||||||
|
"title": _("The external service is currently unavailable.<br>Please try again in a few moments...")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
if response_code != 200:
|
if response_code != 200:
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
"status_code": response_code,
|
"status_code": response_code,
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user