update : 10.07.2025 10:58:55,22
This commit is contained in:
parent
749f713d82
commit
e9fa692910
18
apps/events/migrations/0016_alter_event_read_date_time.py
Normal file
18
apps/events/migrations/0016_alter_event_read_date_time.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.25 on 2025-07-10 03:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('events', '0015_delete_eventsystem'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='read_date_time',
|
||||
field=models.DateTimeField(blank=True, null=True, verbose_name='Время просмотра'),
|
||||
),
|
||||
]
|
||||
@ -35,8 +35,8 @@ class Event(models.Model): # События пользователя
|
||||
default=False,
|
||||
verbose_name="Просмотренно")
|
||||
read_date_time = models.DateTimeField(
|
||||
default=timezone.now,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name="Время просмотра")
|
||||
text_event=models.TextField(
|
||||
max_length=1000,
|
||||
|
||||
@ -211,7 +211,7 @@
|
||||
|
||||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-default" onclick="exit_modal({{catalog.id}})">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
@ -250,5 +250,22 @@
|
||||
return (isCyrillic ? '0' : '1') + data.toLowerCase();
|
||||
}
|
||||
});
|
||||
|
||||
async function exit_modal(id)
|
||||
{
|
||||
formdata = new FormData()
|
||||
formdata.append('id',id)
|
||||
const csrftoken = getCookie('csrftoken');
|
||||
let response = await fetch('/events/event_viewer/', {
|
||||
method: 'POST',
|
||||
body: formdata,
|
||||
headers: {"X-CSRFToken": csrftoken},
|
||||
});
|
||||
|
||||
let result = await response.json();
|
||||
if (result.status=='ok'){
|
||||
$('#modal-edit_'+id).modal('hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock script_footer %}
|
||||
@ -210,7 +210,7 @@
|
||||
|
||||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-default" onclick="exit_modal({{catalog.id}})">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
@ -248,5 +248,23 @@
|
||||
return (isCyrillic ? '0' : '1') + data.toLowerCase();
|
||||
}
|
||||
});
|
||||
|
||||
async function exit_modal(id)
|
||||
{
|
||||
formdata = new FormData()
|
||||
formdata.append('id',id)
|
||||
const csrftoken = getCookie('csrftoken');
|
||||
let response = await fetch('/events/event_viewer/', {
|
||||
method: 'POST',
|
||||
body: formdata,
|
||||
headers: {"X-CSRFToken": csrftoken},
|
||||
});
|
||||
|
||||
let result = await response.json();
|
||||
console.log(result)
|
||||
if (result.status=='ok'){
|
||||
$('#modal-edit_'+id).modal('hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock script_footer %}
|
||||
@ -205,7 +205,7 @@
|
||||
|
||||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-default" onclick="exit_modal({{catalog.id}})">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
@ -246,5 +246,23 @@
|
||||
return (isCyrillic ? '0' : '1') + data.toLowerCase();
|
||||
}
|
||||
});
|
||||
|
||||
async function exit_modal(id)
|
||||
{
|
||||
formdata = new FormData()
|
||||
formdata.append('id',id)
|
||||
const csrftoken = getCookie('csrftoken');
|
||||
let response = await fetch('/events/event_viewer/', {
|
||||
method: 'POST',
|
||||
body: formdata,
|
||||
headers: {"X-CSRFToken": csrftoken},
|
||||
});
|
||||
|
||||
let result = await response.json();
|
||||
console.log(result)
|
||||
if (result.status=='ok'){
|
||||
$('#modal-edit_'+id).modal('hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock script_footer %}
|
||||
@ -209,7 +209,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
|
||||
<button type="button" class="btn btn-default" onclick="exit_modal({{catalog.id}})">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
@ -248,5 +248,23 @@
|
||||
return (isCyrillic ? '0' : '1') + data.toLowerCase();
|
||||
}
|
||||
});
|
||||
|
||||
async function exit_modal(id)
|
||||
{
|
||||
formdata = new FormData()
|
||||
formdata.append('id',id)
|
||||
const csrftoken = getCookie('csrftoken');
|
||||
let response = await fetch('/events/event_viewer/', {
|
||||
method: 'POST',
|
||||
body: formdata,
|
||||
headers: {"X-CSRFToken": csrftoken},
|
||||
});
|
||||
|
||||
let result = await response.json();
|
||||
console.log(result)
|
||||
if (result.status=='ok'){
|
||||
$('#modal-edit_'+id).modal('hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock script_footer %}
|
||||
@ -9,6 +9,7 @@ from django.conf.urls import include # Используйте include() чтоб
|
||||
|
||||
urlpatterns = [
|
||||
path("", views_events.system_events, name='system_events'),
|
||||
path("event_viewer/", views_events.event_viewer, name='event_viewer'),
|
||||
path("new_event/", views_events.new_event, name='new_event'),
|
||||
path("system/", views_events.system_events, name='system_events'),
|
||||
path("gto/", views_events.gto_events, name='gto_events'),
|
||||
|
||||
@ -36,7 +36,7 @@ from apps.events.models.model_events import Event
|
||||
|
||||
from apps.util import generalmodule
|
||||
from sabron.util import logging
|
||||
from apps.events.models.model_events import Event
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=/main/')
|
||||
@never_cache
|
||||
@ -54,7 +54,6 @@ def new_event(request):
|
||||
my_filter=Q()
|
||||
for recipients in recipients_list:
|
||||
my_filter |= Q(role=recipients)
|
||||
print(my_filter)
|
||||
user_list = Profile.objects.filter(my_filter).all()
|
||||
for profile in user_list:
|
||||
Event.objects.create(
|
||||
@ -73,6 +72,23 @@ def new_event(request):
|
||||
logging.error(traceback.format_exc())
|
||||
return redirect('/main/')
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=/main/')
|
||||
@never_cache
|
||||
def event_viewer(request):
|
||||
try:
|
||||
post_param = request.POST.dict()
|
||||
event = Event.objects.filter(id=post_param['id']).first()
|
||||
event.read_date_time = timezone.now()
|
||||
event.viewed = True
|
||||
event.save()
|
||||
data =dict()
|
||||
data.update(status='ok')
|
||||
data.update(post_param=post_param)
|
||||
return generalmodule.ReturnJson(200, data)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
return redirect('/main/')
|
||||
|
||||
@never_cache
|
||||
def update_events(request):
|
||||
try:
|
||||
|
||||
21
apps/pla/migrations/0019_incident_autor_resolution.py
Normal file
21
apps/pla/migrations/0019_incident_autor_resolution.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Generated by Django 3.2.25 on 2025-07-10 03:21
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('pla', '0018_incident_resolution'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='autor_resolution',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='autor_resolution_set', to=settings.AUTH_USER_MODEL, verbose_name='Автор резолюции'),
|
||||
),
|
||||
]
|
||||
@ -42,6 +42,12 @@ class Incident(models.Model):
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
verbose_name=u'Автор')
|
||||
autor_resolution = models.ForeignKey(
|
||||
User,
|
||||
related_name='autor_resolution_set',
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
verbose_name=u'Автор резолюции')
|
||||
|
||||
def __str__(self):
|
||||
return self.type_incident.name
|
||||
|
||||
@ -8,6 +8,8 @@ urlpatterns = [
|
||||
url(r"^$", views_pla.main_index, name="pla_main_index"),
|
||||
# pla
|
||||
url(r"^new_incident/$", views_pla.new_incident, name="new_incident"),
|
||||
url(r"^incident_resolution/$", views_pla.incident_resolution, name="incident_resolution"),
|
||||
|
||||
url(r"^get_incedent/$", views_pla.get_incedent, name="get_incedent"),
|
||||
url(r"^get_typeincedent/$", views_pla.get_typeincedent, name="get_typeincedent"),
|
||||
# radiusip
|
||||
|
||||
@ -15,12 +15,28 @@ from apps.pla.models.model_type_incident import TypeIncident
|
||||
from apps.pla.models.model_incident import Incident
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=/main/')
|
||||
@never_cache
|
||||
def incident_resolution(request):
|
||||
try:
|
||||
post_param = request.POST.dict()
|
||||
incident = Incident.objects.filter(id=post_param["id_incident_resolution"]).first()
|
||||
incident.date_time_stop = post_param["date_time_stop"]
|
||||
incident.resolution = post_param["resolution"]
|
||||
incident.autor_resolution = request.user
|
||||
incident.save()
|
||||
data =dict()
|
||||
data.update(status='ok')
|
||||
return generalmodule.ReturnJson(200, data)
|
||||
except Exception as err:
|
||||
logging.error(traceback.format_exc())
|
||||
return redirect('/main/')
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=/main/')
|
||||
@never_cache
|
||||
def new_incident(request):
|
||||
try:
|
||||
post_param = request.POST.dict()
|
||||
print(post_param)
|
||||
type_incident = TypeIncident.objects.filter(id=post_param["typeincident"]).first()
|
||||
Incident.objects.create(
|
||||
type_incident = type_incident,
|
||||
@ -44,6 +60,8 @@ def get_incedent(request):
|
||||
data_responce = dict()
|
||||
data_responce.update(name=incident.type_incident.name)
|
||||
data_responce.update(id=incident.id)
|
||||
data_responce.update(date_time_start = generalmodule.convert_to_local_time(incident.date_time_start).strftime("%d.%m.%Y %H:%M:%S"))
|
||||
data_responce.update(text_event=incident.text_event)
|
||||
responce.append(data_responce)
|
||||
return generalmodule.ReturnJson(200, responce)
|
||||
except Exception as err:
|
||||
|
||||
@ -3,7 +3,7 @@ import json
|
||||
import os
|
||||
import re
|
||||
import traceback
|
||||
from datetime import datetime, timedelta,timezone
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
@ -16,6 +16,7 @@ from django.http import (Http404, HttpResponse, HttpResponsePermanentRedirect,
|
||||
HttpResponseRedirect)
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.urls import re_path
|
||||
from django.utils import timezone
|
||||
from django.views.static import serve
|
||||
|
||||
from apps.general.models.model_settings import Settings
|
||||
@ -187,6 +188,29 @@ def buildblock(size):
|
||||
random.choice(string.ascii_letters + string.digits) for _ in range(size)
|
||||
)
|
||||
|
||||
def get_current_time():
|
||||
current_time = timezone.now()
|
||||
current_time_timezoned = current_time.astimezone(settings.TIME_ZONE_OBJECT)
|
||||
return current_time_timezoned
|
||||
|
||||
|
||||
def convert_to_local_time(time_object):
|
||||
if time_object is None:
|
||||
return datetime.min
|
||||
return time_object.astimezone(settings.TIME_ZONE_OBJECT)
|
||||
|
||||
|
||||
def date_time_to_str(time_object):
|
||||
if time_object is None:
|
||||
return datetime.min.strftime("%d.%m.%Y %H:%M:%S")
|
||||
return time_object.strftime("%d.%m.%Y %H:%M:%S")
|
||||
|
||||
|
||||
def date_to_str(time_object):
|
||||
if time_object is None:
|
||||
return datetime.min.strftime("%d.%m.%Y")
|
||||
return time_object.strftime("%d.%m.%Y")
|
||||
|
||||
|
||||
def get_update_timedelta():
|
||||
try:
|
||||
|
||||
@ -71,7 +71,7 @@ INSTALLED_APPS = [
|
||||
"""Информация о приложении """
|
||||
SITE_TITLE = "Многофункциональная система безопасности ОГР"
|
||||
SITE_TITLE_S = "МФСБ ОГР"
|
||||
APP_VER = "1.0.19.2"
|
||||
APP_VER = "1.0.19.3"
|
||||
APP_VEK = "2023 - 2025гг"
|
||||
APP_COPPIRIGHT = "Многофункциональная система безопасности ОГР"
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ async function updateIncident() {
|
||||
if (item.id ==0){
|
||||
$("#id_link_incident").html('')
|
||||
}else{
|
||||
$("#id_link_incident").html(item.name)
|
||||
$("#id_link_incident").html("ВНИМАНИЕ! АВАРИЙНЫЙ РЕЖИМ.")
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -157,6 +157,68 @@ function validateFormIncident() {
|
||||
}
|
||||
|
||||
|
||||
document.getElementById('id_incident_resolution_ok').onclick = ClickOKIncidentResolution;
|
||||
|
||||
async function ClickOKIncidentResolution() {
|
||||
var Toast = Swal.mixin({
|
||||
toast: true,
|
||||
position: 'top-end',
|
||||
showConfirmButton: false,
|
||||
timer: 2000
|
||||
});
|
||||
if (validateFormIncidentResolution()==false){return}
|
||||
formdata = new FormData(id_form_resolution)
|
||||
const csrftoken = getCookie('csrftoken');
|
||||
let response = await fetch('/pla/incident_resolution/', {
|
||||
method: 'POST',
|
||||
body: formdata,
|
||||
headers: {"X-CSRFToken": csrftoken},
|
||||
});
|
||||
|
||||
let result = await response.json();
|
||||
console.log(result)
|
||||
if (result.status=='ok'){
|
||||
$('#modal-danger-resolution').modal('hide')
|
||||
toastr.success('Авария зарегистрирована.')
|
||||
}
|
||||
const form = document.getElementById("id_form_resolution");
|
||||
form.reset();
|
||||
}
|
||||
|
||||
function validateFormIncidentResolution() {
|
||||
var x = document.forms["id_form_resolution"]["id_text_resolution"].value;
|
||||
var date_time_stop= document.forms["id_form_resolution"]["id_date_time_stop"].value;
|
||||
if (date_time_stop == "") {
|
||||
alert("Необходимо ввести время окончания аварии.");
|
||||
return false;
|
||||
}
|
||||
if (x == "") {
|
||||
alert("Необходимо ввести комментарий по ликвидации аварии.");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('#modal-danger-resolution').on('show.bs.modal', async function (e) {
|
||||
const eventData = await fetch('/pla/get_incedent').then(r => r.json());
|
||||
eventData.forEach(item => {
|
||||
$("#id_incident_resolution").val(item.id)
|
||||
if (item.id ==0){
|
||||
$("#id_typeincident_resolution").html('')
|
||||
}else{
|
||||
$("#id_typeincident_resolution").val(item.name)
|
||||
$("#id_date_time_start_resolution").val(item.date_time_start)
|
||||
$("#id_text_incident_resolution").val(item.text_event)
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
|
||||
// Событие после загрузки страницы
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li class="nav-item" style="width: 500px;">
|
||||
<li class="nav-item" style="width: 100px;">
|
||||
<a class="blink7" data-toggle="modal" data-target="#modal-danger-resolution" style="cursor: pointer;">
|
||||
<h6 id="id_link_incident" class="truncate-text">
|
||||
</h6>
|
||||
@ -421,24 +421,44 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="id_form_incident">
|
||||
<form id="id_form_resolution">
|
||||
<div class="form-group row">
|
||||
<label for="id_typeincident" class="col-sm-2 col-form-label">Авария : </label>
|
||||
<label for="id_typeincident_resolution" class="col-sm-2 col-form-label">Авария : </label>
|
||||
<div class="col-sm-10">
|
||||
<select id="id_typeincident" name = "typeincident" class="form-control select2" style="width: 100%;" >
|
||||
<input id="id_typeincident_resolution" class="form-control" type="text" readonly >
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="id_text_incident" class="col-sm-2 col-form-label">Подробности : </label>
|
||||
<label for="id_date_time_start" class="col-sm-2 col-form-label">Время налчала аварии : </label>
|
||||
<div class="col-sm-10">
|
||||
<input id="id_date_time_start_resolution" class="form-control" type="text" readonly >
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="id_text_incident_resolution" class="col-sm-2 col-form-label">Подробности : </label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="id_text_incident" name="text_incident" class="form-control"></textarea>
|
||||
<textarea id="id_text_incident_resolution" name="text_incident" readonly class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="form-group row">
|
||||
<label for="id_date_time_stop_resolution" class="col-sm-2 col-form-label">Дата окончании аварии : </label>
|
||||
<div class="col-sm-10">
|
||||
<input type="datetime-local" id="id_date_time_stop" name = "date_time_stop" class="form-control d-inline-block" style="width: auto;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="id_text_resolution" class="col-sm-2 col-form-label">Комментарий : </label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="id_text_resolution" name="resolution" class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="id_incident_resolution" name="id_incident_resolution">
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button id="id_incident_ok" type="button" class="btn btn-primary">Добавить</button>
|
||||
<button id="id_incident_resolution_ok" type="button" class="btn btn-primary">Сохранить</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Отмена</button>
|
||||
|
||||
</div>
|
||||
|
||||
@ -181,7 +181,6 @@ function normalizeCoordinates(entities, dxfHeader) {
|
||||
}
|
||||
|
||||
function dxfToGeoJSON(dxf) {
|
||||
console.log(dxf);
|
||||
const normalizedEntities = normalizeCoordinates(dxf.entities, dxf.header);
|
||||
const features = normalizedEntities.map(entity => {
|
||||
if (entity.type === 'LINE') {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user