From 3bbd976abec5d80f557ee3a9893ada087d9c0c5c Mon Sep 17 00:00:00 2001 From: zakhy <=> Date: Tue, 25 Feb 2025 15:03:10 +0700 Subject: [PATCH] =?UTF-8?q?=D0=AD=D0=BD=D0=B5=D1=80=D0=B3=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=9D=D0=9A=20(=D0=9F=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD?= =?UTF-8?q?=D0=B8=D0=B9=20=D0=B6=D1=83=D1=80=D0=BD=D0=B0=D0=BB)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/geoproc/templates/geoproc_main.html | 2 +- .../templates/monitoring_journalobs.html | 8 ++-- .../templates/monitoring_journalobs_edit.html | 8 ++-- apps/geoproc/urls.py | 8 ++-- apps/geoproc/views/views_monitoring_obs.py | 41 ++++++++----------- 5 files changed, 30 insertions(+), 37 deletions(-) diff --git a/apps/geoproc/templates/geoproc_main.html b/apps/geoproc/templates/geoproc_main.html index 4c7c893..547a685 100644 --- a/apps/geoproc/templates/geoproc_main.html +++ b/apps/geoproc/templates/geoproc_main.html @@ -93,7 +93,7 @@ {% if geoproc_show_monitoring_journal_obs %}
- Открыть
+ Открыть

Журнал наблюдений за состоянием бортов,траншей,уступов,откосов и отвалов

diff --git a/apps/geoproc/templates/monitoring_journalobs.html b/apps/geoproc/templates/monitoring_journalobs.html index a097770..349239a 100644 --- a/apps/geoproc/templates/monitoring_journalobs.html +++ b/apps/geoproc/templates/monitoring_journalobs.html @@ -18,7 +18,7 @@
@@ -33,7 +33,7 @@
{% if not user.profile.isredonly %} - Добавить + Добавить {% endif %} {% block pagination %} {% if is_paginated %} @@ -84,7 +84,7 @@ {{catalog.id}} -
+ {% csrf_token %} {{ catalog.date_time }} @@ -94,7 +94,7 @@ - + {% csrf_token %} {{ catalog.name }} diff --git a/apps/geoproc/templates/monitoring_journalobs_edit.html b/apps/geoproc/templates/monitoring_journalobs_edit.html index b5773a3..2ea3387 100644 --- a/apps/geoproc/templates/monitoring_journalobs_edit.html +++ b/apps/geoproc/templates/monitoring_journalobs_edit.html @@ -35,8 +35,8 @@
- Отмена + Отмена
diff --git a/apps/geoproc/urls.py b/apps/geoproc/urls.py index eecfb38..04b3a32 100644 --- a/apps/geoproc/urls.py +++ b/apps/geoproc/urls.py @@ -57,10 +57,10 @@ urlpatterns = [ path('sector//monitoring/journal_m/save/', views_monitoring_m.monitoring_journal_save, name='monitoring_journal_m_save'), # Журнал мониторинга (OBS) - path('monitoring/journal_obs/', views_monitoring_obs.monitoring_journal, name='monitoring_journal_obs'), - path('monitoring/journal_obs/add/', views_monitoring_obs.monitoring_journal_add, name='monitoring_journal_obs_add'), - path('monitoring/journal_obs/edit/', views_monitoring_obs.monitoring_journal_edit, name='monitoring_journal_obs_edit'), - path('monitoring/journal_obs/save/', views_monitoring_obs.monitoring_journal_save, name='monitoring_journal_obs_save'), + path('sector//monitoring/journal_obs/', views_monitoring_obs.monitoring_journal, name='monitoring_journal_obs'), + path('sector//monitoring/journal_obs/add/', views_monitoring_obs.monitoring_journal_add, name='monitoring_journal_obs_add'), + path('sector//monitoring/journal_obs/edit/', views_monitoring_obs.monitoring_journal_edit, name='monitoring_journal_obs_edit'), + path('sector//monitoring/journal_obs/save/', views_monitoring_obs.monitoring_journal_save, name='monitoring_journal_obs_save'), # Отчеты path('report/j/', views_report.report_j, name='report_j'), diff --git a/apps/geoproc/views/views_monitoring_obs.py b/apps/geoproc/views/views_monitoring_obs.py index 69e1257..8f48113 100644 --- a/apps/geoproc/views/views_monitoring_obs.py +++ b/apps/geoproc/views/views_monitoring_obs.py @@ -5,7 +5,7 @@ import io import json from datetime import datetime -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 from django.http import HttpResponse from django.conf import settings from django.contrib.auth.decorators import login_required @@ -18,7 +18,7 @@ from django.contrib.auth.models import User from apps.general.views.settingsmodule import get_settings from apps.geoproc.models.model_journalobs import JournalObs from apps.geoproc.models.model_journalobs_table import JournalObsTable - +from apps.geoproc.models.model_sector import Sector from sabron.util import logging from apps.util import generalmodule @@ -26,10 +26,10 @@ from apps.util import generalmodule @login_required(login_url='/') @never_cache -def monitoring_journal(request): +def monitoring_journal(request, pk): try: - param=request.GET.dict() - catalog_list=JournalObs.objects.order_by("date_time").all() + sector = get_object_or_404(Sector, id=pk) + catalog_list=JournalObs.objects.order_by("date_time").filter(sector=sector) catalog_count = catalog_list.count() paginator = Paginator(catalog_list, 50) page_number = request.GET.get('page',1) @@ -69,6 +69,7 @@ def monitoring_journal(request): 'end_page_list':end_page_list, 'start_page_list':start_page_list, 'clients_count':catalog_count, + 'sector': sector }) return render(request,'monitoring_journalobs.html', context) except Exception as err: @@ -76,8 +77,9 @@ def monitoring_journal(request): @login_required(login_url='/') @never_cache -def monitoring_journal_edit(request): +def monitoring_journal_edit(request, pk): try: + sector = get_object_or_404(Sector, id=pk) param_get=request.GET.dict() element = JournalObs.objects.filter(id=param_get['id']).first() journal_table = JournalObsTable.objects.filter(journal_vizual=element).all() @@ -85,7 +87,8 @@ def monitoring_journal_edit(request): context.update({ 'element':element, 'journal_tables':journal_table, - 'date_time':element.date_time.strftime('%Y-%m-%d') + 'date_time':element.date_time.strftime('%Y-%m-%d'), + "sector": sector }) return render(request,'monitoring_journalobs_edit.html', context) except Exception as err: @@ -93,8 +96,9 @@ def monitoring_journal_edit(request): @login_required(login_url='/') @never_cache -def monitoring_journal_add(request): +def monitoring_journal_add(request, pk): try: + sector = get_object_or_404(Sector, id=pk) get_settings('coordinating_position', 'главного технолога') date = datetime.now() day = "0" if date.day < 10 else "" @@ -107,6 +111,7 @@ def monitoring_journal_add(request): 'cmd':'add', 'element':None, 'date_time':"%s-%s-%s" % (year, month, day), + 'sector': sector }) return render(request,'monitoring_journalobs_edit.html', context) except Exception as err: @@ -114,10 +119,9 @@ def monitoring_journal_add(request): @login_required(login_url='/') @never_cache -def monitoring_journal_save(request): +def monitoring_journal_save(request, pk): try: - - param_get=request.GET.dict() + sector = get_object_or_404(Sector, id=pk) param_post=request.POST.dict() if param_post['id'] == '': date_time = param_post['date_time'] @@ -129,7 +133,7 @@ def monitoring_journal_save(request): month += str(date.month) year = date.year date_time = "%s-%s-%s" % (year, month, day) - journal_element = JournalObs.objects.create(date_time=date_time) + journal_element = JournalObs.objects.create(date_time=date_time, sector=sector) else: journal_element = JournalObs.objects.filter(id=param_post['id']).first() JournalObsTable.objects.filter(journal_vizual=journal_element).delete() @@ -177,17 +181,6 @@ def monitoring_journal_save(request): 'element':None, 'date_time':"%s-%s-%s" % (datetime.now().year, datetime.now().month, datetime.now().day), }) - return redirect('/geoproc/monitoring/journal_obs/') - except Exception as err: - logging.error(traceback.format_exc()) - -@login_required(login_url='/') -@never_cache -def main_index(request): - try: - context = generalmodule.get_context_template() - context.update({ - }) - return render(request,'geoproc_main.html', context) + return redirect('geoproc:monitoring_journal_obs', pk=pk) except Exception as err: logging.error(traceback.format_exc())