Энергия НК (Журнал указаний и уведомлений)
This commit is contained in:
parent
4fd6ba4240
commit
8e660eeb84
@ -85,7 +85,7 @@
|
||||
{% if geoproc_show_monitoring_journal_m %}
|
||||
<div class="col invoice-col">
|
||||
<i class="fas fa-book"></i>
|
||||
<a href="monitoring/journal_m/"><strong> Открыть</strong></a><br>
|
||||
<a href="{% url 'geoproc:monitoring_journal_m' sector.id %}"><strong> Открыть</strong></a><br>
|
||||
<p style="font-size:12px;">Журнал указаний и уведомлений</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@ -35,8 +35,8 @@
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="/geoproc/">Главная</a></li>
|
||||
<li class="breadcrumb-item"><a href="/geoproc/monitoring/journal_m/">Журнал указаний и уведомлений</a></li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'geoproc:geoproc_main_with_arg' sector.id %}">Главная</a></li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'geoproc:monitoring_journal_m' sector.id %}">Журнал указаний и уведомлений</a></li>
|
||||
{% if element %}
|
||||
<li class="breadcrumb-item active">{{element.name}}</li>
|
||||
{% else %}
|
||||
@ -49,7 +49,7 @@
|
||||
</section>
|
||||
|
||||
<section class="content">
|
||||
<form action="/geoproc/monitoring/journal_m/save/?id={{element.id}}" method="post" class="form-horizontal">
|
||||
<form action="{% url 'geoproc:monitoring_journal_m_save' sector.id %}?id={{element.id}}" method="post" class="form-horizontal">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" value="{{mt}}" name="mt">
|
||||
<input type="hidden" value="{{element.id}}" name="id">
|
||||
@ -133,7 +133,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a href="/geoproc/monitoring/journal_m/" type="button" class="btn btn-default ">Отмена</a>
|
||||
<a href="{% url 'geoproc:monitoring_journal_m' sector.id %}" type="button" class="btn btn-default ">Отмена</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -354,14 +354,14 @@ function newGuid() {
|
||||
|
||||
$.ajax({
|
||||
type: 'POST', // метод отправки
|
||||
url: '/geoproc/monitoring/journal_m/save/?id={{element.id}}',
|
||||
url: '{% url 'geoproc:monitoring_journal_m_save' sector.id %}?id={{element.id}}',
|
||||
data: {
|
||||
"data_table": JSON.stringify(myObj),
|
||||
"element":'{{element.id}}'
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
window.location.href ='/geoproc/monitoring/journal_m/';
|
||||
window.location.href ='{% url 'geoproc:monitoring_journal_m' sector.id %}';
|
||||
},
|
||||
error: function (dataerr) {
|
||||
$("#reportPanelBody").html(dataerr); // при успешном получении ответа от сервера, заносим полученные данные в элемент с классом answer
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="/geoproc/">Главная</a></li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'geoproc:geoproc_main_with_arg' sector.id %}">Главная</a></li>
|
||||
<li class="breadcrumb-item active">Журнал указаний и уведомлений</li>
|
||||
</ol>
|
||||
</div>
|
||||
@ -33,7 +33,7 @@
|
||||
<div class="card">
|
||||
<div class="card-header text-sm">
|
||||
{% if not user.profile.isredonly %}
|
||||
<a href="../journal_m/add/" type="button" class="btn bg-gradient-primary float-left" style="margin-right:20px;">Добавить</a>
|
||||
<a href="{% url 'geoproc:monitoring_journal_m_add' sector.id %}" type="button" class="btn bg-gradient-primary float-left" style="margin-right:20px;">Добавить</a>
|
||||
{% endif %}
|
||||
{% block pagination %}
|
||||
{% if is_paginated %}
|
||||
@ -84,7 +84,7 @@
|
||||
{{catalog.id}}
|
||||
</td>
|
||||
<td>
|
||||
<form action="/geoproc/monitoring/journal_m/edit/?id={{catalog.id}}" id="frm_name_{{catalog.id}}" method="POST" class="floatLeft butDelUser">
|
||||
<form action="{% url 'geoproc:monitoring_journal_m_edit' sector.id %}?id={{catalog.id}}" id="frm_name_{{catalog.id}}" method="POST" class="floatLeft butDelUser">
|
||||
{% csrf_token %}
|
||||
<a href="#" onclick="document.getElementById('frm_name_{{catalog.id}}').submit(); return false;">
|
||||
{{ catalog.date_time }}
|
||||
@ -94,7 +94,7 @@
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<form action="/geoproc/monitoring/journal_m/edit/?id={{catalog.id}}" id="frm_name_{{catalog.id}}" method="POST" class="floatLeft butDelUser">
|
||||
<form action="{% url 'geoproc:monitoring_journal_m_edit' sector.id %}?id={{catalog.id}}" id="frm_name_{{catalog.id}}" method="POST" class="floatLeft butDelUser">
|
||||
{% csrf_token %}
|
||||
<a href="#" onclick="document.getElementById('frm_name_{{catalog.id}}').submit(); return false;">
|
||||
{{ catalog.name }}
|
||||
|
||||
@ -51,10 +51,10 @@ urlpatterns = [
|
||||
path('sector/<int:pk>/monitoring/journal/save/', views_monitoring.monitoring_journal_save, name='monitoring_journal_save'),
|
||||
|
||||
# Журнал мониторинга (M)
|
||||
path('monitoring/journal_m/', views_monitoring_m.monitoring_journal, name='monitoring_journal_m'),
|
||||
path('monitoring/journal_m/add/', views_monitoring_m.monitoring_journal_add, name='monitoring_journal_m_add'),
|
||||
path('monitoring/journal_m/edit/', views_monitoring_m.monitoring_journal_edit, name='monitoring_journal_m_edit'),
|
||||
path('monitoring/journal_m/save/', views_monitoring_m.monitoring_journal_save, name='monitoring_journal_m_save'),
|
||||
path('sector/<int:pk>/monitoring/journal_m/', views_monitoring_m.monitoring_journal, name='monitoring_journal_m'),
|
||||
path('sector/<int:pk>/monitoring/journal_m/add/', views_monitoring_m.monitoring_journal_add, name='monitoring_journal_m_add'),
|
||||
path('sector/<int:pk>/monitoring/journal_m/edit/', views_monitoring_m.monitoring_journal_edit, name='monitoring_journal_m_edit'),
|
||||
path('sector/<int:pk>/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'),
|
||||
|
||||
@ -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
|
||||
@ -17,7 +17,7 @@ from django.contrib.auth.models import User
|
||||
|
||||
from apps.geoproc.models.model_journalvisual_m import JournalVizualM
|
||||
from apps.geoproc.models.model_journalvisual_table_m import JournalVizualTableM
|
||||
|
||||
from apps.geoproc.models.model_sector import Sector
|
||||
|
||||
from sabron.util import logging
|
||||
from apps.util import generalmodule
|
||||
@ -25,10 +25,11 @@ from apps.util import generalmodule
|
||||
|
||||
@login_required(login_url='/')
|
||||
@never_cache
|
||||
def monitoring_journal(request): #1
|
||||
def monitoring_journal(request, pk): #1
|
||||
try:
|
||||
sector = get_object_or_404(Sector, id=pk)
|
||||
param=request.GET.dict()
|
||||
catalog_list=JournalVizualM.objects.order_by("date_time").all()
|
||||
catalog_list=JournalVizualM.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)
|
||||
@ -68,6 +69,7 @@ def monitoring_journal(request): #1
|
||||
'end_page_list':end_page_list,
|
||||
'start_page_list':start_page_list,
|
||||
'clients_count':catalog_count,
|
||||
'sector': sector
|
||||
})
|
||||
return render(request,'monitoring_journal_m.html', context)
|
||||
except Exception as err:
|
||||
@ -75,8 +77,9 @@ def monitoring_journal(request): #1
|
||||
|
||||
@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 = JournalVizualM.objects.filter(id=param_get['id']).first()
|
||||
journal_table = JournalVizualTableM.objects.filter(journal_vizual=element).all()
|
||||
@ -84,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_journal_edit_m.html', context)
|
||||
except Exception as err:
|
||||
@ -92,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)
|
||||
date = datetime.now()
|
||||
day = "0" if date.day < 10 else ""
|
||||
day += str(date.day)
|
||||
@ -102,9 +107,10 @@ def monitoring_journal_add(request):
|
||||
year = date.year
|
||||
context = generalmodule.get_context_template()
|
||||
context.update({
|
||||
'cmd':'add',
|
||||
'element':None,
|
||||
'date_time':"%s-%s-%s" % (year, month, day),
|
||||
'sector': sector,
|
||||
'cmd':'add',
|
||||
'element':None,
|
||||
'date_time':"%s-%s-%s" % (year, month, day),
|
||||
})
|
||||
return render(request,'monitoring_journal_edit_m.html', context)
|
||||
except Exception as err:
|
||||
@ -112,11 +118,11 @@ 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()
|
||||
param_post=request.POST.dict()
|
||||
|
||||
sector = get_object_or_404(Sector, id=pk)
|
||||
if param_post['id'] == '':
|
||||
date_time = param_post['date_time']
|
||||
if date_time =="":
|
||||
@ -127,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 = JournalVizualM.objects.create(date_time=date_time)
|
||||
journal_element = JournalVizualM.objects.create(date_time=date_time, sector=sector)
|
||||
else:
|
||||
journal_element = JournalVizualM.objects.filter(id=param_post['id']).first()
|
||||
JournalVizualTableM.objects.filter(journal_vizual=journal_element).delete()
|
||||
@ -168,25 +174,6 @@ def monitoring_journal_save(request):
|
||||
else:
|
||||
journal_element.name = name_journal
|
||||
journal_element.save()
|
||||
context = generalmodule.get_context_template()
|
||||
context.update({
|
||||
'cmd':'add',
|
||||
'element':None,
|
||||
'date_time':"%s-%s-%s" % (datetime.now().year, datetime.now().month, datetime.now().day),
|
||||
})
|
||||
return redirect('/geoproc/monitoring/journal_m/')
|
||||
#return render(request,'monitoring_journal_edit.html', context)
|
||||
return redirect('geoproc:monitoring_journal_m', pk=pk)
|
||||
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)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user