diff --git a/apps/gto/templates/gto_main.html b/apps/gto/templates/gto_main.html
index a89fb25..a891ccb 100644
--- a/apps/gto/templates/gto_main.html
+++ b/apps/gto/templates/gto_main.html
@@ -463,10 +463,7 @@
// Функция для обновления маркеров
async function updateMarkers() {
// Обновление GTO
- const gtoData = await fetch('/gto/update_object/', {
- method: 'POST',
- headers: {'X-CSRFToken': csrftoken}
- }).then(r => r.json());
+ const gtoData = await fetch('/gto/update_object/').then(r => r.json());
gtoData.forEach(item => {
if (gtoManager.markers[item.id]) {
diff --git a/apps/gto/views/views_main.py b/apps/gto/views/views_main.py
index d5d12c0..2685e74 100644
--- a/apps/gto/views/views_main.py
+++ b/apps/gto/views/views_main.py
@@ -26,34 +26,31 @@ from sabron.util import logging
@never_cache
def update_object(request):
try:
- if request.method == "POST":
- now = timezone.now()
- week_diff = now - timedelta(days=7)
- object_list = Equipment.objects.filter(block=False, time__gt=week_diff).all()
- m_list = []
- for obj in object_list:
- type_g = obj.model.strip()
- icon = ""
- icon_obj = ModelTypeIcons.objects.filter(model=type_g).first()
- if icon_obj is not None:
- icon = icon_obj.icon.url
- m_list.append(
- {
- "id": obj.id,
- "name": obj.name,
- "lat": obj.lat,
- "lon": obj.lon,
- "time": obj.time.strftime("%d.%m.%Y %H:%M:%S"),
- "iso_time": obj.time.isoformat(),
- "statenum": obj.statenum,
- "model": obj.model,
- "icon": icon,
- "garagenum": obj.garagenum,
- }
- )
- return generalmodule.ReturnJson(200, m_list)
- else:
- return HttpResponse(status=405)
+ now = timezone.now()
+ week_diff = now - timedelta(days=7)
+ object_list = Equipment.objects.filter(block=False, time__gt=week_diff).all()
+ res = []
+ for obj in object_list:
+ type_g = obj.model.strip()
+ icon = ""
+ icon_obj = ModelTypeIcons.objects.filter(model=type_g).first()
+ if icon_obj is not None:
+ icon = icon_obj.icon.url
+ res.append(
+ {
+ "id": obj.id,
+ "name": obj.name,
+ "lat": obj.lat,
+ "lon": obj.lon,
+ "time": obj.time.strftime("%d.%m.%Y %H:%M:%S"),
+ "iso_time": obj.time.isoformat(),
+ "statenum": obj.statenum,
+ "model": obj.model,
+ "icon": icon,
+ "garagenum": obj.garagenum,
+ }
+ )
+ return JsonResponse(res, safe=False)
except Exception as err:
logging.error(traceback.format_exc())
diff --git a/apps/main/templates/main_index.html b/apps/main/templates/main_index.html
index 72e5e06..efd6a8e 100644
--- a/apps/main/templates/main_index.html
+++ b/apps/main/templates/main_index.html
@@ -229,10 +229,7 @@
// Функция для обновления маркеров
async function updateMarkers() {
// Обновление GTO
- const gtoData = await fetch('/gto/update_object/', {
- method: 'POST',
- headers: {'X-CSRFToken': csrftoken}
- }).then(r => r.json());
+ const gtoData = await fetch('/gto/update_object/').then(r => r.json());
gtoData.forEach(item => {
if (gtoManager.markers[item.id]) {