Compare commits
98 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8316cfb6c | ||
|
|
c4ae1011cd | ||
|
|
924aaf2785 | ||
|
|
00ecd848b6 | ||
|
|
2c1fc9a1a0 | ||
|
|
72cb6f9672 | ||
|
|
b39eed1b3b | ||
|
|
9372b9bb75 | ||
|
|
1e7bce1d78 | ||
|
|
a5450a8d22 | ||
|
|
0aea3820c8 | ||
|
|
e6d43a15c9 | ||
|
|
4e8b8fa154 | ||
|
|
b2e593feee | ||
|
|
ca9332a814 | ||
|
|
eac67e5f89 | ||
|
|
89c7577624 | ||
|
|
caa2793250 | ||
|
|
61cc64bde8 | ||
|
|
9c9b096f0f | ||
|
|
b4dcb5f012 | ||
|
|
856cd20ad2 | ||
|
|
ce0ed2aaba | ||
|
|
e7f10940d9 | ||
|
|
19e5c42cce | ||
|
|
8c16af2d47 | ||
|
|
c074f25796 | ||
|
|
54e7da200d | ||
|
|
1169ec67aa | ||
|
|
6fb812600a | ||
|
|
f779589fdd | ||
|
|
4efe69d5d1 | ||
|
|
f79ee5e1ee | ||
|
|
e3d6c3e8b7 | ||
|
|
4fe93a5280 | ||
|
|
bd34b85e4d | ||
|
|
bb186215a7 | ||
|
|
658678818c | ||
|
|
297eff9b0c | ||
|
|
44461573e3 | ||
|
|
4186215daa | ||
|
|
9937ec04c7 | ||
|
|
d6a23a4443 | ||
|
|
3c9208a822 | ||
|
|
8a4f5f4f82 | ||
|
|
6776296c17 | ||
|
|
ca45966260 | ||
|
|
357ed5b047 | ||
|
|
760c84a408 | ||
|
|
7f35fe0a35 | ||
|
|
899d70df32 | ||
|
|
f5fd49271c | ||
|
|
199cea7230 | ||
|
|
c8793c7ed0 | ||
|
|
6b99b16892 | ||
|
|
b9c335ecf8 | ||
| 19b8c9c579 | |||
|
|
ce543c6d2f | ||
|
|
9600c9912f | ||
| 2a686089f3 | |||
|
|
5fcf775cb7 | ||
|
|
2b68ad62d4 | ||
|
|
e4fbff3e29 | ||
|
|
ff38fc13d6 | ||
|
|
8e99a18916 | ||
|
|
dd85bc231f | ||
|
|
2c7fd17a5a | ||
|
|
b9dbc4d2dd | ||
|
|
23b207f052 | ||
|
|
dbfdfd538d | ||
| 52f24c14ee | |||
| 55a749c0ae | |||
| be04ac30d0 | |||
| 306b07d513 | |||
| f2edd2e762 | |||
| 715e9d9c76 | |||
| 58b8687e2f | |||
| 1d3e435051 | |||
| 199694e5ec | |||
| 33b234af48 | |||
| d2183aae1f | |||
| bdc3b3948a | |||
| 9c0a24efe8 | |||
| fc3de59d5a | |||
| f26b1f419a | |||
| f5d8ea6a89 | |||
| a299ced40f | |||
| 1ae7f63cb3 | |||
| fed47907c2 | |||
| 9df295ccdd | |||
| 49aef787c6 | |||
| 106a66fad3 | |||
| 331900310a | |||
| ded144966c | |||
| 2f05cd62e9 | |||
| dacf95b63f | |||
| 5669091ab0 | |||
| 8f8dd1ff70 |
@ -12,6 +12,12 @@ repos:
|
||||
- id: double-quote-string-fixer # заменяет " на '
|
||||
- id: end-of-file-fixer # добавляет пустую строку в конце файла
|
||||
|
||||
- repo: https://github.com/adamchainz/django-upgrade
|
||||
rev: "" # replace with latest tag on GitHub
|
||||
hooks:
|
||||
- id: django-upgrade
|
||||
args: [--target-version, "4.2"]
|
||||
|
||||
# Отсортировывает импорты в проекте
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.13.2
|
||||
@ -46,3 +52,9 @@ repos:
|
||||
rev: v8.18.4
|
||||
hooks:
|
||||
- id: gitleaks
|
||||
|
||||
- repo: https://github.com/adamchainz/django-upgrade
|
||||
rev: "1.22.1" # replace with latest tag on GitHub
|
||||
hooks:
|
||||
- id: django-upgrade
|
||||
args: [ --target-version, "4.2" ] # Replace with Django version
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
1. Клонировать репозиторий
|
||||
|
||||
```bash
|
||||
git clone http://git.hronos.su:8080/sabron/repcofkk.git
|
||||
git clone https://git.cybercode.pro/sabron/repcofkk.git
|
||||
```
|
||||
|
||||
2. Запустить compose
|
||||
|
||||
0
app/apps/__init__.py
Normal file
0
app/apps/__init__.py
Normal file
0
app/apps/finance/__init__.py
Normal file
0
app/apps/finance/__init__.py
Normal file
6
app/apps/finance/apps.py
Normal file
6
app/apps/finance/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class FinanceConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'apps.finance'
|
||||
0
app/apps/finance/migrations/__init__.py
Normal file
0
app/apps/finance/migrations/__init__.py
Normal file
34
app/apps/finance/models.py
Normal file
34
app/apps/finance/models.py
Normal file
@ -0,0 +1,34 @@
|
||||
import decimal
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class DebtorDebt:
|
||||
"""
|
||||
Модель элемента дебиторской задолженности.
|
||||
counter_party: Контрагент;
|
||||
debt: Долг;
|
||||
advance: Аванс.
|
||||
"""
|
||||
|
||||
counter_party: str
|
||||
debt: decimal.Decimal
|
||||
advance: decimal.Decimal
|
||||
|
||||
|
||||
@dataclass
|
||||
class Balance:
|
||||
"""
|
||||
Модель элемента Остатков по расчетным счетам.
|
||||
money type: Вид денежных средств;
|
||||
place: Размещение;
|
||||
amount_balance: Сумма остаток.
|
||||
"""
|
||||
|
||||
money_type: str
|
||||
place: str
|
||||
amount_balance: decimal.Decimal
|
||||
currency: str
|
||||
percent: float
|
||||
account_number: str | None = None
|
||||
bank_name: str | None = None
|
||||
133
app/apps/finance/services/integration_1c/api.py
Normal file
133
app/apps/finance/services/integration_1c/api.py
Normal file
@ -0,0 +1,133 @@
|
||||
import datetime
|
||||
import decimal
|
||||
import traceback
|
||||
|
||||
import requests
|
||||
from apps.finance.models import Balance, DebtorDebt
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from sabron.util import logging
|
||||
from sabron.util.sabronmodule import get_settings
|
||||
|
||||
|
||||
class Finance1CAPI:
|
||||
def __init__(self):
|
||||
self.fin_1c_api_login = get_settings('1c_api_login')
|
||||
self.fin_1c_api_password = get_settings('1c_api_password')
|
||||
self.fin_1c_api_host = get_settings('1c_api_host')
|
||||
|
||||
def get_balance(self) -> (list[Balance], dict):
|
||||
try:
|
||||
|
||||
headers = {
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
basic = HTTPBasicAuth(self.fin_1c_api_login,
|
||||
self.fin_1c_api_password)
|
||||
|
||||
url = f'{self.fin_1c_api_host}/hs/saphire-api/balance'
|
||||
|
||||
response = requests.get(url, headers=headers, auth=basic)
|
||||
|
||||
if response.status_code != 200:
|
||||
return [], decimal.Decimal(0)
|
||||
response_data = response.json()
|
||||
|
||||
balance_data = []
|
||||
for balance_item in response_data['data']:
|
||||
balance_place = balance_item['Размещение'].strip()
|
||||
amount_balance = balance_item['СуммаОстаток']
|
||||
money_type = balance_item['ВидДенежныхСредств'].strip()
|
||||
currency_code = balance_item['Валюта']
|
||||
summary_for_obj = response_data['summary'][money_type][currency_code]
|
||||
percent = amount_balance * 100 / summary_for_obj
|
||||
balance_object = Balance(
|
||||
money_type=money_type,
|
||||
place=balance_place,
|
||||
amount_balance=amount_balance,
|
||||
currency=currency_code,
|
||||
percent=percent
|
||||
)
|
||||
if ',' in balance_place:
|
||||
mas = balance_place.split(',', maxsplit=1)
|
||||
balance_object.account_number = mas[0].strip()
|
||||
balance_object.bank_name = mas[1].strip()
|
||||
balance_data.append(balance_object)
|
||||
return balance_data, response_data['summary']
|
||||
|
||||
except Exception:
|
||||
logging.error(traceback.format_exc())
|
||||
return [], {}
|
||||
|
||||
def get_debts(self) -> dict[str, decimal.Decimal]:
|
||||
try:
|
||||
headers = {
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
basic = HTTPBasicAuth(self.fin_1c_api_login,
|
||||
self.fin_1c_api_password)
|
||||
date_today = datetime.datetime.now()
|
||||
formatted_date = date_today.strftime('%Y%m%d')
|
||||
|
||||
url = f'{self.fin_1c_api_host}/hs/saphire-api/debts/{formatted_date}'
|
||||
|
||||
response = requests.get(url, headers=headers, auth=basic)
|
||||
|
||||
response_template = {
|
||||
'buyers': {
|
||||
'debts': [],
|
||||
'summary': {
|
||||
'debt': 0,
|
||||
'advance': 0,
|
||||
},
|
||||
},
|
||||
'providers': {
|
||||
'debts': [],
|
||||
'summary': {
|
||||
'debt': 0,
|
||||
'advance': 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
if response.status_code != 200:
|
||||
return response_template
|
||||
response_data = response.json()
|
||||
buyers_mas = []
|
||||
providers_mas = []
|
||||
|
||||
for databuyer in response_data['databuyers']:
|
||||
buyers_mas.append(
|
||||
DebtorDebt(
|
||||
counter_party=databuyer['Контрагент'],
|
||||
debt=databuyer['Долг'],
|
||||
advance=databuyer['Аванс'],
|
||||
)
|
||||
)
|
||||
for dataprovider in response_data['dataproviders']:
|
||||
providers_mas.append(
|
||||
DebtorDebt(
|
||||
counter_party=dataprovider['Контрагент'],
|
||||
debt=dataprovider['Долг'],
|
||||
advance=dataprovider['Аванс'],
|
||||
)
|
||||
)
|
||||
buyers = {
|
||||
'debts': buyers_mas,
|
||||
'summary': {
|
||||
'debt': response_data['summarybuyers']['Долг'],
|
||||
'advance': response_data['summarybuyers']['Аванс'],
|
||||
},
|
||||
}
|
||||
providers = {
|
||||
'debts': providers_mas,
|
||||
'summary': {
|
||||
'debt': response_data['summaryproviders']['Долг'],
|
||||
'advance': response_data['summaryproviders']['Аванс'],
|
||||
},
|
||||
}
|
||||
|
||||
debts_data = {'buyers': buyers, 'providers': providers}
|
||||
return debts_data
|
||||
|
||||
except Exception:
|
||||
logging.error(traceback.format_exc())
|
||||
return response_template
|
||||
153
app/apps/finance/services/integration_1c/service.py
Normal file
153
app/apps/finance/services/integration_1c/service.py
Normal file
@ -0,0 +1,153 @@
|
||||
from dataclasses import asdict
|
||||
|
||||
from apps.finance.models import Balance
|
||||
from apps.finance.services.integration_1c.api import Finance1CAPI
|
||||
from apps.main.services.base_service import DashboardBaseService
|
||||
|
||||
|
||||
class Finance1CService(DashboardBaseService):
|
||||
cash_money_type = 'Деньги в кассе'
|
||||
bank_money_type = 'Деньги на расчетных счетах'
|
||||
|
||||
@staticmethod
|
||||
def get_balance() -> dict:
|
||||
|
||||
api = Finance1CAPI()
|
||||
data, summary = api.get_balance()
|
||||
result = {
|
||||
'error': '',
|
||||
'status': 0,
|
||||
'total': len(data),
|
||||
'items': [asdict(item) for item in data],
|
||||
'summary': summary,
|
||||
}
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def get_debtor_debts() -> dict:
|
||||
api = Finance1CAPI()
|
||||
data, summary = api.get_debts()
|
||||
result = {
|
||||
'error': '',
|
||||
'status': 0,
|
||||
'total': len(data),
|
||||
'items': [asdict(item) for item in data],
|
||||
'summary': summary,
|
||||
}
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def get_balance_raw() -> (list[Balance], dict):
|
||||
api = Finance1CAPI()
|
||||
return api.get_balance()
|
||||
|
||||
@staticmethod
|
||||
def get_debts_raw() -> dict:
|
||||
api = Finance1CAPI()
|
||||
return api.get_debts()
|
||||
|
||||
# @classmethod
|
||||
# def get_balance_grouped_by_currency(cls) -> dict[str, dict]:
|
||||
# data, summary = cls.get_balance_raw()
|
||||
# for key, value in summary:
|
||||
# pass
|
||||
# res = {
|
||||
#
|
||||
# }
|
||||
@classmethod
|
||||
def get_balance_grouped_by_money_type(cls) -> (dict, dict):
|
||||
data, summary = cls.get_balance_raw()
|
||||
result = {'bank': {}, 'cash': {}}
|
||||
for balance_object in data:
|
||||
cls.create_currency_object(
|
||||
result, asdict(balance_object), balance_object.money_type, summary
|
||||
)
|
||||
|
||||
for outer_key, outer_value in summary.items():
|
||||
for inner_key, inner_value in outer_value.items():
|
||||
if outer_key == cls.cash_money_type:
|
||||
result['cash'][inner_key]['summary'] = inner_value
|
||||
elif outer_key == cls.bank_money_type:
|
||||
result['bank'][inner_key]['summary'] = inner_value
|
||||
result['bank']['643']['data']['main'].sort(key=lambda x: x['amount_balance'], reverse=True)
|
||||
result['bank']['643']['data']['other'].sort(key=lambda x: x['amount_balance'], reverse=True)
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def create_currency_object(cls, result, balance_object, object_money_type, summary):
|
||||
money_type = 'cash' if object_money_type == cls.cash_money_type else 'bank'
|
||||
if not result.get(money_type):
|
||||
result[money_type] = {}
|
||||
if not result[money_type].get(balance_object['currency']):
|
||||
result[money_type][balance_object['currency']] = {}
|
||||
if not result[money_type][balance_object['currency']].get('data'):
|
||||
result[money_type][balance_object['currency']]['data'] = {}
|
||||
|
||||
summary_for_type = summary[object_money_type][balance_object['currency']]
|
||||
percent = balance_object['amount_balance'] * 100 / summary_for_type
|
||||
if not result[money_type][balance_object['currency']]['data'].get('main'):
|
||||
result[money_type][balance_object['currency']]['data']['main'] = []
|
||||
result[money_type][balance_object['currency']]['data']['other'] = []
|
||||
|
||||
if percent > 2:
|
||||
result[money_type][balance_object['currency']]['data']['main'].append(balance_object)
|
||||
else:
|
||||
result[money_type][balance_object['currency']]['data']['other'].append(balance_object)
|
||||
|
||||
@classmethod
|
||||
def get_balance_grouped_by_percent(cls) -> tuple[dict[str, list], float]:
|
||||
data, summary = cls.get_balance_raw()
|
||||
main_group = []
|
||||
other_group = []
|
||||
for item in data:
|
||||
percent = item.amount_balance * 100 / summary
|
||||
if percent > 3:
|
||||
main_group.append(asdict(item))
|
||||
else:
|
||||
other_group.append(asdict(item))
|
||||
main_group.sort(key=lambda x: x['amount_balance'], reverse=True)
|
||||
other_group.sort(key=lambda x: x['amount_balance'], reverse=True)
|
||||
|
||||
return (
|
||||
{
|
||||
'main_group': main_group,
|
||||
'other_group': other_group,
|
||||
},
|
||||
summary,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_debts_grouped_by_percent(cls):
|
||||
data = cls.get_debts_raw()
|
||||
buyers_main_group, buyers_other_group = cls.sort_object_by_percent(
|
||||
data['buyers']
|
||||
)
|
||||
providers_main_group, providers_other_group = cls.sort_object_by_percent(
|
||||
data['providers']
|
||||
)
|
||||
return {
|
||||
'buyers': {
|
||||
'main_group': buyers_main_group,
|
||||
'other_group': buyers_other_group,
|
||||
'summary': data['buyers']['summary'],
|
||||
},
|
||||
'providers': {
|
||||
'main_group': providers_main_group,
|
||||
'other_group': providers_other_group,
|
||||
'summary': data['providers']['summary'],
|
||||
},
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def sort_object_by_percent(cls, obj):
|
||||
main_group = []
|
||||
other_group = []
|
||||
for item in obj['debts']:
|
||||
percent = item.debt * 100 / obj['summary']['debt']
|
||||
if percent > 1:
|
||||
main_group.append(asdict(item))
|
||||
else:
|
||||
other_group.append(asdict(item))
|
||||
main_group.sort(key=lambda x: x['debt'], reverse=True)
|
||||
other_group.sort(key=lambda x: x['debt'], reverse=True)
|
||||
return main_group, other_group
|
||||
15
app/apps/finance/services/integration_1c/views.py
Normal file
15
app/apps/finance/services/integration_1c/views.py
Normal file
@ -0,0 +1,15 @@
|
||||
from apps.finance.services.integration_1c.service import Finance1CService
|
||||
from apps.util.base_view import base_view
|
||||
from django.http import JsonResponse
|
||||
|
||||
|
||||
@base_view
|
||||
def get_balance(request):
|
||||
data = Finance1CService.get_balance()
|
||||
return JsonResponse(data)
|
||||
|
||||
|
||||
@base_view
|
||||
def get_debtor_debts(request):
|
||||
data = Finance1CService.get_debtor_debts()
|
||||
return JsonResponse(data)
|
||||
487
app/apps/finance/templates/finance/fin_index.html
Normal file
487
app/apps/finance/templates/finance/fin_index.html
Normal file
@ -0,0 +1,487 @@
|
||||
{% extends 'default.html' %}
|
||||
{% load humanize %}
|
||||
|
||||
{% block content %}
|
||||
<div class="m-content" style="padding-top: 10px; padding-bottom: 10px;">
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<div class="m-portlet">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
<b>Остатки по счетам</b>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body p-3">
|
||||
<div class="d-flex mb-3 p-2" style="gap: 50px; border-bottom: 1px solid #ebedf2 ">
|
||||
<span style="color: #6f727d; font-size: 15px">
|
||||
Банк
|
||||
<br>
|
||||
<span style="font-size: 16px; font-weight: bold">{{ balances.bank.643.summary|intcomma }} ₽</span> <br>
|
||||
<span style="font-size: 16px; font-weight: bold">{{ balances.bank.156.summary|intcomma }} ¥</span>
|
||||
</span>
|
||||
|
||||
<span style="color: #6f727d; font-size: 15px">
|
||||
Касса
|
||||
<br>
|
||||
<span style="font-size: 16px; font-weight: bold;">{{ balances.cash.643.summary|intcomma }} ₽</span>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<div class="row divider-vertical">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4 style="font-size: 18px">Более 2% от общего баланса</h4>
|
||||
<div id="amountChart" style="min-height: 300px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4 style="font-size: 18px">До 2% от общего баланса</h4>
|
||||
<div id="amountChart2"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h4 style="font-size: 18px">Все счета</h4>
|
||||
<div class="position-sticky" style="top: -5px">
|
||||
<div class="d-flex">
|
||||
<span class=""></span>
|
||||
<div class="w-100"
|
||||
style="display: grid; grid-template-columns: 1fr 0.25fr 0.25fr">
|
||||
<span style="display: flex; align-items: center">
|
||||
</span>
|
||||
<div class="d-flex flex-column justify-content-end">
|
||||
<span class="pr-2 text-align-end"><b>Процент от баланса</b></span>
|
||||
</div>
|
||||
<div class="d-flex flex-column">
|
||||
<span class="pr-2 text-align-end"><b>Остаток</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-list-timeline" style="max-height: 380px; overflow-x: hidden;">
|
||||
<div class="m-list-timeline__items">
|
||||
{% for balance in balances.bank.643.data.main %}
|
||||
<div class="m-list-timeline__item">
|
||||
<div class="d-flex">
|
||||
<span class="m-list-timeline__badge m-list-timeline__badge--success"></span>
|
||||
<div class="w-100"
|
||||
style="display: grid; grid-template-columns: 1fr 0.25fr 0.25fr">
|
||||
<span>
|
||||
{% if balance.bank_name and balance.account_number %}
|
||||
{{ balance.bank_name }}: {{ balance.account_number }}
|
||||
{% else %}
|
||||
{% if balance.place %}
|
||||
{{ balance.place }}
|
||||
{% else %}
|
||||
Безымянный счет
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span>
|
||||
<span class="pr-2 text-align-end"><b>{{ balance.percent|floatformat:1 }} %</b></span>
|
||||
|
||||
<span class="pr-2 text-align-end"><b>{{ balance.amount_balance|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
{% for balance in balances.bank.643.data.other %}
|
||||
<div class="m-list-timeline__item">
|
||||
<div class="d-flex">
|
||||
<span class="m-list-timeline__badge m-list-timeline__badge--primary"></span>
|
||||
<div class="w-100"
|
||||
style="display: grid; grid-template-columns: 1fr 0.25fr 0.25fr">
|
||||
<span>
|
||||
{% if balance.bank_name and balance.account_number %}
|
||||
{{ balance.bank_name }}: {{ balance.account_number }}
|
||||
{% else %}
|
||||
{% if balance.place %}
|
||||
{{ balance.place }}
|
||||
{% else %}
|
||||
Безымянный счет
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span>
|
||||
<span class="pr-2 text-align-end"><b>{{ balance.percent|floatformat:3 }} %</b></span>
|
||||
|
||||
<span class="pr-2 text-align-end"><b>{{ balance.amount_balance|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<div class="m-portlet m-portlet--tabs">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
<b>Задолженности</b>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__head-tools">
|
||||
<ul class="nav nav-tabs m-tabs m-tabs-line m-tabs-line--right m-tabs-line-danger"
|
||||
role="tablist">
|
||||
<li class="nav-item m-tabs__item">
|
||||
<a class="nav-link m-tabs__link active show" data-toggle="tab"
|
||||
href="#buyers-tab" role="tab" aria-selected="true">
|
||||
Покупатели
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item m-tabs__item">
|
||||
<a class="nav-link m-tabs__link" data-toggle="tab" href="#providers-tab"
|
||||
role="tab" aria-selected="false">
|
||||
Поставщики
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active show" id="buyers-tab">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h4 style="font-size: 18px">Более 1% от общего долга</h4>
|
||||
|
||||
<span class="m-widget12__text1" style="color: #6f727d; font-size: 15px">
|
||||
Общая задолженность по покупателям
|
||||
<br>
|
||||
<span>Долг: </span><span
|
||||
style="font-size: 16px; font-weight: bold;">{{ debts.buyers.summary.debt|intcomma }} ₽</span>
|
||||
<br>
|
||||
<span>Аванс: </span><span
|
||||
style="font-size: 16px; font-weight: bold;">{{ debts.buyers.summary.advance|intcomma }} ₽</span>
|
||||
|
||||
</div>
|
||||
<div id="debtsBuyersChart"></div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<h4 style="font-size: 18px">Все задолженности по покупателям</h4>
|
||||
<div class="position-sticky" style="top: -5px">
|
||||
<div class="d-flex">
|
||||
<span class=""></span>
|
||||
<div class="w-100"
|
||||
style="display: grid; grid-template-columns: 1fr 0.5fr 0.5fr">
|
||||
<span style="display: flex; align-items: center">
|
||||
</span>
|
||||
<div class="d-flex flex-column justify-content-end">
|
||||
<span class="pr-2 text-align-end"><b>Долг</b></span>
|
||||
</div>
|
||||
<div class="d-flex flex-column">
|
||||
|
||||
<span class="pr-2 text-align-end"><b>Аванс</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-list-timeline" style="max-height: 250px; overflow-x: hidden;">
|
||||
<div class="m-list-timeline__items">
|
||||
{% for debtor in debts.buyers.main_group %}
|
||||
<div class="m-list-timeline__item">
|
||||
<div class="d-flex">
|
||||
<span class="m-list-timeline__badge m-list-timeline__badge--success"></span>
|
||||
<div class="w-100"
|
||||
style="display: grid; grid-template-columns: 1fr 0.5fr 0.5fr">
|
||||
<span style="display: flex; align-items: center">
|
||||
{{ debtor.counter_party }}
|
||||
</span>
|
||||
<div class="d-flex flex-column justify-content-end">
|
||||
<span class="pr-2 text-align-end"><b>{{ debtor.debt|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
<div class="d-flex flex-column">
|
||||
|
||||
<span class="pr-2 text-align-end"><b>{{ debtor.advance|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for debtor in debts.buyers.other_group %}
|
||||
<div class="m-list-timeline__item">
|
||||
<div class="d-flex">
|
||||
<span class="m-list-timeline__badge m-list-timeline__badge--primary"></span>
|
||||
<div class="w-100"
|
||||
style="display: grid; grid-template-columns: 1fr 0.5fr 0.5fr">
|
||||
<span style="display: flex; align-items: center">
|
||||
{{ debtor.counter_party }}
|
||||
</span>
|
||||
<div class="d-flex flex-column justify-content-end">
|
||||
<span class="pr-2 text-align-end"><b>{{ debtor.debt|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
<div class="d-flex flex-column">
|
||||
<span class="pr-2 text-align-end"><b>{{ debtor.advance|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="providers-tab">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h4 style="font-size: 18px">Более 1% от общего долга</h4>
|
||||
|
||||
<span class="m-widget12__text1" style="color: #6f727d; font-size: 15px">
|
||||
Общая дебиторская задолженность по поставщикам
|
||||
<br>
|
||||
<span>Долг: </span><span
|
||||
style="font-size: 16px; font-weight: bold;">{{ debts.providers.summary.debt|intcomma }} ₽</span>
|
||||
<br>
|
||||
<span>Аванс: </span><span
|
||||
style="font-size: 16px; font-weight: bold;">{{ debts.providers.summary.advance|intcomma }} ₽</span>
|
||||
|
||||
</div>
|
||||
<div id="debtsProvidersChart"></div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<h4 style="font-size: 18px">Все задолженности по поставщикам</h4>
|
||||
<div class="position-sticky" style="top: -5px">
|
||||
<div class="d-flex">
|
||||
<span class=""></span>
|
||||
<div class="w-100"
|
||||
style="display: grid; grid-template-columns: 1fr 0.5fr 0.5fr">
|
||||
<span style="display: flex; align-items: center">
|
||||
</span>
|
||||
<div class="d-flex flex-column justify-content-end">
|
||||
<span class="pr-2 text-align-end"><b>Долг</b></span>
|
||||
</div>
|
||||
<div class="d-flex flex-column">
|
||||
<span class="pr-2 text-align-end"><b>Аванс</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-list-timeline" style="max-height: 250px; overflow-x: hidden;">
|
||||
<div class="m-list-timeline__items">
|
||||
{% for debtor in debts.providers.main_group %}
|
||||
<div class="m-list-timeline__item">
|
||||
<div class="d-flex">
|
||||
<span class="m-list-timeline__badge m-list-timeline__badge--success"></span>
|
||||
<div class="w-100"
|
||||
style="display: grid; grid-template-columns: 1fr 0.5fr 0.5fr">
|
||||
<span style="display: flex; align-items: center">
|
||||
{{ debtor.counter_party }}
|
||||
</span>
|
||||
<div class="d-flex flex-column justify-content-end">
|
||||
<span class="pr-2 text-align-end"><b>{{ debtor.debt|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
<div class="d-flex flex-column">
|
||||
<span class="pr-2 text-align-end"><b>{{ debtor.advance|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for debtor in debts.providers.other_group %}
|
||||
<div class="m-list-timeline__item">
|
||||
<div class="d-flex">
|
||||
<span class="m-list-timeline__badge m-list-timeline__badge--primary"></span>
|
||||
<div class="w-100"
|
||||
style="display: grid; grid-template-columns: 1fr 0.5fr 0.5fr">
|
||||
<span style="display: flex; align-items: center">
|
||||
{{ debtor.counter_party }}
|
||||
</span>
|
||||
<div class="d-flex flex-column justify-content-end">
|
||||
<span class="pr-2 text-align-end"><b>{{ debtor.debt|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
<div class="d-flex flex-column">
|
||||
<span class="pr-2 text-align-end"><b>{{ debtor.advance|intcomma }} ₽</b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block script_footer %}
|
||||
<script>
|
||||
const prettify = (num, separator = ' ') => {
|
||||
const n = num.toString();
|
||||
return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1" + separator);
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const amountChart = document.getElementById('amountChart');
|
||||
const amountChart2 = document.getElementById('amountChart2');
|
||||
|
||||
const balanceList = {{ balances_json|safe }};
|
||||
console.log(balanceList)
|
||||
const mainSeriesData = balanceList.bank["643"].data.main.map(item => item.amount_balance);
|
||||
const mainLabelsData = balanceList.bank["643"].data.main.map(item => item.account_number ? item.account_number : item.place);
|
||||
|
||||
|
||||
const otherSeriesData = balanceList.bank["643"].data.other.map(item => item.amount_balance);
|
||||
const otherLabelsData = balanceList.bank["643"].data.other.map(item => item.account_number ? item.account_number : item.place);
|
||||
|
||||
const baseOptions = {
|
||||
chart: {
|
||||
type: 'donut',
|
||||
height: 200
|
||||
},
|
||||
tooltip: {
|
||||
y: {
|
||||
formatter: function (value) {
|
||||
return prettify(value) + ' ₽'; // или любой формат, например с пробелами
|
||||
},
|
||||
title: {
|
||||
formatter: function (seriesName) {
|
||||
return "Счет: " + seriesName + " -"; // по умолчанию — просто имя серии
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: false
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
};
|
||||
const options = {
|
||||
...baseOptions,
|
||||
series: mainSeriesData,
|
||||
labels: mainLabelsData,
|
||||
};
|
||||
const options2 = {
|
||||
...baseOptions,
|
||||
series: otherSeriesData,
|
||||
labels: otherLabelsData
|
||||
}
|
||||
const chart = new ApexCharts(amountChart, options);
|
||||
chart.render();
|
||||
|
||||
const chart2 = new ApexCharts(amountChart2, options2)
|
||||
chart2.render();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const debtsBuyersChart = document.getElementById('debtsBuyersChart')
|
||||
const debtsProvidersChart = document.getElementById('debtsProvidersChart')
|
||||
|
||||
|
||||
const debts = {{ debts_json|safe }};
|
||||
|
||||
const buyersMainCategories = debts.buyers.main_group.map(item => item.counter_party);
|
||||
const buyersMainAdvances = debts.buyers.main_group.map(item => item.advance);
|
||||
const buyersMainDebts = debts.buyers.main_group.map(item => item.debt);
|
||||
|
||||
|
||||
const providersMainCategories = debts.providers.main_group.map(item => item.counter_party);
|
||||
const providersMainAdvances = debts.providers.main_group.map(item => item.advance);
|
||||
const providersMainDebts = debts.providers.main_group.map(item => item.debt);
|
||||
|
||||
const baseOptions = {
|
||||
chart: {
|
||||
type: 'bar',
|
||||
height: 300
|
||||
},
|
||||
|
||||
plotOptions: {
|
||||
bar: {
|
||||
horizontal: true,
|
||||
dataLabels: {
|
||||
position: 'top',
|
||||
},
|
||||
}
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
offsetX: -6,
|
||||
style: {
|
||||
fontSize: '12px',
|
||||
colors: ['#fff']
|
||||
}
|
||||
},
|
||||
stroke: {
|
||||
show: true,
|
||||
width: 1,
|
||||
colors: ['#fff']
|
||||
},
|
||||
tooltip: {
|
||||
shared: true,
|
||||
intersect: false,
|
||||
y: {
|
||||
formatter: function (value) {
|
||||
return prettify(value) + ' ₽'; // или любой формат, например с пробелами
|
||||
},
|
||||
title: {
|
||||
formatter: function (seriesName) {
|
||||
return seriesName + " -"; // по умолчанию — просто имя серии
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var mainBuyersDebtsOptions = {
|
||||
...baseOptions,
|
||||
series: [{
|
||||
name: "Долг",
|
||||
data: buyersMainDebts
|
||||
}, {
|
||||
name: "Аванс",
|
||||
data: buyersMainAdvances
|
||||
}],
|
||||
xaxis: {
|
||||
categories: buyersMainCategories,
|
||||
},
|
||||
};
|
||||
|
||||
var mainProvidersDebtsOptions = {
|
||||
...baseOptions,
|
||||
series: [{
|
||||
name: "Долг",
|
||||
data: providersMainDebts
|
||||
}, {
|
||||
name: "Аванс",
|
||||
data: providersMainAdvances
|
||||
}],
|
||||
xaxis: {
|
||||
categories: providersMainCategories,
|
||||
},
|
||||
};
|
||||
|
||||
var buyersMainChart = new ApexCharts(debtsBuyersChart, mainBuyersDebtsOptions);
|
||||
buyersMainChart.render();
|
||||
|
||||
|
||||
var providersMainChart = new ApexCharts(debtsProvidersChart, mainProvidersDebtsOptions);
|
||||
providersMainChart.render();
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
11
app/apps/finance/urls.py
Normal file
11
app/apps/finance/urls.py
Normal file
@ -0,0 +1,11 @@
|
||||
from apps.finance.services.integration_1c.views import get_balance, get_debtor_debts
|
||||
from apps.finance.views_money import fin_index
|
||||
from django.urls import path
|
||||
|
||||
app_name = 'finance'
|
||||
|
||||
urlpatterns = [
|
||||
path('', fin_index, name='fin_index'),
|
||||
path('balance/', get_balance, name='get_balance'),
|
||||
path('debts/', get_debtor_debts, name='get_debtor_debts-'),
|
||||
]
|
||||
22
app/apps/finance/utils.py
Normal file
22
app/apps/finance/utils.py
Normal file
@ -0,0 +1,22 @@
|
||||
def get_currency_symbol_by_numeric_code(code: str) -> str:
|
||||
currency_map = {
|
||||
'840': '$', # USD — Доллар США
|
||||
'978': '€', # EUR — Евро
|
||||
'643': '₽', # RUB — Российский рубль
|
||||
'826': '£', # GBP — Британский фунт
|
||||
'392': '¥', # JPY — Японская иена
|
||||
'124': 'C$', # CAD — Канадский доллар
|
||||
'036': 'A$', # AUD — Австралийский доллар
|
||||
'756': 'CHF', # CHF — Швейцарский франк
|
||||
'156': '¥', # CNY — Китайский юань
|
||||
'410': '₩', # KRW — Южнокорейская вона
|
||||
'784': 'د.إ', # AED — Дирхам ОАЭ
|
||||
'356': '₹', # INR — Индийская рупия
|
||||
'949': '₺', # TRY — Турецкая лира
|
||||
'702': 'S$', # SGD — Сингапурский доллар
|
||||
'554': 'NZ$', # NZD — Новозеландский доллар
|
||||
'986': 'R$', # BRL — Бразильский реал
|
||||
'710': 'R', # ZAR — Южноафриканский рэнд
|
||||
}
|
||||
|
||||
return currency_map.get(code, '?')
|
||||
45
app/apps/finance/views_money.py
Normal file
45
app/apps/finance/views_money.py
Normal file
@ -0,0 +1,45 @@
|
||||
import json
|
||||
import traceback
|
||||
|
||||
from apps.finance.services.integration_1c.service import Finance1CService
|
||||
from apps.util.base_view import group_required
|
||||
from apps.util.generalmodule import get_context_template
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.shortcuts import render
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.views.decorators.cache import never_cache
|
||||
from sabron.util import logging
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@group_required('Финансы')
|
||||
@never_cache
|
||||
def fin_index(request):
|
||||
try:
|
||||
if request.method == 'GET':
|
||||
context = get_context_template(request)
|
||||
user_groups = [group.name for group in request.user.groups.all()]
|
||||
user_have_fin_group = 'Финансы' in user_groups
|
||||
user_have_coal_group = 'Уголь' in user_groups
|
||||
context['user_have_fin_group'] = user_have_fin_group
|
||||
context['user_have_coal_group'] = user_have_coal_group
|
||||
|
||||
service = Finance1CService()
|
||||
debts = service.get_debts_grouped_by_percent()
|
||||
balances = service.get_balance_grouped_by_money_type()
|
||||
return render(
|
||||
request,
|
||||
'finance/fin_index.html',
|
||||
{
|
||||
**context,
|
||||
'balances': balances,
|
||||
'balances_json': mark_safe(
|
||||
json.dumps(balances, cls=DjangoJSONEncoder)),
|
||||
|
||||
'debts': debts,
|
||||
'debts_json': mark_safe(json.dumps(debts, cls=DjangoJSONEncoder)),
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
logging.error(traceback.format_exc())
|
||||
@ -1,6 +1,6 @@
|
||||
from apps.main.models.accident_stops import AccidentStop
|
||||
from apps.main.models.aspiration_unit import AspirationUnit
|
||||
from apps.main.models.scales_control import Position, ScalesControl, ShiftReport
|
||||
from apps.main.models.scales_control import Position
|
||||
from apps.main.models.worktime import FabricWorkTime
|
||||
from django.contrib import admin
|
||||
|
||||
@ -17,18 +17,6 @@ class FabricWorkTimeAdmin(admin.ModelAdmin):
|
||||
]
|
||||
|
||||
|
||||
@admin.register(ScalesControl)
|
||||
class ScalesControlAdmin(admin.ModelAdmin):
|
||||
list_display = ['date_created', 'name', 'value']
|
||||
list_filter = ['time', 'name']
|
||||
ordering = [
|
||||
'-time',
|
||||
]
|
||||
|
||||
def date_created(self, obj):
|
||||
return obj.time.strftime('%x - %X')
|
||||
|
||||
|
||||
@admin.register(AccidentStop)
|
||||
class AccidentStopAdmin(admin.ModelAdmin):
|
||||
list_display = ['time']
|
||||
@ -41,11 +29,6 @@ class PositionAdmin(admin.ModelAdmin):
|
||||
list_display = ['title']
|
||||
|
||||
|
||||
@admin.register(ShiftReport)
|
||||
class ShiftReportAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
@admin.register(AspirationUnit)
|
||||
class AspirationUnitAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
@ -8,14 +8,21 @@ class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
dependencies = []
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AccidentStop',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
(
|
||||
'id',
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name='ID',
|
||||
),
|
||||
),
|
||||
('time', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
],
|
||||
options={
|
||||
@ -26,10 +33,27 @@ class Migration(migrations.Migration):
|
||||
migrations.CreateModel(
|
||||
name='FabricWorkTime',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
(
|
||||
'id',
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name='ID',
|
||||
),
|
||||
),
|
||||
('time', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('status', models.CharField(choices=[('WO', 'Работает под нагрузкой'),
|
||||
('WA', 'Работает без нагрузки'), ('NW', 'Не работает')], max_length=10)),
|
||||
(
|
||||
'status',
|
||||
models.CharField(
|
||||
choices=[
|
||||
('WO', 'Работает под нагрузкой'),
|
||||
('WA', 'Работает без нагрузки'),
|
||||
('NW', 'Не работает'),
|
||||
],
|
||||
max_length=10,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Время работы фабрики',
|
||||
@ -39,7 +63,15 @@ class Migration(migrations.Migration):
|
||||
migrations.CreateModel(
|
||||
name='Position',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
(
|
||||
'id',
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name='ID',
|
||||
),
|
||||
),
|
||||
('title', models.CharField(blank=True, max_length=100)),
|
||||
('tag', models.CharField(blank=True, max_length=80)),
|
||||
('aver_smena_tag', models.CharField(blank=True, max_length=80)),
|
||||
@ -57,9 +89,31 @@ class Migration(migrations.Migration):
|
||||
migrations.CreateModel(
|
||||
name='ScalesControl',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(blank=True, db_column='Name', max_length=150, null=True)),
|
||||
('value', models.DecimalField(blank=True, db_column='Values', decimal_places=6, max_digits=50, null=True)),
|
||||
(
|
||||
'id',
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name='ID',
|
||||
),
|
||||
),
|
||||
(
|
||||
'name',
|
||||
models.CharField(
|
||||
blank=True, db_column='Name', max_length=150, null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
'value',
|
||||
models.DecimalField(
|
||||
blank=True,
|
||||
db_column='Values',
|
||||
decimal_places=6,
|
||||
max_digits=50,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
('time', models.DateTimeField(blank=True, db_column='Date', null=True)),
|
||||
('check', models.BooleanField(db_column='Check', default=False)),
|
||||
],
|
||||
@ -71,7 +125,15 @@ class Migration(migrations.Migration):
|
||||
migrations.CreateModel(
|
||||
name='ShiftReport',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
(
|
||||
'id',
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name='ID',
|
||||
),
|
||||
),
|
||||
('time', models.DateTimeField()),
|
||||
('concentrate', models.FloatField()),
|
||||
('dropout', models.FloatField()),
|
||||
@ -92,7 +154,9 @@ class Migration(migrations.Migration):
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='scalescontrol',
|
||||
index=models.Index(fields=['name', 'time'], name='main_scales_Name_9fd251_idx'),
|
||||
index=models.Index(
|
||||
fields=['name', 'time'], name='main_scales_Name_9fd251_idx'
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='fabricworktime',
|
||||
|
||||
36
app/apps/main/migrations/0002_auto_20250410_0828.py
Normal file
36
app/apps/main/migrations/0002_auto_20250410_0828.py
Normal file
@ -0,0 +1,36 @@
|
||||
# Generated by Django 3.2.25 on 2025-04-10 01:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AspirationUnit',
|
||||
fields=[
|
||||
(
|
||||
'id',
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name='ID',
|
||||
),
|
||||
),
|
||||
('mfsb_id', models.IntegerField()),
|
||||
('tag', models.CharField(blank=True, max_length=50)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Аспирационная установка',
|
||||
'verbose_name_plural': 'Аспирационные установки',
|
||||
},
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='ShiftReport',
|
||||
),
|
||||
]
|
||||
31
app/apps/main/migrations/0003_auto_20250410_0831.py
Normal file
31
app/apps/main/migrations/0003_auto_20250410_0831.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Generated by Django 3.2.25 on 2025-04-10 01:31
|
||||
from django.contrib.auth.models import Group, User
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def forwards_func(apps, schema_editor):
|
||||
db_alias = schema_editor.connection.alias
|
||||
coal, _ = Group.objects.using(db_alias).get_or_create(name='Уголь')
|
||||
fin, _ = Group.objects.using(db_alias).get_or_create(name='Финансы')
|
||||
users = User.objects.using(db_alias).all()
|
||||
for user in users:
|
||||
user.groups.add(coal)
|
||||
|
||||
|
||||
def reverse_func(apps, schema_editor):
|
||||
db_alias = schema_editor.connection.alias
|
||||
try:
|
||||
Group.objects.using(db_alias).filter(name='Уголь').delete()
|
||||
Group.objects.using(db_alias).filter(name='Финансы').delete()
|
||||
except Group.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('main', '0002_auto_20250410_0828'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(forwards_func, reverse_func),
|
||||
]
|
||||
30
app/apps/main/migrations/0004_auto_20250424_1227.py
Normal file
30
app/apps/main/migrations/0004_auto_20250424_1227.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Generated by Django 3.2.25 on 2025-04-24 05:27
|
||||
|
||||
from django.db import migrations
|
||||
from sabron.models import Settings
|
||||
|
||||
|
||||
def forwards_func(apps, schema_editor):
|
||||
db_alias = schema_editor.connection.alias
|
||||
u_name, _ = Settings.objects.using(db_alias).get_or_create(name='charger_username', value='secret')
|
||||
u_pass, _ = Settings.objects.using(db_alias).get_or_create(name='charger_password', value='secret')
|
||||
|
||||
|
||||
def reverse_func(apps, schema_editor):
|
||||
db_alias = schema_editor.connection.alias
|
||||
try:
|
||||
Settings.objects.using(db_alias).filter(name='charger_username').delete()
|
||||
Settings.objects.using(db_alias).filter(name='charger_password').delete()
|
||||
except Settings.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0003_auto_20250410_0831'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(forwards_func, reverse_func),
|
||||
]
|
||||
@ -1,4 +1,3 @@
|
||||
from apps.main.services.base_service import DashboardBaseService
|
||||
from django.db import models
|
||||
|
||||
|
||||
@ -19,7 +18,7 @@ class ScalesControl(models.Model):
|
||||
return {
|
||||
'name': self.name,
|
||||
'values': self.value,
|
||||
'date': self.date,
|
||||
'date': self.time.isoformat(),
|
||||
}
|
||||
|
||||
def __str__(self):
|
||||
@ -47,20 +46,3 @@ class Position(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
||||
class ShiftReport(models.Model):
|
||||
time = models.DateTimeField(default=DashboardBaseService.get_current_time)
|
||||
scales_data = models.JSONField(blank=True, null=True)
|
||||
worktime_data = models.JSONField(blank=True, null=True)
|
||||
density_data = models.JSONField(blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Отчет за смену'
|
||||
verbose_name_plural = 'Отчет за смены'
|
||||
indexes = [
|
||||
models.Index(fields=['time'])
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.time}'
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.timezone import now
|
||||
|
||||
@ -16,18 +17,18 @@ class FabricWorkTime(models.Model):
|
||||
time = models.DateTimeField(default=now)
|
||||
status = models.CharField(
|
||||
choices=(
|
||||
("WO", "Работает под нагрузкой"),
|
||||
("WA", "Работает без нагрузки"),
|
||||
("NW", "Не работает"),
|
||||
('WO', 'Работает под нагрузкой'),
|
||||
('WA', 'Работает без нагрузки'),
|
||||
('NW', 'Не работает'),
|
||||
),
|
||||
max_length=10,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Время работы фабрики"
|
||||
verbose_name_plural = "Отрезки времени работы фабрики"
|
||||
verbose_name = 'Время работы фабрики'
|
||||
verbose_name_plural = 'Отрезки времени работы фабрики'
|
||||
|
||||
indexes = (models.Index(fields=["time"]),)
|
||||
indexes = (models.Index(fields=['time']),)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.time}: {self.status}"
|
||||
return f'{self.time.astimezone(settings.TIME_ZONE_OBJECT)}: {self.status}'
|
||||
|
||||
@ -13,9 +13,11 @@ class AccidentStopsService(DashboardBaseService):
|
||||
time_ranges = {
|
||||
'month': now_date - relativedelta(hours=730),
|
||||
'week': now_date - relativedelta(hours=168),
|
||||
'day': now_date - relativedelta(hours=24)
|
||||
'day': now_date - relativedelta(hours=24),
|
||||
}
|
||||
stops_by_ranges = {}
|
||||
for key, start_time in time_ranges.items():
|
||||
stops_by_ranges[f'stops_by_{key}'] = AccidentStopRepository.count_stops_by_range(start_time, now_date)
|
||||
stops_by_ranges[f'stops_by_{key}'] = (
|
||||
AccidentStopRepository.count_stops_by_range(start_time, now_date)
|
||||
)
|
||||
return stops_by_ranges
|
||||
|
||||
@ -9,7 +9,9 @@ class AspirationUnitAPI:
|
||||
|
||||
def get_aspiration_unit_by_id(self, id: int):
|
||||
try:
|
||||
response = requests.get(f'{self.api_host}/api/v2/scada/sensor/{id}', timeout=1)
|
||||
response = requests.get(
|
||||
f'{self.api_host}/api/v2/scada/sensor/{id}', timeout=1
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error(str(e))
|
||||
return {}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
@ -21,7 +22,7 @@ class DashboardBaseService:
|
||||
|
||||
@staticmethod
|
||||
def get_current_time():
|
||||
return timezone.now()
|
||||
return timezone.now().astimezone(settings.TIME_ZONE_OBJECT)
|
||||
|
||||
@staticmethod
|
||||
def get_shift_start(now_date: datetime):
|
||||
@ -40,9 +41,9 @@ class DashboardBaseService:
|
||||
total_seconds = dt.hour * 3600 + dt.minute * 60 + dt.second
|
||||
# Округляем до ближайшего часа
|
||||
if total_seconds % 3600 >= 1800: # Если больше половины часа
|
||||
total_seconds += (3600 - (total_seconds % 3600)) # Округляем вверх
|
||||
total_seconds += 3600 - (total_seconds % 3600) # Округляем вверх
|
||||
else:
|
||||
total_seconds -= (total_seconds % 3600) # Округляем вниз
|
||||
total_seconds -= total_seconds % 3600 # Округляем вниз
|
||||
# Получаем новые часы, минуты и секунды
|
||||
new_hour = (total_seconds // 3600) % 24 # 24-часовой формат
|
||||
return dt.replace(hour=new_hour, minute=0, second=0, microsecond=0)
|
||||
|
||||
@ -13,7 +13,8 @@ class DensitySensorAPI:
|
||||
try:
|
||||
response = requests.get(
|
||||
f'{self.api_host}/api/v1/json/montorem/?method=sensor_list',
|
||||
auth=(self.api_login, self.api_password), timeout=1
|
||||
auth=(self.api_login, self.api_password),
|
||||
timeout=1,
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error(str(e))
|
||||
|
||||
34
app/apps/main/services/meteo/api.py
Normal file
34
app/apps/main/services/meteo/api.py
Normal file
@ -0,0 +1,34 @@
|
||||
import datetime
|
||||
import traceback
|
||||
|
||||
import requests
|
||||
from sabron.util import logging
|
||||
from sabron.util.sabronmodule import get_settings
|
||||
|
||||
|
||||
class MeteoStationAPI:
|
||||
def __init__(self):
|
||||
self.api_token = get_settings('meteo_api_token')
|
||||
self.post_id = get_settings('post_id')
|
||||
|
||||
def get_latest_post(self) -> dict | bool:
|
||||
headers = {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': f'Bearer {self.api_token}',
|
||||
}
|
||||
try:
|
||||
date_today = datetime.datetime.now().date().isoformat()
|
||||
|
||||
url = f'https://mycityair.ru/harvester/v2/Posts/{self.post_id}/measurements?interval=1h&date__gt={date_today}&limit=1'
|
||||
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()['data']
|
||||
if len(data) > 0:
|
||||
return data[-1]
|
||||
return {}
|
||||
|
||||
except Exception:
|
||||
logging.error(traceback.format_exc())
|
||||
return {}
|
||||
9
app/apps/main/services/meteo/service.py
Normal file
9
app/apps/main/services/meteo/service.py
Normal file
@ -0,0 +1,9 @@
|
||||
from apps.main.services.base_service import DashboardBaseService
|
||||
from apps.main.services.meteo.api import MeteoStationAPI
|
||||
|
||||
|
||||
class MeteoStationService(DashboardBaseService):
|
||||
@staticmethod
|
||||
def get_latest_post():
|
||||
api = MeteoStationAPI()
|
||||
return api.get_latest_post()
|
||||
9
app/apps/main/services/meteo/views.py
Normal file
9
app/apps/main/services/meteo/views.py
Normal file
@ -0,0 +1,9 @@
|
||||
from apps.main.services.meteo.service import MeteoStationService
|
||||
from apps.util.base_view import base_view
|
||||
from django.http import JsonResponse
|
||||
|
||||
|
||||
@base_view
|
||||
def get_meteo_data(request):
|
||||
data = MeteoStationService.get_latest_post()
|
||||
return JsonResponse(data, safe=False)
|
||||
@ -3,20 +3,19 @@ from typing import Any
|
||||
|
||||
from apps.main.services.base_service import DashboardBaseService
|
||||
from apps.util.redis_api import RedisService
|
||||
from django.conf import settings
|
||||
from django.db.models import QuerySet
|
||||
|
||||
try:
|
||||
from repcofkk.local_settings import REDIS_HOST, REDIS_PORT
|
||||
except ModuleNotFoundError:
|
||||
from repcofkk.production_settings import REDIS_HOST, REDIS_PORT
|
||||
REDIS_HOST = settings.REDIS_HOST
|
||||
REDIS_PORT = settings.REDIS_PORT
|
||||
|
||||
|
||||
class RedisRepository(DashboardBaseService):
|
||||
def __init__(
|
||||
self,
|
||||
control_conveyor_month: str,
|
||||
fabric_goal: str,
|
||||
service: RedisService = RedisService(host=REDIS_HOST, port=REDIS_PORT, db=1),
|
||||
self,
|
||||
control_conveyor_month: str,
|
||||
fabric_goal: str,
|
||||
service: RedisService = RedisService(host=REDIS_HOST, port=REDIS_PORT, db=1),
|
||||
):
|
||||
self.fabric_goal = fabric_goal
|
||||
self.control_conveyor_month = control_conveyor_month
|
||||
@ -66,7 +65,7 @@ class RedisRepository(DashboardBaseService):
|
||||
res['percent_values'] = self.get_percent_values(
|
||||
scales.get('Поз. 13', 0),
|
||||
scales.get('Поз. 22', 0),
|
||||
scales.get('Поз. 4', 0)
|
||||
scales.get('Поз. 4', 0),
|
||||
)
|
||||
res['latest_date'] = latest_date
|
||||
except AttributeError:
|
||||
@ -173,15 +172,25 @@ class RedisRepository(DashboardBaseService):
|
||||
with self.service as redis_service:
|
||||
kek = redis_service.get_value('kek')
|
||||
breed = redis_service.get_value('breed')
|
||||
pos4_value = redis_service.hget_value('SIEMENSPLC.AZG01.ReportProdDB.ProdPos4.Smena', 'Value')
|
||||
pos13_value = redis_service.hget_value('SIEMENSPLC.AZG01.ReportProdDB.ProdPos13.Smena', 'Value')
|
||||
pos22_value = redis_service.hget_value('SIEMENSPLC.AZG01.ReportProdDB.ProdPos22.Smena', 'Value')
|
||||
pos4_value = redis_service.hget_value(
|
||||
'SIEMENSPLC.AZG01.ReportProdDB.ProdPos4.Smena', 'Value'
|
||||
)
|
||||
pos13_value = redis_service.hget_value(
|
||||
'SIEMENSPLC.AZG01.ReportProdDB.ProdPos13.Smena', 'Value'
|
||||
)
|
||||
pos22_value = redis_service.hget_value(
|
||||
'SIEMENSPLC.AZG01.ReportProdDB.ProdPos22.Smena', 'Value'
|
||||
)
|
||||
if kek is None or breed is None:
|
||||
value = False
|
||||
else:
|
||||
value = self.calculate_concentrate_and_dropout_value(int(float(pos4_value)), int(float(pos13_value)),
|
||||
int(float(pos22_value)), int(float(kek)),
|
||||
int(float(breed)))
|
||||
value = self.calculate_concentrate_and_dropout_value(
|
||||
int(float(pos4_value)),
|
||||
int(float(pos13_value)),
|
||||
int(float(pos22_value)),
|
||||
int(float(kek)),
|
||||
int(float(breed)),
|
||||
)
|
||||
|
||||
return value
|
||||
|
||||
@ -209,25 +218,25 @@ class RedisRepository(DashboardBaseService):
|
||||
|
||||
@staticmethod
|
||||
def calculate_concentrate_and_dropout_value(
|
||||
pos4_value: int, pos13_value: int, pos22_value: int, kek: int, breed: int
|
||||
pos4_value: int, pos13_value: int, pos22_value: int, kek: int, breed: int
|
||||
) -> dict[str, int | str]:
|
||||
try:
|
||||
concentrate: int | float = (
|
||||
(pos4_value - pos13_value - (kek * 0.6) - breed) / (pos4_value / 100)
|
||||
)
|
||||
pos4_value - pos13_value - (kek * 0.6) - breed
|
||||
) / (pos4_value / 100)
|
||||
except ZeroDivisionError:
|
||||
concentrate = 0 # Возвращаем число вместо строки
|
||||
|
||||
try:
|
||||
dropout: int | float = (
|
||||
(pos4_value - pos22_value - (kek * 0.6) - breed) / (pos4_value / 100)
|
||||
dropout: int | float = (pos4_value - pos22_value - (kek * 0.6) - breed) / (
|
||||
pos4_value / 100
|
||||
)
|
||||
except ZeroDivisionError:
|
||||
dropout = 0 # Возвращаем число вместо строки
|
||||
|
||||
result: dict[str, int | str] = {
|
||||
'concentrate': abs(int(concentrate)),
|
||||
'dropout': abs(int(dropout))
|
||||
'dropout': abs(int(dropout)),
|
||||
}
|
||||
return result
|
||||
|
||||
|
||||
@ -19,7 +19,13 @@ def get_scales_data(request):
|
||||
plan = service.get_scales_value_with_plan()
|
||||
concentrate = service.get_concentrate_value()
|
||||
return JsonResponse(
|
||||
{'daily': daily, 'average': average, 'monthly': monthly, 'plan': plan, 'concentrate_and_dropout': concentrate}
|
||||
{
|
||||
'daily': daily,
|
||||
'average': average,
|
||||
'monthly': monthly,
|
||||
'plan': plan,
|
||||
'concentrate_and_dropout': concentrate,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -38,11 +44,19 @@ def set_kek_and_breed(request):
|
||||
if ('kek' in data and 'breed' in data) and (data['kek'] and data['breed']):
|
||||
service = RedisRepository(control_conveyor_month, fabric_goal)
|
||||
if service.set_kek_and_breed_values(data):
|
||||
return JsonResponse({'success': True, 'message': 'Данные успешно переданы'})
|
||||
return JsonResponse({'success': False, 'message': 'Возникла ошибка'},
|
||||
status=418)
|
||||
return JsonResponse({'success': False, 'message': 'Поля формы заполнены не корректно или не заполнены!'},
|
||||
status=418)
|
||||
return JsonResponse(
|
||||
{'success': True, 'message': 'Данные успешно переданы'}
|
||||
)
|
||||
return JsonResponse(
|
||||
{'success': False, 'message': 'Возникла ошибка'}, status=418
|
||||
)
|
||||
return JsonResponse(
|
||||
{
|
||||
'success': False,
|
||||
'message': 'Поля формы заполнены не корректно или не заполнены!',
|
||||
},
|
||||
status=418,
|
||||
)
|
||||
return JsonResponse({'success': False, 'message': 'only POST allowed'}, status=400)
|
||||
|
||||
|
||||
|
||||
@ -26,15 +26,13 @@ urlpatterns = [
|
||||
),
|
||||
path('worktime/create/', create_worktime, name='create_worktime'),
|
||||
path('status/', get_current_status, name='current_status'),
|
||||
|
||||
path('positions/', get_positions, name='get_positions'),
|
||||
|
||||
path('density_sensors/', get_sensors_list, name='get_sensors_list'),
|
||||
|
||||
path('scales/', get_scales_data, name='scales'),
|
||||
path('scales/kek_and_breed/recieve/', set_kek_and_breed, name='receive_kek_and_breed'),
|
||||
path(
|
||||
'scales/kek_and_breed/recieve/', set_kek_and_breed, name='receive_kek_and_breed'
|
||||
),
|
||||
path('scales/kek_and_breed/', get_kek_and_breed, name='get_kek_and_breed'),
|
||||
path('scales/fabric_goal/', fabric_goal, name='fabric_goal'),
|
||||
|
||||
path('aspiration_units/', get_aspiration_units_data),
|
||||
]
|
||||
|
||||
@ -18,12 +18,12 @@ def create_worktime_data() -> bool:
|
||||
control_conveyor = get_settings('control_conveyor')
|
||||
|
||||
# получение данных с весов поминутно
|
||||
latest_records_scales = ScalesControl.objects.filter(
|
||||
name=control_conveyor,
|
||||
time__lte=start_period
|
||||
).annotate(
|
||||
time_minute=TruncMinute('time')
|
||||
).order_by('time_minute').distinct('time_minute')
|
||||
latest_records_scales = (
|
||||
ScalesControl.objects.filter(name=control_conveyor, time__lte=start_period)
|
||||
.annotate(time_minute=TruncMinute('time'))
|
||||
.order_by('time_minute')
|
||||
.distinct('time_minute')
|
||||
)
|
||||
|
||||
# если нет записей с весов - выход из функции
|
||||
if not latest_records_scales:
|
||||
|
||||
@ -36,11 +36,14 @@ class FabricWorkTimeService(DashboardBaseService):
|
||||
|
||||
return status_durations_hours
|
||||
|
||||
def add_time_from_last_value(self, worktime_values: dict, start_period: datetime, diff: timedelta) -> dict:
|
||||
def add_time_from_last_value(
|
||||
self, worktime_values: dict, start_period: datetime, diff: timedelta
|
||||
) -> dict:
|
||||
|
||||
try:
|
||||
last_value = FabricWorkTime.objects.filter(time__lte=start_period,
|
||||
time__gte=start_period - timedelta(hours=168)).last()
|
||||
last_value = FabricWorkTime.objects.filter(time__lte=start_period).latest(
|
||||
'time'
|
||||
)
|
||||
if last_value is None:
|
||||
return worktime_values
|
||||
worktime_values[last_value.status] += diff
|
||||
@ -51,7 +54,9 @@ class FabricWorkTimeService(DashboardBaseService):
|
||||
def return_worktime(self, return_durations: bool = False):
|
||||
now_date = self.get_current_time()
|
||||
start_month = now_date.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
|
||||
start_week = (now_date - timedelta(days=now_date.weekday())).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
start_week = (now_date - timedelta(days=now_date.weekday())).replace(
|
||||
hour=0, minute=0, second=0, microsecond=0
|
||||
)
|
||||
start_shift = self.get_shift_start(now_date)
|
||||
|
||||
monthly_qs = self.get_qs_by_range(start_month, now_date)
|
||||
@ -76,7 +81,9 @@ class FabricWorkTimeService(DashboardBaseService):
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def check_worktime_validity(cls, worktime: dict, start_period: datetime, now_date: datetime) -> timedelta:
|
||||
def check_worktime_validity(
|
||||
cls, worktime: dict, start_period: datetime, now_date: datetime
|
||||
) -> timedelta:
|
||||
mas_worktime = [i for i in worktime.values()]
|
||||
total_time = timedelta(hours=0)
|
||||
for i in mas_worktime:
|
||||
|
||||
@ -1,25 +1,20 @@
|
||||
import json
|
||||
import os
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
|
||||
import psycopg2
|
||||
from apps.main.models.scales_control import Position, ShiftReport
|
||||
import requests
|
||||
from apps.main.models.worktime import FabricWorkTime
|
||||
from apps.main.services.base_service import DashboardBaseService
|
||||
from apps.main.services.scales_control.redis_repository import RedisRepository
|
||||
from apps.util.redis_api import RedisService
|
||||
from apps.util.redis_cache import RedisCache
|
||||
from celery import shared_task
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.conf import settings
|
||||
from psycopg2 import OperationalError
|
||||
from sabron.util import logging
|
||||
from sabron.util.sabronmodule import get_settings
|
||||
|
||||
try:
|
||||
from repcofkk.local_settings import REDIS_HOST, REDIS_PORT
|
||||
except ModuleNotFoundError:
|
||||
from repcofkk.production_settings import REDIS_HOST, REDIS_PORT
|
||||
REDIS_HOST = settings.REDIS_HOST
|
||||
REDIS_PORT = settings.REDIS_PORT
|
||||
|
||||
|
||||
class RedisScales:
|
||||
@ -32,7 +27,7 @@ class RedisScales:
|
||||
date = datetime.strptime(date_str, '%Y-%m-%d %H:%M:%S.%f')
|
||||
except ValueError:
|
||||
date = datetime.strptime(date_str, '%Y-%m-%d %H:%M:%S')
|
||||
|
||||
date = date.replace(tzinfo=settings.TIME_ZONE_OBJECT)
|
||||
return {'value': value, 'date': date}
|
||||
|
||||
|
||||
@ -41,14 +36,15 @@ class PostgresScales:
|
||||
def fetch_scales_data_by_range(start: datetime, end: datetime) -> list:
|
||||
control_conveyor = get_settings('control_conveyor')
|
||||
with psycopg2.connect(
|
||||
dbname='vesi_db',
|
||||
user='ktp_user',
|
||||
password='rb,thrjl',
|
||||
host='192.168.10.2',
|
||||
port='5432',
|
||||
dbname=get_settings('scales_db'),
|
||||
user=get_settings('scales_db_user'),
|
||||
password=get_settings('scales_db_password'),
|
||||
host=get_settings('scales_db_host'),
|
||||
port=get_settings('scales_db_port'),
|
||||
) as conn_postgres:
|
||||
with conn_postgres.cursor() as cursor:
|
||||
cursor.execute("""
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT DISTINCT ON (date_trunc('minute', "Date"))
|
||||
"Name",
|
||||
"Values",
|
||||
@ -59,18 +55,20 @@ class PostgresScales:
|
||||
"Name" = %s AND
|
||||
"Date" BETWEEN %s AND %s
|
||||
LIMIT 10000;
|
||||
""", (control_conveyor, start, end))
|
||||
""",
|
||||
(control_conveyor, start, end),
|
||||
)
|
||||
return cursor.fetchall()
|
||||
|
||||
@staticmethod
|
||||
def get_scales_data(limit: int = 20000) -> list:
|
||||
try:
|
||||
with psycopg2.connect(
|
||||
dbname='vesi_db',
|
||||
user='ktp_user',
|
||||
password='rb,thrjl',
|
||||
host='192.168.10.2',
|
||||
port='5432',
|
||||
dbname=get_settings('scales_db'),
|
||||
user=get_settings('scales_db_user'),
|
||||
password=get_settings('scales_db_password'),
|
||||
host=get_settings('scales_db_host'),
|
||||
port=get_settings('scales_db_port'),
|
||||
) as conn_postgres:
|
||||
with conn_postgres.cursor() as cursor:
|
||||
cursor.execute(
|
||||
@ -94,11 +92,11 @@ class PostgresScales:
|
||||
return 'No scales data'
|
||||
try:
|
||||
with psycopg2.connect(
|
||||
dbname=os.environ.get('POSTGRES_DB', 'repcofkk_db'),
|
||||
user=os.environ.get('POSTGRES_USER', 'repcofkk_user'),
|
||||
password=os.environ.get('POSTGRES_PASSWORD', 'Angstrem*45'),
|
||||
host=os.environ.get('POSTGRES_HOST', '127.0.0.1'),
|
||||
port='5432',
|
||||
dbname=os.environ.get('POSTGRES_DB', 'repcofkk_db'),
|
||||
user=os.environ.get('POSTGRES_USER', 'repcofkk_user'),
|
||||
password=os.environ.get('POSTGRES_PASSWORD', 'Angstrem*45'),
|
||||
host=os.environ.get('POSTGRES_HOST', '127.0.0.1'),
|
||||
port='5432',
|
||||
) as postgres_conn:
|
||||
with postgres_conn.cursor() as cursor:
|
||||
for row in data:
|
||||
@ -127,7 +125,19 @@ class PostgresScales:
|
||||
END IF;
|
||||
END $$;
|
||||
""",
|
||||
(name, name, name, value, date, name, value, name, value, date, check,),
|
||||
(
|
||||
name,
|
||||
name,
|
||||
name,
|
||||
value,
|
||||
date,
|
||||
name,
|
||||
value,
|
||||
name,
|
||||
value,
|
||||
date,
|
||||
check,
|
||||
),
|
||||
)
|
||||
postgres_conn.commit()
|
||||
return 'Success'
|
||||
@ -143,41 +153,62 @@ def create_worktime_data_from_scales_db(start, stop):
|
||||
pass
|
||||
|
||||
|
||||
def is_conveyor_working() -> bool | int:
|
||||
api_host = get_settings('api_host')
|
||||
conveyor_bool = get_settings('conveyor_bool')
|
||||
if not conveyor_bool:
|
||||
return -1
|
||||
response = requests.get(
|
||||
f'{api_host}/api/v2/scada/sensor/tag/{conveyor_bool}', timeout=3
|
||||
)
|
||||
return bool(response.json()['responce']['value'])
|
||||
|
||||
|
||||
@shared_task
|
||||
def create_worktime_data():
|
||||
"""
|
||||
Description:
|
||||
Создает объекты времени работы фабрики. Получает данные с Redis по весам конвейера. Если разница текущего времени записи с
|
||||
Redis больше чем 5 минут с текущим временем - фабрика не работает Запись будет создаваться только в случае если
|
||||
статус изменился.
|
||||
Вызывается каждые 30 секунд
|
||||
Создает объекты времени работы фабрики
|
||||
Returns: строку со статусом задачи
|
||||
"""
|
||||
|
||||
now_date = DashboardBaseService.get_current_time()
|
||||
fabric_unloaded_val = int(get_settings('fabric_unloaded_val', '5'))
|
||||
|
||||
obj_from_redis = RedisScales.get_scales_data_from_redis(get_settings('control_conveyor'))
|
||||
obj_from_redis = RedisScales.get_scales_data_from_redis(
|
||||
get_settings('control_conveyor')
|
||||
)
|
||||
conveyor_state = is_conveyor_working()
|
||||
|
||||
delta_now_and_redis = (now_date - obj_from_redis['date']).total_seconds() / 60
|
||||
if conveyor_state == -1:
|
||||
return 'conveyor_bool is not set'
|
||||
|
||||
try:
|
||||
latest_worktime_obj = FabricWorkTime.objects.latest('time')
|
||||
except FabricWorkTime.DoesNotExist:
|
||||
obj = FabricWorkTime.objects.create(status='WO' if delta_now_and_redis < 5 else 'NW',
|
||||
time=obj_from_redis['date'])
|
||||
status = (
|
||||
'NW'
|
||||
if conveyor_state is False
|
||||
else ('WO' if obj_from_redis['value'] > fabric_unloaded_val else 'WA')
|
||||
)
|
||||
obj = FabricWorkTime.objects.create(status=status, time=obj_from_redis['date'])
|
||||
return 'Success. Created first obj: ' + str(obj)
|
||||
|
||||
status = None
|
||||
|
||||
if latest_worktime_obj.status == 'NW' and delta_now_and_redis < 5:
|
||||
status = 'WO'
|
||||
|
||||
elif latest_worktime_obj.status == 'WO' and delta_now_and_redis > 5:
|
||||
status = 'NW'
|
||||
if conveyor_state:
|
||||
if float(obj_from_redis['value']) > fabric_unloaded_val:
|
||||
if latest_worktime_obj.status != 'WO':
|
||||
status = 'WO'
|
||||
else:
|
||||
if latest_worktime_obj.status != 'WA':
|
||||
status = 'WA'
|
||||
else:
|
||||
if latest_worktime_obj.status != 'NW':
|
||||
status = 'NW'
|
||||
|
||||
if status:
|
||||
obj = FabricWorkTime.objects.create(status=status, time=obj_from_redis['date'])
|
||||
return f'Success. Created obj: {str(obj)} (latest {str(latest_worktime_obj)}'
|
||||
return f'Success. Created obj: {str(obj)} (latest {str(latest_worktime_obj)})'
|
||||
|
||||
return 'Success. ' + str(latest_worktime_obj)
|
||||
|
||||
@ -211,28 +242,3 @@ def write_scale_control_data_to_redis():
|
||||
except Exception as e:
|
||||
logging.error('CELERY' + traceback.format_exc())
|
||||
return str(e)
|
||||
|
||||
|
||||
@shared_task
|
||||
def create_shift_report():
|
||||
control_conveyor_month = get_settings('conveyor_month')
|
||||
fabric_goal = get_settings('fabric_goal')
|
||||
service = RedisRepository(control_conveyor_month, fabric_goal)
|
||||
positions = Position.objects.order_by('id')
|
||||
average = service.get_scales_value_by_shifts(positions, 'Aver')
|
||||
daily = service.get_scales_value_by_shifts(positions, 'Smena')
|
||||
concentrate = service.get_concentrate_value()
|
||||
if not concentrate:
|
||||
concentrate = {'concentrate': 0,
|
||||
'dropout': 0}
|
||||
scales_data = json.dumps({'daily': daily, 'average': average},
|
||||
sort_keys=True,
|
||||
indent=1,
|
||||
cls=DjangoJSONEncoder
|
||||
)
|
||||
obj = ShiftReport.objects.create(time=DashboardBaseService.get_current_time(),
|
||||
concentrate=concentrate['concentrate'],
|
||||
dropout=concentrate['dropout'],
|
||||
scales_data=scales_data)
|
||||
service.delete_kek_and_breed_values()
|
||||
return str(obj)
|
||||
|
||||
@ -13,6 +13,9 @@
|
||||
<div class="">
|
||||
<a href="/main/scada/" target="_blank" class="btn btn-primary btn-lg">SCADA</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/main/scada/flotation/" target="_blank" class="btn btn-primary btn-lg">Флотация</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/montorem/" target="_blank" class="btn btn-primary btn-lg">Montorem</a>
|
||||
</div>
|
||||
@ -32,6 +35,8 @@
|
||||
{# {% include 'emergency_stops_widget.html' %}#}
|
||||
<!--Виджет плотность в тяжелой среде -->
|
||||
{% include 'widgets/density/widget.html' %}
|
||||
|
||||
{% include 'widgets/meteo/widget.html' %}
|
||||
</div>
|
||||
|
||||
<!--end:: Widgets/Support Stats-->
|
||||
@ -47,4 +52,6 @@
|
||||
<script src="{% static 'js/charts/workStatus.js' %}?ver={% settings_value 'APP_VERSION' %}"></script>
|
||||
<script src="{% static 'js/charts/scaleControl.js' %}?ver={% settings_value 'APP_VERSION' %}"></script>
|
||||
<script src="{% static 'js/charts/densityInHeavy.js' %}?ver={% settings_value 'APP_VERSION' %}"></script>
|
||||
<script src="{% static 'js/charts/meteo.js' %}?ver={% settings_value 'APP_VERSION' %}"></script>
|
||||
|
||||
{% endblock script_footer %}
|
||||
|
||||
63
app/apps/main/templates/scada_flotation.html
Normal file
63
app/apps/main/templates/scada_flotation.html
Normal file
@ -0,0 +1,63 @@
|
||||
<html>
|
||||
{% load static %}
|
||||
{% load mysettings %}
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body style="margin:0;">
|
||||
<!--<img src="http://192.168.10.251:8000/screen?rand=0.5233895099246539" alt="" id="image" width="100%" height="95%">-->
|
||||
<img id="skadaimg" alt="" id="image" width="100%" >
|
||||
<div at-magnifier-wrapper="">
|
||||
<div class="at-theme-light">
|
||||
<div class="at-base notranslate" translate="no">
|
||||
<div class="EuwGd" style="top: 0px; left: 0px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./wrapper -->
|
||||
<!-- REQUIRED SCRIPTS -->
|
||||
<!-- jQuery -->
|
||||
<script src="{% static 'lte/plugins/jquery/jquery.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<!-- Bootstrap 4 -->
|
||||
<script src="{% static 'lte/plugins/bootstrap/js/bootstrap.bundle.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<!-- SweetAlert2 -->
|
||||
<script src="{% static 'lte/plugins/sweetalert2/sweetalert2.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<!-- Toastr -->
|
||||
<script src="{% static 'lte/plugins/toastr/toastr.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<!-- AdminLTE App -->
|
||||
<script src="{% static 'lte/dist/js/adminlte.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<script src="{% static 'js/main.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<script>
|
||||
|
||||
function show()
|
||||
{
|
||||
cmd = 'refresh';
|
||||
$.ajax({
|
||||
type: 'POST', // метод отправки
|
||||
async:true,
|
||||
url: window.location.pathname+'ajax/', // путь к обработчику
|
||||
data: {
|
||||
"cmd": cmd,
|
||||
},
|
||||
success: function (data) {
|
||||
$('#skadaimg').attr('src',data.img)
|
||||
},
|
||||
error: function (dataerr) {
|
||||
console.log('Ошибка выполнение команды :'+dataerr)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
show()
|
||||
setInterval('show()', 1000);
|
||||
|
||||
setInterval(function () {
|
||||
var image = document.getElementById('image');
|
||||
image.src = 'http://192.168.10.247:8000/?rand=' + Math.random();
|
||||
}, 10000);
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,4 +1,4 @@
|
||||
<div class="col-md-12 col-lg-8">
|
||||
<div class="col-md-12 col-lg-6">
|
||||
<div class="m-portlet m-portlet--full-height">
|
||||
<div class="m-portlet__head justify-content-center">
|
||||
<div class="m-portlet__head-caption">
|
||||
|
||||
99
app/apps/main/templates/widgets/meteo/widget.html
Normal file
99
app/apps/main/templates/widgets/meteo/widget.html
Normal file
@ -0,0 +1,99 @@
|
||||
<div class="col-md-12 col-lg-6">
|
||||
<div class="m-portlet m-portlet--tabs m-portlet--full-height">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
<a href="https://mycityair.ru/networks/posts" target="_blank">Данные с метеостанции</a>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__head-tools">
|
||||
<ul class="nav nav-tabs m-tabs m-tabs-line m-tabs-line--right m-tabs-line-danger" role="tablist">
|
||||
<li class="nav-item m-tabs__item">
|
||||
<a class="nav-link m-tabs__link active show" data-toggle="tab" href="#m_portlet_tab_1_1"
|
||||
role="tab" aria-selected="true">
|
||||
Качество воздуха
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item m-tabs__item">
|
||||
<a class="nav-link m-tabs__link" data-toggle="tab" href="#m_portlet_tab_1_2" role="tab"
|
||||
aria-selected="false">
|
||||
Погодные условия
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body p-3" style="min-height: 115px;">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active show" id="m_portlet_tab_1_1">
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr">
|
||||
<div>PM2.5</div>
|
||||
<div><b><span class="meteo_pm2"></span> мгк/м<sup>3</sup></b></div>
|
||||
|
||||
<div>PM10</div>
|
||||
<div><b><span class="meteo_pm10"></span> мгк/м<sup>3</sup></b></div>
|
||||
|
||||
<div>CO</div>
|
||||
|
||||
<div><b><span class="meteo_co"></span> мгк/м<sup>3</sup></b></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr">
|
||||
|
||||
<div>NO<sub>2</sub></div>
|
||||
|
||||
<div><b><span class="meteo_no2"></span> мгк/м<sup>3</sup></b></div>
|
||||
|
||||
<div>SO<sub>2</sub></div>
|
||||
|
||||
<div><b><span class="meteo_so2"></span> мгк/м<sup>3</sup></b></div>
|
||||
|
||||
<div>O<sub>3</sub></div>
|
||||
<div><b><span class="meteo_o3"></span> мгк/м<sup>3</sup></b></div>
|
||||
|
||||
<div>H<sub>2</sub>S</div>
|
||||
|
||||
<div><b><span class="meteo_h2s"></span> мгк/м<sup>3</sup></b></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="m_portlet_tab_1_2">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr">
|
||||
<div>Температура</div>
|
||||
<div><b><span class="meteo_temperature"></span>°C</b></div>
|
||||
|
||||
<div>Давление</div>
|
||||
<div><b><span class="meteo_pressure"></span> мм.рт.ст.</b></div>
|
||||
|
||||
<div>Влажность</div>
|
||||
<div><b><span class="meteo_humidity"></span>%</b></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr">
|
||||
|
||||
<div>Направление ветра</div>
|
||||
<div><b><span class="meteo_wda"></span></b>
|
||||
<i class="fa fa-arrow-up wda-dir" style="color: var(--primary);"></i>
|
||||
</div>
|
||||
|
||||
<div>Скорость ветра</div>
|
||||
<div><b><span class="meteo_wva"></span> м/c</b></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1,168 +1,174 @@
|
||||
<div class="col-xl-4">
|
||||
<div class="m-portlet m-portlet--full-height">
|
||||
<div class="m-portlet__head justify-content-center">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
{% include 'widgets/worktime/workstatus.html' %}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body pt-1">
|
||||
<div class="m-widget16 h-100 grid-gar-1fr divider-horizontal">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-md-6">
|
||||
<h5 class="roboto text-center">За смену</h5>
|
||||
<div class="m-widget16__body">
|
||||
<div class="worktime-between">
|
||||
<div class="m-portlet m-portlet--full-height">
|
||||
<div class="m-portlet__head justify-content-center">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
{% include 'widgets/worktime/workstatus.html' %}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body pt-1">
|
||||
<div class="m-widget16 h-100 grid-gar-1fr divider-horizontal">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-md-6">
|
||||
<h5 class="roboto text-center">За смену
|
||||
<sup><a href="{% url 'worktime_history' %}?scale=shift"><i class="fa fa-info-circle" style="color: var(--primary); cursor: pointer"></i></a></sup>
|
||||
</h5>
|
||||
<div class="m-widget16__body">
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto dark">
|
||||
Под нагрузкой
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-success roboto font-weight-bold"
|
||||
id="dailyWO">0 ч.</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class="m-widget16__price m--align-right m--font-success roboto font-weight-bold"
|
||||
id="dailyWO">0 ч.</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Без нагрузки
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-primary roboto font-weight-bold"
|
||||
id="dailyWA">
|
||||
<span class="m-widget16__price m--align-right m--font-primary roboto font-weight-bold"
|
||||
id="dailyWA">
|
||||
0 ч.
|
||||
</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Не работала
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-danger roboto font-weight-bold"
|
||||
id="dailyNW">
|
||||
<span class="m-widget16__price m--align-right m--font-danger roboto font-weight-bold"
|
||||
id="dailyNW">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Общее время работы
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-accent roboto font-weight-bold"
|
||||
id="dailySUM">
|
||||
<span class="m-widget16__price m--align-right m--font-accent roboto font-weight-bold"
|
||||
id="dailySUM">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="m-widget16__stats">
|
||||
<div class="m-widget16__visual">
|
||||
<div id="dailyWorkTimeChart" style="height: 180px">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="m-widget16__stats">
|
||||
<div class="m-widget16__visual">
|
||||
<div id="dailyWorkTimeChart" style="height: 180px">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center">
|
||||
<div class="col-md-6">
|
||||
<h5 class="roboto text-center">За неделю</h5>
|
||||
<div class="m-widget16__body">
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center">
|
||||
<div class="col-md-6">
|
||||
<h5 class="roboto text-center">За неделю
|
||||
<sup><a href="{% url 'worktime_history' %}?scale=week"><i class="fa fa-info-circle" style="color: var(--primary); cursor: pointer"></i></a></sup>
|
||||
</h5>
|
||||
<div class="m-widget16__body">
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Под нагрузкой
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-success roboto font-weight-bold"
|
||||
id="weeklyWO">
|
||||
<span class="m-widget16__price m--align-right m--font-success roboto font-weight-bold"
|
||||
id="weeklyWO">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Без нагрузки
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-primary roboto font-weight-bold"
|
||||
id="weeklyWA">
|
||||
<span class="m-widget16__price m--align-right m--font-primary roboto font-weight-bold"
|
||||
id="weeklyWA">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Не работала
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-danger roboto font-weight-bold"
|
||||
id="weeklyNW">
|
||||
<span class="m-widget16__price m--align-right m--font-danger roboto font-weight-bold"
|
||||
id="weeklyNW">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Общее время работы
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-accent roboto font-weight-bold"
|
||||
id="weeklySUM">
|
||||
<span class="m-widget16__price m--align-right m--font-accent roboto font-weight-bold"
|
||||
id="weeklySUM">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="m-widget16__stats">
|
||||
<div class="m-widget16__visual">
|
||||
<div id="weeklyWorkTimeChart" style="height: 180px">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="m-widget16__stats">
|
||||
<div class="m-widget16__visual">
|
||||
<div id="weeklyWorkTimeChart" style="height: 180px">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center">
|
||||
<div class="col-md-6">
|
||||
<h5 class="roboto text-center">За месяц</h5>
|
||||
<div class="m-widget16__body">
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center">
|
||||
<div class="col-md-6">
|
||||
<h5 class="roboto text-center">За месяц
|
||||
<sup><a href="{% url 'worktime_history' %}?scale=month"><i class="fa fa-info-circle" style="color: var(--primary); cursor: pointer"></i></a></sup>
|
||||
</h5>
|
||||
<div class="m-widget16__body">
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Под нагрузкой
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-success roboto font-weight-bold"
|
||||
id="monthlyWO">
|
||||
<span class="m-widget16__price m--align-right m--font-success roboto font-weight-bold"
|
||||
id="monthlyWO">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Без нагрузки
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-primary roboto font-weight-bold"
|
||||
id="monthlyWA">
|
||||
<span class="m-widget16__price m--align-right m--font-primary roboto font-weight-bold"
|
||||
id="monthlyWA">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Не работала
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-danger roboto font-weight-bold"
|
||||
id="monthlyNW">
|
||||
<span class="m-widget16__price m--align-right m--font-danger roboto font-weight-bold"
|
||||
id="monthlyNW">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
</div>
|
||||
<div class="worktime-between">
|
||||
<span class=" roboto">
|
||||
Общее время работы
|
||||
</span>
|
||||
<span class="m-widget16__price m--align-right m--font-accent roboto font-weight-bold"
|
||||
id="monthlySUM">
|
||||
<span class="m-widget16__price m--align-right m--font-accent roboto font-weight-bold"
|
||||
id="monthlySUM">
|
||||
0ч.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="m-widget16__stats">
|
||||
<div class="m-widget16__visual">
|
||||
<div id="monthlyWorkTimeChart" style="height: 180px">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="m-widget16__stats">
|
||||
<div class="m-widget16__visual">
|
||||
<div id="monthlyWorkTimeChart" style="height: 180px">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
53
app/apps/main/templates/worktime_history.html
Normal file
53
app/apps/main/templates/worktime_history.html
Normal file
@ -0,0 +1,53 @@
|
||||
{% extends 'default.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="m-content">
|
||||
<div class="row">
|
||||
<div class="col-xl-6 col-lg-12">
|
||||
|
||||
<!--Begin::Portlet-->
|
||||
<div class="m-portlet m-portlet--full-height ">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
Отрезки времени работы фабрики
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body">
|
||||
<div class="m-scrollable m-scroller ps ps--active-y" data-scrollable="true"
|
||||
style="max-height: 70vh; overflow: hidden;">
|
||||
{% for object in objects_list %}
|
||||
<div class="m-list-badge m-list-badge--light-bg m--margin">
|
||||
{% if object.status == 'WO' %}
|
||||
<div class="m-list-badge__label m--font-success">{{ object.time|date:"d.m.Y H:i" }}</div>
|
||||
{% elif object.status == 'WA' %}
|
||||
<div class="m-list-badge__label m--font-warning">{{ object.time|date:"d.m.Y H:i" }}</div>
|
||||
{% elif object.status == 'NW' %}
|
||||
<div class="m-list-badge__label m--font-danger">{{ object.time|date:"d.m.Y H:i" }}</div>
|
||||
{% endif %}
|
||||
<div class="m-list-badge__items">
|
||||
{% if object.status == 'WO' %}
|
||||
<span class="m-list-badge__item m-list-badge__item--success">Работает</span>
|
||||
{% elif object.status == 'WA' %}
|
||||
<span class="m-list-badge__item m-list-badge__item--warning">Работает без нагрузки</span>
|
||||
{% elif object.status == 'NW' %}
|
||||
<span class="m-list-badge__item m-list-badge__item--danger">Не работает</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--End::Portlet-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -1,14 +1,23 @@
|
||||
from apps.main import views_main
|
||||
from apps.main.views_main import administration, aspiration, scales
|
||||
from apps.main.services.meteo.views import get_meteo_data
|
||||
from apps.main.views_main import aspiration, scales, worktime_history
|
||||
from django.urls import include, path
|
||||
|
||||
urlpatterns = [
|
||||
path('', views_main.mainindex, name='mainindex'),
|
||||
# Уголь
|
||||
path('', views_main.mainindex, name='main_index'),
|
||||
path('scada/flotation/', views_main.scada_flotation),
|
||||
path('scada/charger/', views_main.scada_charger),
|
||||
path('scada/flotation/ajax/', views_main.scada_flotation_get_ajax),
|
||||
path('scada/', views_main.scada_index, name='scada_index'),
|
||||
path('scada/ajax/', views_main.get_ajax, name='get_ajax'),
|
||||
# path('scada/charger/', views_main.scada_charger, name='scada_charger'),
|
||||
path('', include('apps.main.services.urls')),
|
||||
path('scale/', scales, name='concentrate_and_dropout'),
|
||||
path('aspiration/', aspiration, name='aspiration'),
|
||||
|
||||
path('administration/', administration, name='administration'),
|
||||
path('worktime/history/', worktime_history, name='worktime_history'),
|
||||
path('meteo/', get_meteo_data, name='get_meteo_data'),
|
||||
# re_path(r"^proxy/(?P<path>.*)$", proxy_view),
|
||||
]
|
||||
|
||||
# create_worktime_data()
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
import base64
|
||||
import traceback
|
||||
from datetime import timedelta
|
||||
|
||||
import requests
|
||||
from apps.main.models.worktime import FabricWorkTime
|
||||
from apps.main.services.base_service import DashboardBaseService
|
||||
from apps.util import generalmodule
|
||||
from apps.util.base_view import group_required
|
||||
from apps.util.generalmodule import get_context_template
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import redirect, render
|
||||
from django.views.decorators.cache import never_cache
|
||||
@ -10,13 +15,13 @@ from sabron.util import logging
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@group_required('Уголь')
|
||||
@never_cache
|
||||
def mainindex(request):
|
||||
try:
|
||||
if request.method == 'GET':
|
||||
context = {
|
||||
'updatepage': True,
|
||||
}
|
||||
context = get_context_template(request)
|
||||
|
||||
return render(request, 'main_index.html', context)
|
||||
except Exception:
|
||||
logging.error(traceback.format_exc())
|
||||
@ -37,6 +42,7 @@ def get_ajax(request):
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@group_required('Уголь')
|
||||
@never_cache
|
||||
def scada_index(request):
|
||||
try:
|
||||
@ -50,20 +56,85 @@ def scada_index(request):
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@group_required('Уголь')
|
||||
@never_cache
|
||||
def scada_flotation(request):
|
||||
try:
|
||||
if request.method == 'GET':
|
||||
context = {
|
||||
'updatepage': True,
|
||||
}
|
||||
return render(request, 'scada_flotation.html', context)
|
||||
except Exception:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@never_cache
|
||||
def scada_flotation_get_ajax(request):
|
||||
try:
|
||||
dataimage = base64.b64encode(
|
||||
requests.get('http://192.168.10.247:8000/screen').content
|
||||
)
|
||||
data = dict()
|
||||
data.update(img='data:image/png;base64,' + dataimage.decode('utf-8'))
|
||||
return generalmodule.ReturnJson(200, data)
|
||||
except Exception:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@group_required('Уголь')
|
||||
@never_cache
|
||||
def scales(request):
|
||||
return render(request, 'concentrate_and_dropout.html')
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@group_required('Уголь')
|
||||
@never_cache
|
||||
def aspiration(request):
|
||||
return render(request, 'aspiration.html')
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@group_required('Уголь')
|
||||
@never_cache
|
||||
def administration(request):
|
||||
if not request.user.is_superuser or not request.user.is_staff:
|
||||
return redirect('mainindex')
|
||||
return render(request, 'administration.html')
|
||||
def worktime_history(request):
|
||||
scale = request.GET.get('scale')
|
||||
current_time = DashboardBaseService.get_current_time()
|
||||
if not scale:
|
||||
return redirect('/main/')
|
||||
match scale:
|
||||
case 'shift':
|
||||
start_shift = DashboardBaseService.get_shift_start(current_time)
|
||||
objects_list = FabricWorkTime.objects.filter(time__gt=start_shift).order_by(
|
||||
'-time'
|
||||
)
|
||||
case 'week':
|
||||
start_week = (
|
||||
current_time - timedelta(days=current_time.weekday())
|
||||
).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
objects_list = FabricWorkTime.objects.filter(time__gt=start_week).order_by(
|
||||
'-time'
|
||||
)
|
||||
case 'month':
|
||||
start_month = current_time.replace(
|
||||
day=1, hour=0, minute=0, second=0, microsecond=0
|
||||
)
|
||||
objects_list = FabricWorkTime.objects.filter(time__gt=start_month).order_by(
|
||||
'-time'
|
||||
)
|
||||
case _:
|
||||
return redirect('/main/')
|
||||
return render(request, 'worktime_history.html', {'objects_list': objects_list})
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@group_required('Уголь')
|
||||
@never_cache
|
||||
def scada_charger(request):
|
||||
try:
|
||||
return redirect('/app/')
|
||||
except Exception:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
0
app/apps/management/__init__.py
Normal file
0
app/apps/management/__init__.py
Normal file
6
app/apps/management/apps.py
Normal file
6
app/apps/management/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ManagementConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'apps.management'
|
||||
69
app/apps/management/forms.py
Normal file
69
app/apps/management/forms.py
Normal file
@ -0,0 +1,69 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.models import Group, User
|
||||
|
||||
|
||||
class UserForm(forms.ModelForm):
|
||||
username = forms.CharField(
|
||||
label='Имя пользователя',
|
||||
widget=forms.TextInput(attrs={'class': 'form-control m-input'}),
|
||||
)
|
||||
password1 = forms.CharField(
|
||||
label='Пароль',
|
||||
widget=forms.PasswordInput(attrs={'class': 'form-control m-input'}),
|
||||
required=False,
|
||||
)
|
||||
password2 = forms.CharField(
|
||||
label='Подтверждение пароля',
|
||||
widget=forms.PasswordInput(attrs={'class': 'form-control m-input'}),
|
||||
required=False,
|
||||
)
|
||||
groups = forms.ModelMultipleChoiceField(
|
||||
queryset=Group.objects.all(),
|
||||
widget=forms.CheckboxSelectMultiple(),
|
||||
required=False,
|
||||
label='Права доступа',
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('username', 'groups')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.is_edit = kwargs.pop('is_edit', False)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
if self.is_edit:
|
||||
self.fields['password1'].help_text = (
|
||||
'Оставьте пустым, чтобы не менять пароль.'
|
||||
)
|
||||
self.fields['password2'].help_text = (
|
||||
'Оставьте пустым, чтобы не менять пароль.'
|
||||
)
|
||||
else:
|
||||
self.fields['password1'].required = False
|
||||
self.fields['password2'].required = False
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
password1 = cleaned_data.get('password1')
|
||||
password2 = cleaned_data.get('password2')
|
||||
|
||||
if password1 or password2:
|
||||
if password1 != password2:
|
||||
raise forms.ValidationError('Пароли не совпадают.')
|
||||
|
||||
return cleaned_data
|
||||
|
||||
def save(self, commit=True):
|
||||
user = super().save(commit=False)
|
||||
password = self.cleaned_data.get('password1')
|
||||
|
||||
if password:
|
||||
user.set_password(password)
|
||||
|
||||
if commit:
|
||||
user.save()
|
||||
user.groups.set(self.cleaned_data['groups'])
|
||||
user.save()
|
||||
|
||||
return user
|
||||
0
app/apps/management/migrations/__init__.py
Normal file
0
app/apps/management/migrations/__init__.py
Normal file
@ -2,74 +2,90 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="row m-2">
|
||||
<div class="col-lg-4 col-sm-12">
|
||||
<div class="col-lg-8 col-sm-12">
|
||||
<div class="m-portlet m-portlet--mobile m-portlet--body-progress-">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
Основное
|
||||
Пользователи
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="/admin" class="btn btn-primary roboto">Панель администрирования</a>
|
||||
<div class="m-portlet__head-tools">
|
||||
<ul class="m-portlet__nav">
|
||||
<li class="m-portlet__nav-item">
|
||||
<a href="{% url 'management:create_user' %}" class="btn btn-primary m-btn m-btn--icon">
|
||||
<span>
|
||||
<i class="fa fa-plus"></i>
|
||||
<span>Добавить пользователя</span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-sm-12">
|
||||
<div class="m-portlet m-portlet--mobile m-portlet--body-progress-">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
Время работы фабрики
|
||||
</h3>
|
||||
<div class="m-portlet__body p-4" style="max-height: 75vh; overflow-y: scroll">
|
||||
<div class="tab-content">
|
||||
<!--begin::Widget 14-->
|
||||
<div class="m-widget4">
|
||||
{% for user in users %}
|
||||
<!--begin::Widget 14 Item-->
|
||||
<div class="d-flex justify-content-between mb-3 pb-2 border-bottom">
|
||||
<div class="m-widget4__info d-flex flex-column">
|
||||
<span class="m-widget4__title" style="font-size: 1.2rem">
|
||||
<a href="{% url 'management:update_user' user.id %}"
|
||||
style="text-decoration: underline">
|
||||
<b>{{ user.username }}</b>
|
||||
</a>
|
||||
</span>
|
||||
<span class="m-widget4__sub" style="font-size: 1rem">
|
||||
<b>Права доступа:</b>
|
||||
{% for group in user.groups.all %}
|
||||
<u>{{ group }}</u>
|
||||
{% empty %}
|
||||
-
|
||||
{% endfor %}
|
||||
</span>
|
||||
</div>
|
||||
<div class="d-flex" style="gap: .5em">
|
||||
<a href="{% url 'management:delete_user' user.id %}" class="m-btn btn btn-danger">Удалить</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<!--end::Widget 14 Item-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="{% url "create_worktime" %}" class="btn btn-outline-primary roboto">Загрузить время
|
||||
работы
|
||||
фабрики</a>
|
||||
<a href="#" class="btn btn-danger roboto">Очистить время работы</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4 col-sm-12">
|
||||
<div class="m-portlet m-portlet--mobile m-portlet--body-progress-">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
Весы
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body">
|
||||
<div class="d-flex flex-column ">
|
||||
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary roboto mb-4" data-toggle="modal"
|
||||
data-target="#fabricGoalModal" id="launchModalBtn">Изменить значение цели по
|
||||
переработке
|
||||
</button>
|
||||
</div>
|
||||
<div><a href="#" class="btn btn-outline-danger roboto mb-2">Очистить значение кека и породы</a>
|
||||
</div>
|
||||
<div><a href="#" class="btn btn-danger roboto mb-2">Очистить данные весов</a></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if request.user.is_superuser %}
|
||||
<div class="col-lg-4 col-sm-12">
|
||||
<div class="m-portlet m-portlet--mobile m-portlet--body-progress-">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<h3 class="m-portlet__head-text">
|
||||
Весы
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__body p-4">
|
||||
<div class="d-flex flex-column ">
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary roboto mb-4" data-toggle="modal"
|
||||
data-target="#fabricGoalModal" id="launchModalBtn">
|
||||
Изменить значение цели по переработке
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="fabricGoalModal" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
|
||||
28
app/apps/management/templates/management/confirm_delete.html
Normal file
28
app/apps/management/templates/management/confirm_delete.html
Normal file
@ -0,0 +1,28 @@
|
||||
{% extends 'default.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="modal fade show" id="m_modal_1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
style="display: block;">
|
||||
<div class="modal-dialog" role="document">
|
||||
<form method="post" class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Удалить пользователя "{{ object.username }}"?</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
{% csrf_token %}
|
||||
Это действие невозможно отменить.
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="{% url 'management:administration' %}" class="btn btn-secondary">Отмена</a>
|
||||
<button type="submit" class="btn btn-primary">Да, удалить</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
60
app/apps/management/templates/management/form.html
Normal file
60
app/apps/management/templates/management/form.html
Normal file
@ -0,0 +1,60 @@
|
||||
{% extends 'default.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
<!--begin::Portlet-->
|
||||
<div class="m-portlet mt-3 ml-3">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<span class="m-portlet__head-icon m--hide">
|
||||
<i class="la la-gear"></i>
|
||||
</span>
|
||||
<h3 class="m-portlet__head-text">
|
||||
{% if object %}
|
||||
Редактирование
|
||||
{% else %}
|
||||
Создание
|
||||
{% endif %} пользователя
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--begin::Form-->
|
||||
<form class="m-form m-form--fit m-form--label-align-right" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="p-4">
|
||||
{{ form.as_p }}
|
||||
</div>
|
||||
{# <div class="m-portlet__body">#}
|
||||
{# <div class="form-group m-form__group">#}
|
||||
{# <label for="{{ form.username.id_for_label }}">Имя пользователя</label>#}
|
||||
{# {{ form.username }}#}
|
||||
{# <span class="m-form__help">По этому имени пользователь будет входить в систему.</span>#}
|
||||
{# </div>#}
|
||||
{# <div class="form-group m-form__group">#}
|
||||
{# <label for="{{ form.password.id_for_label }}">Пароль</label>#}
|
||||
{# {{ form.password }}#}
|
||||
{# </div>#}
|
||||
{# <div class="form-group m-form__group">#}
|
||||
{# <label for="{{ form.groups.id_for_label }}">Права доступа</label>#}
|
||||
{# {{ form.groups }}#}
|
||||
{# </div>#}
|
||||
{# </div>#}
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
<div class="m-form__actions p-4">
|
||||
<button type="submit" class="btn btn-primary">Сохранить</button>
|
||||
<a href="{% url 'management:administration' %}" class="btn btn-secondary">Отмена</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!--end::Form-->
|
||||
</div>
|
||||
<!--end::Portlet-->
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
16
app/apps/management/urls.py
Normal file
16
app/apps/management/urls.py
Normal file
@ -0,0 +1,16 @@
|
||||
from apps.management.views.view_management import (
|
||||
UserDeleteView,
|
||||
administration,
|
||||
create_user,
|
||||
update_user,
|
||||
)
|
||||
from django.urls import path
|
||||
|
||||
app_name = 'management'
|
||||
|
||||
urlpatterns = [
|
||||
path('', administration, name='administration'),
|
||||
path('users/create/', create_user, name='create_user'),
|
||||
path('users/<int:pk>/edit/', update_user, name='update_user'),
|
||||
path('users/<int:pk>/delete/', UserDeleteView.as_view(), name='delete_user'),
|
||||
]
|
||||
74
app/apps/management/views/view_management.py
Normal file
74
app/apps/management/views/view_management.py
Normal file
@ -0,0 +1,74 @@
|
||||
import traceback
|
||||
|
||||
from apps.management.forms import UserForm
|
||||
from apps.util.generalmodule import get_context_template
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.views.generic import DeleteView
|
||||
from sabron.util import logging
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@never_cache
|
||||
def administration(request: HttpRequest) -> HttpResponse:
|
||||
if not (request.user.profile.role in (1, 2)):
|
||||
return redirect('mainindex')
|
||||
users = User.objects.all().exclude(is_superuser=True).order_by('username')
|
||||
context = get_context_template(request)
|
||||
context['users'] = users
|
||||
return render(request, 'management/administration.html', context)
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@never_cache
|
||||
def create_user(request: HttpRequest) -> HttpResponse:
|
||||
try:
|
||||
if not (request.user.profile.role in (1, 2)):
|
||||
return redirect('mainindex')
|
||||
if request.method == 'POST':
|
||||
form = UserForm(request.POST)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return redirect('management:administration')
|
||||
elif request.method == 'GET':
|
||||
context = get_context_template(request)
|
||||
form = UserForm()
|
||||
context['form'] = form
|
||||
return render(request, 'management/form.html', context)
|
||||
except Exception:
|
||||
print(traceback.format_exc())
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@never_cache
|
||||
def update_user(request, pk):
|
||||
try:
|
||||
if not (request.user.profile.role in (1, 2)):
|
||||
return redirect('mainindex')
|
||||
if request.method == 'POST':
|
||||
user = get_object_or_404(User, id=pk)
|
||||
form = UserForm(request.POST, instance=user, is_edit=True)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return redirect('management:administration')
|
||||
elif request.method == 'GET':
|
||||
user = get_object_or_404(User, id=pk)
|
||||
context = get_context_template(request)
|
||||
form = UserForm(instance=user)
|
||||
context['form'] = form
|
||||
context['object'] = user
|
||||
return render(request, 'management/form.html', context)
|
||||
except Exception:
|
||||
print(traceback.format_exc())
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
|
||||
class UserDeleteView(DeleteView):
|
||||
model = User
|
||||
template_name = 'management/confirm_delete.html'
|
||||
success_url = reverse_lazy('management:administration')
|
||||
@ -1,14 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.conf.urls import url
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.conf.urls import (
|
||||
include,
|
||||
) # Используйте include() чтобы добавлять URL из каталога приложения
|
||||
|
||||
from apps.montorem.views import views_main
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^$", views_main.mainindex, name="mainindex"),
|
||||
url(r"^sensor/$", views_main.sensor, name="sensor"),
|
||||
url(r"sensor/sensor_ajax/$", views_main.sensor_ajax, name="sensor_ajax"),
|
||||
path('', views_main.mainindex, name='mainindex'),
|
||||
path('sensor/', views_main.sensor, name='sensor'),
|
||||
path('sensor/sensor_ajax/', views_main.sensor_ajax, name='sensor_ajax'),
|
||||
]
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import functools
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.models import QuerySet
|
||||
from django.http import JsonResponse
|
||||
|
||||
from django.shortcuts import redirect
|
||||
from sabron.util import logging
|
||||
|
||||
|
||||
@ -16,8 +17,8 @@ def ret(json_object, status=200):
|
||||
|
||||
def error_response(exception):
|
||||
res = {
|
||||
"errorMessage": str(exception),
|
||||
"traceback": traceback.format_exc() if settings.DEBUG else "error occured",
|
||||
'errorMessage': str(exception),
|
||||
'traceback': traceback.format_exc() if settings.DEBUG else 'error occured',
|
||||
}
|
||||
logging.error(traceback.format_exc())
|
||||
return ret(res, status=400)
|
||||
@ -36,8 +37,21 @@ def base_view(fn):
|
||||
|
||||
def get_qs_by_range(model, start: datetime, end: datetime) -> QuerySet:
|
||||
return (
|
||||
model.objects.only("time")
|
||||
model.objects.only('time')
|
||||
.filter(time__range=(start, end))
|
||||
.order_by("time")
|
||||
.order_by('time')
|
||||
.values()
|
||||
)
|
||||
|
||||
|
||||
def group_required(*groups):
|
||||
|
||||
def decorator(function):
|
||||
def wrapper(request, *args, **kwargs):
|
||||
if request.user.groups.filter(name__in=groups).exists():
|
||||
return function(request, *args, **kwargs)
|
||||
return redirect('router')
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
||||
@ -1,32 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import json
|
||||
import re
|
||||
import traceback
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
from django.core.files import File
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.views.static import serve
|
||||
from django.urls import re_path
|
||||
from django.db.models import Avg, Max, Min
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.http import (
|
||||
Http404,
|
||||
HttpResponse,
|
||||
HttpResponsePermanentRedirect,
|
||||
HttpResponseRedirect,
|
||||
)
|
||||
from django.db import connection
|
||||
|
||||
from sabron.util import logging
|
||||
from django.urls import re_path
|
||||
from django.views.static import serve
|
||||
from sabron.models import Settings
|
||||
|
||||
|
||||
def get_context_template():
|
||||
def get_context_template(request):
|
||||
context = {}
|
||||
settings_list = Settings.objects.all()
|
||||
for setting in settings_list:
|
||||
context.update({setting.name: setting.value})
|
||||
|
||||
user_groups = [group.name for group in request.user.groups.all()]
|
||||
user_have_fin_group = 'Финансы' in user_groups
|
||||
user_have_coal_group = 'Уголь' in user_groups
|
||||
context['user_have_fin_group'] = user_have_fin_group
|
||||
context['user_have_coal_group'] = user_have_coal_group
|
||||
|
||||
return context
|
||||
|
||||
|
||||
@ -43,47 +39,47 @@ def static(prefix, view=serve, **kwargs):
|
||||
"""
|
||||
|
||||
if not prefix:
|
||||
raise ImproperlyConfigured("Empty static prefix not permitted")
|
||||
elif not settings.DEBUG or "://" in prefix:
|
||||
raise ImproperlyConfigured('Empty static prefix not permitted')
|
||||
elif not settings.DEBUG or '://' in prefix:
|
||||
# No-op if not in debug mode or a non-local prefix.
|
||||
return []
|
||||
User.is_authenticated
|
||||
return [
|
||||
re_path(
|
||||
r"^%s(?P<path>.*)$" % re.escape(prefix.lstrip("/")), view, kwargs=kwargs
|
||||
r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def getObjectOR404(klassModel, *args, **kwargs):
|
||||
objectModel = get_object_or_404(klassModel, pk=kwargs["pk"])
|
||||
objectModel = get_object_or_404(klassModel, pk=kwargs['pk'])
|
||||
return objectModel
|
||||
|
||||
|
||||
@login_required(login_url="/accounts/login/")
|
||||
@login_required(login_url='/accounts/login/')
|
||||
def get_media_URL(View):
|
||||
return settings.MEDIA_URL
|
||||
|
||||
|
||||
@login_required(login_url="/accounts/login/")
|
||||
@login_required(login_url='/accounts/login/')
|
||||
def get_media_ROOT(request):
|
||||
return settings.MEDIA_ROOT
|
||||
|
||||
|
||||
def convert_number(number):
|
||||
return (
|
||||
number.replace("A", "А")
|
||||
.replace("B", "В")
|
||||
.replace("C", "С")
|
||||
.replace("E", "Е")
|
||||
.replace("H", "Н")
|
||||
.replace("K", "К")
|
||||
.replace("M", "М")
|
||||
.replace("O", "О")
|
||||
.replace("P", "Р")
|
||||
.replace("T", "Т")
|
||||
.replace("X", "Х")
|
||||
.replace("Y", "У")
|
||||
number.replace('A', 'А')
|
||||
.replace('B', 'В')
|
||||
.replace('C', 'С')
|
||||
.replace('E', 'Е')
|
||||
.replace('H', 'Н')
|
||||
.replace('K', 'К')
|
||||
.replace('M', 'М')
|
||||
.replace('O', 'О')
|
||||
.replace('P', 'Р')
|
||||
.replace('T', 'Т')
|
||||
.replace('X', 'Х')
|
||||
.replace('Y', 'У')
|
||||
)
|
||||
|
||||
|
||||
@ -93,21 +89,21 @@ def getJobTime(seccond):
|
||||
m = (a // 60) % 60
|
||||
s = a % 60
|
||||
if m < 10:
|
||||
m = str("0" + str(m))
|
||||
m = str('0' + str(m))
|
||||
else:
|
||||
m = str(m)
|
||||
if s < 10:
|
||||
s = str("0" + str(s))
|
||||
s = str('0' + str(s))
|
||||
else:
|
||||
s = str(s)
|
||||
return str(h) + ":" + str(m) + ":" + str(s)
|
||||
return str(h) + ':' + str(m) + ':' + str(s)
|
||||
|
||||
|
||||
def ReturnJson(code, data):
|
||||
httpRespon = HttpResponse()
|
||||
httpRespon["Content-Type"] = "application/json"
|
||||
httpRespon['Content-Type'] = 'application/json'
|
||||
# httpRespon['Cache-Control']='no-cache,no-store'
|
||||
httpRespon["charset"] = "ASCII"
|
||||
httpRespon['charset'] = 'ASCII'
|
||||
httpRespon.status_code = code
|
||||
httpRespon.write(json.dumps(data, sort_keys=True, indent=4))
|
||||
return httpRespon
|
||||
@ -115,7 +111,7 @@ def ReturnJson(code, data):
|
||||
|
||||
def Return404():
|
||||
httpRespon = HttpResponse()
|
||||
httpRespon["Content-Type"] = "text/plain"
|
||||
httpRespon['Content-Type'] = 'text/plain'
|
||||
# httpRespon['charset']='ASCII'
|
||||
httpRespon.status_code = 404
|
||||
# httpRespon.write(json.dumps(data, sort_keys=True, indent=4))
|
||||
@ -124,14 +120,14 @@ def Return404():
|
||||
|
||||
def ReturnText(text):
|
||||
httpRespon = HttpResponse()
|
||||
httpRespon["Content-Type"] = "text/plain"
|
||||
httpRespon['Content-Type'] = 'text/plain'
|
||||
httpRespon.write(text)
|
||||
return httpRespon
|
||||
|
||||
|
||||
def ReturnApi(code, data):
|
||||
httpRespon = HttpResponse()
|
||||
httpRespon["Content-Type"] = "application/json"
|
||||
httpRespon['Content-Type'] = 'application/json'
|
||||
httpRespon.status_code = code
|
||||
httpRespon.write(json.dumps(data, sort_keys=True, indent=4))
|
||||
return httpRespon
|
||||
@ -145,6 +141,6 @@ def getSeconds(data1, data2):
|
||||
|
||||
|
||||
def buildblock(size):
|
||||
return "".join(
|
||||
return ''.join(
|
||||
random.choice(string.ascii_letters + string.digits) for _ in range(size)
|
||||
)
|
||||
|
||||
@ -97,9 +97,7 @@ class RedisSimpleService(RedisBaseService):
|
||||
|
||||
|
||||
class RedisHashService(RedisBaseService):
|
||||
def hset_value(
|
||||
self, name: str, key: str, value: bytes | str | int | float
|
||||
) -> bool:
|
||||
def hset_value(self, name: str, key: str, value: bytes | str | int | float) -> bool:
|
||||
"""
|
||||
Устанавливает значение в хэш по ключу.
|
||||
|
||||
|
||||
@ -7,19 +7,25 @@ class RedisCache:
|
||||
self.redis_host = redis_host
|
||||
|
||||
def set_cache_value(self, key: str, value: str) -> str:
|
||||
with RedisService(host=self.redis_host, port=self.redis_port, db=2) as redis_service:
|
||||
with RedisService(
|
||||
host=self.redis_host, port=self.redis_port, db=2
|
||||
) as redis_service:
|
||||
value = redis_service.set_value('cache_tasks/' + key, value)
|
||||
redis_service.set_expire('cache_tasks/' + key, 60)
|
||||
return value
|
||||
|
||||
def get_cache_value(self, key: str) -> bool:
|
||||
with RedisService(host=self.redis_host, port=self.redis_port, db=2) as redis_service:
|
||||
with RedisService(
|
||||
host=self.redis_host, port=self.redis_port, db=2
|
||||
) as redis_service:
|
||||
value = redis_service.get_value('cache_tasks/' + key)
|
||||
if value is None:
|
||||
return False
|
||||
return True
|
||||
|
||||
def delete_cache_value(self, key: str) -> str:
|
||||
with RedisService(host=self.redis_host, port=self.redis_port, db=2) as redis_service:
|
||||
with RedisService(
|
||||
host=self.redis_host, port=self.redis_port, db=2
|
||||
) as redis_service:
|
||||
value = redis_service.delete_value('cache_tasks/' + key)
|
||||
return value
|
||||
|
||||
12
app/apps/util/version.py
Normal file
12
app/apps/util/version.py
Normal file
@ -0,0 +1,12 @@
|
||||
from sabron.util.sabronmodule import get_settings, set_settings
|
||||
|
||||
|
||||
def get_version_from_db(version_name):
|
||||
res = get_settings(version_name)
|
||||
return res
|
||||
|
||||
|
||||
def print_update(version_name, version_from_file):
|
||||
print(f'Установлена версия {version_from_file}')
|
||||
set_settings(version_name, version_from_file)
|
||||
return 0
|
||||
560
app/fixtures/users.json
Normal file
560
app/fixtures/users.json
Normal file
@ -0,0 +1,560 @@
|
||||
[
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 1,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$EgJKhDBm3iJr79cfHhYa0j$ZB/K7Z1wl+TrPPcgJ5HCrPXIydTxqmp5cfSmcDWr6dA=",
|
||||
"last_login": "2025-04-09T02:03:02.549Z",
|
||||
"is_superuser": true,
|
||||
"username": "admin",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "admin@my.ru",
|
||||
"is_staff": true,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-11T08:33:18.046Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 2,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$fMDLwysdSIiWWHVVZhLJdG$vh0xnezDUeixobTiasrdor8yFC+hQ5SndGBiYR4jgOg=",
|
||||
"last_login": "2025-04-08T22:39:56.771Z",
|
||||
"is_superuser": false,
|
||||
"username": "Kranchev",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-12T09:21:18Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 3,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$acwTUU03XAyVNvoxRjdlhN$/qyr8BT2zDhHiQ+pvbk4BNYUI+LUplIEzANDMIOTpQg=",
|
||||
"last_login": "2024-02-15T04:39:05Z",
|
||||
"is_superuser": false,
|
||||
"username": "sabron",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-25T04:27:32Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 4,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$yLESO9AUgM135jyBAQRMUJ$qcOcp9XMqFI9qK/+yYRPBGEtanjFD0P7QMlsyFmJR9U=",
|
||||
"last_login": "2025-04-08T09:11:13.784Z",
|
||||
"is_superuser": false,
|
||||
"username": "Kuznetsov",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-25T06:33:49.315Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 5,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$3ChoU7XMYJVBW6nzE5QCHh$pibL+IRFanoJ09NiOPiUyXKsjXqpObg/rUNXktMmKDM=",
|
||||
"last_login": "2025-03-26T01:16:08.418Z",
|
||||
"is_superuser": false,
|
||||
"username": "Bendin",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-25T09:38:25Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 6,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$thj7r3jml9tUkhxV0sYSrj$jAs18cb0zVykn6aZGQvULmDtle7mnw43CWG7X0teMAM=",
|
||||
"last_login": "2025-04-08T12:50:50.184Z",
|
||||
"is_superuser": false,
|
||||
"username": "Arzanov",
|
||||
"first_name": "Максим",
|
||||
"last_name": "Арзанов",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-25T10:25:07Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 7,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$Vn9uNm00JV2tmHSdKeCJcb$C2r7ELj6uMln0GRF1rXzq8H01fj51Y3T3U+9ENtvxTo=",
|
||||
"last_login": "2025-03-27T15:02:15.504Z",
|
||||
"is_superuser": false,
|
||||
"username": "Turov",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-25T10:27:39.743Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 8,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$wLPFq0xOwphZMAFBoTIPJe$iW4teKj2A7svVavQxSM7RyOX6uG8gzZYg9zw369BG08=",
|
||||
"last_login": "2025-03-30T13:49:59.276Z",
|
||||
"is_superuser": false,
|
||||
"username": "Loshenov",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-25T11:41:49.891Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 9,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$7719HES3532l3GLieuabxg$D+BidCqd+1biXZDwS8x7QvLusQzd1XBJW1U8uEVZE+4=",
|
||||
"last_login": "2025-04-09T02:41:27.425Z",
|
||||
"is_superuser": false,
|
||||
"username": "Barmin",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-25T12:27:03.955Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 10,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$j8SxHIJ7r17Erox6mn0R28$OcMQ8zHkTHQ9GU3ANnPax7yKAnmYfEMtRnaFpPrPoXE=",
|
||||
"last_login": "2025-04-03T01:21:38.953Z",
|
||||
"is_superuser": false,
|
||||
"username": "Mehanik",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-01-25T13:10:48.754Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 11,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$f8vVPRACJWz9PdlRRUVbqV$XusTgQTgWTdwh4cCXl8cVuEBpEmLtyS9VRByAcggYo4=",
|
||||
"last_login": null,
|
||||
"is_superuser": false,
|
||||
"username": "Gorbunov",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-02-22T06:11:37.512Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 12,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$xu4WSihrVLyUqBVUoP8K3L$vTFcwfZoXBk6a9zPcQuxZ2/I9RldHcRpPXkp6FNvvTg=",
|
||||
"last_login": "2025-04-05T18:09:55.195Z",
|
||||
"is_superuser": false,
|
||||
"username": "Kostyleva",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-02-22T06:12:13.945Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 13,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$Fc1C4Bv9XQBKTrq2AwpRC6$M7W3gWjua7lZLbb9l67elENdbd2piNUuWbNFBvdtgkw=",
|
||||
"last_login": "2025-04-02T23:11:11.261Z",
|
||||
"is_superuser": false,
|
||||
"username": "Savelev",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-02-22T06:12:31.439Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 14,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$hVUvUFW0vklS3ndXMjG96k$qht8hyI1q66lZu7wJw5vovlsuJLcZ74Gjw/ffxbpstI=",
|
||||
"last_login": "2025-04-07T21:41:44.559Z",
|
||||
"is_superuser": false,
|
||||
"username": "Borodina",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-02-22T06:12:47.942Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 15,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$TKVW4SpcLDaAzuu0AyOhQp$yemZWVRfZXm8Khs8mjHvmo6LPsK+DhCNQl7sve0w0Jg=",
|
||||
"last_login": "2024-12-18T15:06:18.337Z",
|
||||
"is_superuser": false,
|
||||
"username": "Churilov",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-02-22T06:13:11.362Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 16,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$Xdz5ffOriYqJF0z6zF3xwy$HLvG7J/G6Dvt6VybJEFjvBAywGeQ8eUBFEy62KiBmnw=",
|
||||
"last_login": null,
|
||||
"is_superuser": false,
|
||||
"username": "Markelov",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-02-22T06:13:26.030Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 17,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$AI6TNga2uTetqfce8EWf4C$MA4PO/h9lSfDavTaZHz5T0uTfZS2lZYtPMJ5iYNxQnI=",
|
||||
"last_login": "2025-03-18T03:22:27.362Z",
|
||||
"is_superuser": false,
|
||||
"username": "Vakalov",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-03-05T08:56:33.878Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 18,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$EYw8AIfGm9A3nsTuRroLt5$pf6/1FpOlukUEcloMAzzukZsiRlkZGF7w77dUpa+YHY=",
|
||||
"last_login": "2024-12-27T19:35:57.118Z",
|
||||
"is_superuser": false,
|
||||
"username": "Slepcov",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-04-10T11:04:43.102Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 19,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$Wft8zPi9cHZt3ehygiDAiE$2I7gCl5vOIhWXZJcU53kC/lD03Y3KMrlR8zOJ/KS9yU=",
|
||||
"last_login": "2024-05-15T13:13:40.679Z",
|
||||
"is_superuser": false,
|
||||
"username": "tv",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-05-15T13:12:16.594Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 20,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$FZUwXzC4GeFv52pm6Z6hPU$raiu2+7LmWuNtUu/CJ9XxzoggfwAYwLV02dfffQ7jQA=",
|
||||
"last_login": "2025-02-13T09:13:53.405Z",
|
||||
"is_superuser": false,
|
||||
"username": "m.kovalev",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-06-01T22:45:56Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 21,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$J3JDlpxFwrEOGa5zTieKCV$0d9Li1gRjIGmXWpKY2lqX64OVA03w1aqvjGD/0gtDkA=",
|
||||
"last_login": "2024-06-26T11:02:45.024Z",
|
||||
"is_superuser": false,
|
||||
"username": "tvk",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-06-26T11:00:57.474Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 22,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$Kro3kliyFyCaNcsvUwSEPO$fASxv6Te2zqgUTDvuWKA2qn7dRalIon5g2EEKeQyH5E=",
|
||||
"last_login": "2025-03-25T06:26:30.470Z",
|
||||
"is_superuser": false,
|
||||
"username": "Mihailova",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-07-11T04:06:52.708Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 23,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$6dgPphWtHuBA0DUKaKZgc2$RdcHy9FaXPIUVIm0vpU7Mni1/3FBbr7IaKjkiOBGplU=",
|
||||
"last_login": "2025-04-08T02:36:00.842Z",
|
||||
"is_superuser": true,
|
||||
"username": "cybercode",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "admin@example.com",
|
||||
"is_staff": true,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-08-06T09:06:42Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 24,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$xBd1BbKRwLwrhLCx0LXm1y$1i/DcnmZziZfIq6YSbij9Fdb3qzK/hAgXPtKNsuGYF8=",
|
||||
"last_login": "2025-04-03T07:25:19.651Z",
|
||||
"is_superuser": false,
|
||||
"username": "repcofkk_user",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-08-06T10:12:59.120Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 25,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$0oP0MilsGAp3K6eU0DDEMj$0ACEAbzHXmPWMCT7DHzyjq3SlfJW4YzB8RsnSQUB97A=",
|
||||
"last_login": "2025-04-09T02:13:54.839Z",
|
||||
"is_superuser": false,
|
||||
"username": "Energy",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-08-07T05:51:24Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 27,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$9IJoPgcLcAteJ19Njz7mCh$q9RD1cteBdCNbRn5TyCD7kPA4MY7hh3EF835kOw16UA=",
|
||||
"last_login": "2024-12-15T01:03:53.485Z",
|
||||
"is_superuser": false,
|
||||
"username": "operator",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-11-26T04:18:58.818Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 28,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$tR2z8A5OMYEXZKqsbsNOs9$jJfRfM/e7L+1Zydl+fRXBFDYS8X1wA+rT/adcvSIDfg=",
|
||||
"last_login": "2024-12-12T05:56:50.289Z",
|
||||
"is_superuser": false,
|
||||
"username": "test",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2024-12-04T06:19:27.785Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 29,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$1jVI4U5UK9asAPZuEgJ0af$PIRljJ6FmixZyouSi9FNzyU0B7FtBcwLznYzylVzAi8=",
|
||||
"last_login": "2025-04-02T07:46:59.898Z",
|
||||
"is_superuser": false,
|
||||
"username": "Nadtochyi",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2025-02-05T06:26:14.613Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 30,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$bv2cAffYBjh9fgX4qYwIRH$ILTdbF8eLxxgeNaSmlwAKovZuDKZnszySOUF8UfcNIc=",
|
||||
"last_login": "2025-04-08T09:26:58.455Z",
|
||||
"is_superuser": false,
|
||||
"username": "Kazdorf",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2025-02-05T06:30:07.214Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 31,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$vth9OdrdFi1afdkJLcGQIM$GLvqjymxdyndP9kkITLInq+tjtQpV1KPEDbz8459E+g=",
|
||||
"last_login": null,
|
||||
"is_superuser": false,
|
||||
"username": "user",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2025-03-12T08:30:48.377Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "auth.user",
|
||||
"pk": 32,
|
||||
"fields": {
|
||||
"password": "pbkdf2_sha256$260000$UrA9gmoSjCiWmjGsFssUbr$5FspWwuLsw/jCbhmhudcdeRNjCcUSHSF4HWGT2rxA4U=",
|
||||
"last_login": "2025-04-09T01:44:00.029Z",
|
||||
"is_superuser": false,
|
||||
"username": "Timofeev",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": "",
|
||||
"is_staff": false,
|
||||
"is_active": true,
|
||||
"date_joined": "2025-03-17T12:22:06.394Z",
|
||||
"groups": [],
|
||||
"user_permissions": []
|
||||
}
|
||||
}
|
||||
]
|
||||
150
app/poetry.lock
generated
150
app/poetry.lock
generated
@ -1,4 +1,4 @@
|
||||
# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "amqp"
|
||||
@ -6,6 +6,7 @@ version = "5.2.0"
|
||||
description = "Low-level AMQP client for Python (fork of amqplib)."
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "amqp-5.2.0-py3-none-any.whl", hash = "sha256:827cb12fb0baa892aad844fd95258143bce4027fdac4fccddbc43330fd281637"},
|
||||
{file = "amqp-5.2.0.tar.gz", hash = "sha256:a1ecff425ad063ad42a486c902807d1482311481c8ad95a72694b2975e75f7fd"},
|
||||
@ -20,6 +21,7 @@ version = "3.8.1"
|
||||
description = "ASGI specs, helper code, and adapters"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "asgiref-3.8.1-py3-none-any.whl", hash = "sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47"},
|
||||
{file = "asgiref-3.8.1.tar.gz", hash = "sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590"},
|
||||
@ -37,6 +39,7 @@ version = "4.0.3"
|
||||
description = "Timeout context manager for asyncio programs"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "async-timeout-4.0.3.tar.gz", hash = "sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f"},
|
||||
{file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"},
|
||||
@ -48,6 +51,7 @@ version = "4.2.0"
|
||||
description = "Python multiprocessing fork with improvements and bugfixes"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "billiard-4.2.0-py3-none-any.whl", hash = "sha256:07aa978b308f334ff8282bd4a746e681b3513db5c9a514cbdd810cbbdc19714d"},
|
||||
{file = "billiard-4.2.0.tar.gz", hash = "sha256:9a3c3184cb275aa17a732f93f65b20c525d3d9f253722d26a82194803ade5a2c"},
|
||||
@ -59,6 +63,7 @@ version = "24.8.0"
|
||||
description = "The uncompromising code formatter."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "black-24.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:09cdeb74d494ec023ded657f7092ba518e8cf78fa8386155e4a03fdcc44679e6"},
|
||||
{file = "black-24.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:81c6742da39f33b08e791da38410f32e27d632260e599df7245cccee2064afeb"},
|
||||
@ -95,7 +100,7 @@ typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""}
|
||||
|
||||
[package.extras]
|
||||
colorama = ["colorama (>=0.4.3)"]
|
||||
d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"]
|
||||
d = ["aiohttp (>=3.7.4) ; sys_platform != \"win32\" or implementation_name != \"pypy\"", "aiohttp (>=3.7.4,!=3.9.0) ; sys_platform == \"win32\" and implementation_name == \"pypy\""]
|
||||
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
|
||||
uvloop = ["uvloop (>=0.15.2)"]
|
||||
|
||||
@ -105,6 +110,7 @@ version = "5.4.0"
|
||||
description = "Distributed Task Queue."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "celery-5.4.0-py3-none-any.whl", hash = "sha256:369631eb580cf8c51a82721ec538684994f8277637edde2dfc0dacd73ed97f64"},
|
||||
{file = "celery-5.4.0.tar.gz", hash = "sha256:504a19140e8d3029d5acad88330c541d4c3f64c789d85f94756762d8bca7e706"},
|
||||
@ -125,32 +131,32 @@ vine = ">=5.1.0,<6.0"
|
||||
arangodb = ["pyArango (>=2.0.2)"]
|
||||
auth = ["cryptography (==42.0.5)"]
|
||||
azureblockblob = ["azure-storage-blob (>=12.15.0)"]
|
||||
brotli = ["brotli (>=1.0.0)", "brotlipy (>=0.7.0)"]
|
||||
brotli = ["brotli (>=1.0.0) ; platform_python_implementation == \"CPython\"", "brotlipy (>=0.7.0) ; platform_python_implementation == \"PyPy\""]
|
||||
cassandra = ["cassandra-driver (>=3.25.0,<4)"]
|
||||
consul = ["python-consul2 (==0.1.5)"]
|
||||
cosmosdbsql = ["pydocumentdb (==2.3.5)"]
|
||||
couchbase = ["couchbase (>=3.0.0)"]
|
||||
couchbase = ["couchbase (>=3.0.0) ; platform_python_implementation != \"PyPy\" and (platform_system != \"Windows\" or python_version < \"3.10\")"]
|
||||
couchdb = ["pycouchdb (==1.14.2)"]
|
||||
django = ["Django (>=2.2.28)"]
|
||||
dynamodb = ["boto3 (>=1.26.143)"]
|
||||
elasticsearch = ["elastic-transport (<=8.13.0)", "elasticsearch (<=8.13.0)"]
|
||||
eventlet = ["eventlet (>=0.32.0)"]
|
||||
eventlet = ["eventlet (>=0.32.0) ; python_version < \"3.10\""]
|
||||
gcs = ["google-cloud-storage (>=2.10.0)"]
|
||||
gevent = ["gevent (>=1.5.0)"]
|
||||
librabbitmq = ["librabbitmq (>=2.0.0)"]
|
||||
memcache = ["pylibmc (==1.6.3)"]
|
||||
librabbitmq = ["librabbitmq (>=2.0.0) ; python_version < \"3.11\""]
|
||||
memcache = ["pylibmc (==1.6.3) ; platform_system != \"Windows\""]
|
||||
mongodb = ["pymongo[srv] (>=4.0.2)"]
|
||||
msgpack = ["msgpack (==1.0.8)"]
|
||||
pymemcache = ["python-memcached (>=1.61)"]
|
||||
pyro = ["pyro4 (==4.82)"]
|
||||
pyro = ["pyro4 (==4.82) ; python_version < \"3.11\""]
|
||||
pytest = ["pytest-celery[all] (>=1.0.0)"]
|
||||
redis = ["redis (>=4.5.2,!=4.5.5,<6.0.0)"]
|
||||
s3 = ["boto3 (>=1.26.143)"]
|
||||
slmq = ["softlayer-messaging (>=1.0.3)"]
|
||||
solar = ["ephem (==4.1.5)"]
|
||||
solar = ["ephem (==4.1.5) ; platform_python_implementation != \"PyPy\""]
|
||||
sqlalchemy = ["sqlalchemy (>=1.4.48,<2.1)"]
|
||||
sqs = ["boto3 (>=1.26.143)", "kombu[sqs] (>=5.3.4)", "pycurl (>=7.43.0.5)", "urllib3 (>=1.26.16)"]
|
||||
tblib = ["tblib (>=1.3.0)", "tblib (>=1.5.0)"]
|
||||
sqs = ["boto3 (>=1.26.143)", "kombu[sqs] (>=5.3.4)", "pycurl (>=7.43.0.5) ; sys_platform != \"win32\" and platform_python_implementation == \"CPython\"", "urllib3 (>=1.26.16)"]
|
||||
tblib = ["tblib (>=1.3.0) ; python_version < \"3.8.0\"", "tblib (>=1.5.0) ; python_version >= \"3.8.0\""]
|
||||
yaml = ["PyYAML (>=3.10)"]
|
||||
zookeeper = ["kazoo (>=1.3.1)"]
|
||||
zstd = ["zstandard (==0.22.0)"]
|
||||
@ -161,6 +167,7 @@ version = "2024.7.4"
|
||||
description = "Python package for providing Mozilla's CA Bundle."
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"},
|
||||
{file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"},
|
||||
@ -172,6 +179,7 @@ version = "3.4.0"
|
||||
description = "Validate configuration and produce human readable error messages."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"},
|
||||
{file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"},
|
||||
@ -183,6 +191,7 @@ version = "3.3.2"
|
||||
description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
|
||||
optional = false
|
||||
python-versions = ">=3.7.0"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"},
|
||||
{file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"},
|
||||
@ -282,6 +291,7 @@ version = "8.1.7"
|
||||
description = "Composable command line interface toolkit"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["main", "dev"]
|
||||
files = [
|
||||
{file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"},
|
||||
{file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"},
|
||||
@ -296,6 +306,7 @@ version = "0.3.1"
|
||||
description = "Enables git-like *did-you-mean* feature in click"
|
||||
optional = false
|
||||
python-versions = ">=3.6.2"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "click_didyoumean-0.3.1-py3-none-any.whl", hash = "sha256:5c4bb6007cfea5f2fd6583a2fb6701a22a41eb98957e63d0fac41c10e7c3117c"},
|
||||
{file = "click_didyoumean-0.3.1.tar.gz", hash = "sha256:4f82fdff0dbe64ef8ab2279bd6aa3f6a99c3b28c05aa09cbfc07c9d7fbb5a463"},
|
||||
@ -310,6 +321,7 @@ version = "1.1.1"
|
||||
description = "An extension module for click to enable registering CLI commands via setuptools entry-points."
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "click-plugins-1.1.1.tar.gz", hash = "sha256:46ab999744a9d831159c3411bb0c79346d94a444df9a3a3742e9ed63645f264b"},
|
||||
{file = "click_plugins-1.1.1-py2.py3-none-any.whl", hash = "sha256:5d262006d3222f5057fd81e1623d4443e41dcda5dc815c06b442aa3c02889fc8"},
|
||||
@ -327,6 +339,7 @@ version = "0.3.0"
|
||||
description = "REPL plugin for Click"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "click-repl-0.3.0.tar.gz", hash = "sha256:17849c23dba3d667247dc4defe1757fff98694e90fe37474f3feebb69ced26a9"},
|
||||
{file = "click_repl-0.3.0-py3-none-any.whl", hash = "sha256:fb7e06deb8da8de86180a33a9da97ac316751c094c6899382da7feeeeb51b812"},
|
||||
@ -345,6 +358,8 @@ version = "0.4.6"
|
||||
description = "Cross-platform colored terminal text."
|
||||
optional = false
|
||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
||||
groups = ["main", "dev"]
|
||||
markers = "platform_system == \"Windows\""
|
||||
files = [
|
||||
{file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
|
||||
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
|
||||
@ -356,6 +371,7 @@ version = "0.3.8"
|
||||
description = "Distribution utilities"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"},
|
||||
{file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"},
|
||||
@ -367,6 +383,7 @@ version = "3.2.25"
|
||||
description = "A high-level Python Web framework that encourages rapid development and clean, pragmatic design."
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "Django-3.2.25-py3-none-any.whl", hash = "sha256:a52ea7fcf280b16f7b739cec38fa6d3f8953a5456986944c3ca97e79882b4e38"},
|
||||
{file = "Django-3.2.25.tar.gz", hash = "sha256:7ca38a78654aee72378594d63e51636c04b8e28574f5505dff630895b5472777"},
|
||||
@ -381,12 +398,28 @@ sqlparse = ">=0.2.2"
|
||||
argon2 = ["argon2-cffi (>=19.1.0)"]
|
||||
bcrypt = ["bcrypt"]
|
||||
|
||||
[[package]]
|
||||
name = "django-upgrade"
|
||||
version = "1.24.0"
|
||||
description = "Automatically upgrade your Django project code."
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "django_upgrade-1.24.0-py3-none-any.whl", hash = "sha256:198572f31130cd80b4f30c568aa331351176cccf1455741e45ebca272812271d"},
|
||||
{file = "django_upgrade-1.24.0.tar.gz", hash = "sha256:d761d517f87338291ac73890e15b09775532c5cea8cf794f56ad159da9d63d9b"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
tokenize-rt = ">=4.1"
|
||||
|
||||
[[package]]
|
||||
name = "filelock"
|
||||
version = "3.15.4"
|
||||
description = "A platform independent file lock."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "filelock-3.15.4-py3-none-any.whl", hash = "sha256:6ca1fffae96225dab4c6eaf1c4f4f28cd2568d3ec2a44e15a08520504de468e7"},
|
||||
{file = "filelock-3.15.4.tar.gz", hash = "sha256:2207938cbc1844345cb01a5a95524dae30f0ce089eba5b00378295a17e3e90cb"},
|
||||
@ -395,7 +428,7 @@ files = [
|
||||
[package.extras]
|
||||
docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"]
|
||||
testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-asyncio (>=0.21)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)", "virtualenv (>=20.26.2)"]
|
||||
typing = ["typing-extensions (>=4.8)"]
|
||||
typing = ["typing-extensions (>=4.8) ; python_version < \"3.11\""]
|
||||
|
||||
[[package]]
|
||||
name = "flower"
|
||||
@ -403,6 +436,7 @@ version = "2.0.1"
|
||||
description = "Celery Flower"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "flower-2.0.1-py2.py3-none-any.whl", hash = "sha256:9db2c621eeefbc844c8dd88be64aef61e84e2deb29b271e02ab2b5b9f01068e2"},
|
||||
{file = "flower-2.0.1.tar.gz", hash = "sha256:5ab717b979530770c16afb48b50d2a98d23c3e9fe39851dcf6bc4d01845a02a0"},
|
||||
@ -421,6 +455,7 @@ version = "22.0.0"
|
||||
description = "WSGI HTTP Server for UNIX"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "gunicorn-22.0.0-py3-none-any.whl", hash = "sha256:350679f91b24062c86e386e198a15438d53a7a8207235a78ba1b53df4c4378d9"},
|
||||
{file = "gunicorn-22.0.0.tar.gz", hash = "sha256:4a0b436239ff76fb33f11c07a16482c521a7e09c1ce3cc293c2330afe01bec63"},
|
||||
@ -442,6 +477,7 @@ version = "4.10.0"
|
||||
description = "Python humanize utilities"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "humanize-4.10.0-py3-none-any.whl", hash = "sha256:39e7ccb96923e732b5c2e27aeaa3b10a8dfeeba3eb965ba7b74a3eb0e30040a6"},
|
||||
{file = "humanize-4.10.0.tar.gz", hash = "sha256:06b6eb0293e4b85e8d385397c5868926820db32b9b654b932f57fa41c23c9978"},
|
||||
@ -456,6 +492,7 @@ version = "2.6.0"
|
||||
description = "File identification library for Python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "identify-2.6.0-py2.py3-none-any.whl", hash = "sha256:e79ae4406387a9d300332b5fd366d8994f1525e8414984e1a59e058b2eda2dd0"},
|
||||
{file = "identify-2.6.0.tar.gz", hash = "sha256:cb171c685bdc31bcc4c1734698736a7d5b6c8bf2e0c15117f4d469c8640ae5cf"},
|
||||
@ -470,6 +507,7 @@ version = "3.7"
|
||||
description = "Internationalized Domain Names in Applications (IDNA)"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "idna-3.7-py3-none-any.whl", hash = "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0"},
|
||||
{file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"},
|
||||
@ -481,6 +519,7 @@ version = "5.4.0"
|
||||
description = "Messaging library for Python."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "kombu-5.4.0-py3-none-any.whl", hash = "sha256:c8dd99820467610b4febbc7a9e8a0d3d7da2d35116b67184418b51cc520ea6b6"},
|
||||
{file = "kombu-5.4.0.tar.gz", hash = "sha256:ad200a8dbdaaa2bbc5f26d2ee7d707d9a1fded353a0f4bd751ce8c7d9f449c60"},
|
||||
@ -495,7 +534,7 @@ azureservicebus = ["azure-servicebus (>=7.10.0)"]
|
||||
azurestoragequeues = ["azure-identity (>=1.12.0)", "azure-storage-queue (>=12.6.0)"]
|
||||
confluentkafka = ["confluent-kafka (>=2.2.0)"]
|
||||
consul = ["python-consul2 (==0.1.5)"]
|
||||
librabbitmq = ["librabbitmq (>=2.0.0)"]
|
||||
librabbitmq = ["librabbitmq (>=2.0.0) ; python_version < \"3.11\""]
|
||||
mongodb = ["pymongo (>=4.1.1)"]
|
||||
msgpack = ["msgpack (==1.0.8)"]
|
||||
pyro = ["pyro4 (==4.82)"]
|
||||
@ -503,16 +542,33 @@ qpid = ["qpid-python (>=0.26)", "qpid-tools (>=0.26)"]
|
||||
redis = ["redis (>=4.5.2,!=4.5.5,!=5.0.2)"]
|
||||
slmq = ["softlayer-messaging (>=1.0.3)"]
|
||||
sqlalchemy = ["sqlalchemy (>=1.4.48,<2.1)"]
|
||||
sqs = ["boto3 (>=1.26.143)", "pycurl (>=7.43.0.5)", "urllib3 (>=1.26.16)"]
|
||||
sqs = ["boto3 (>=1.26.143)", "pycurl (>=7.43.0.5) ; sys_platform != \"win32\" and platform_python_implementation == \"CPython\"", "urllib3 (>=1.26.16)"]
|
||||
yaml = ["PyYAML (>=3.10)"]
|
||||
zookeeper = ["kazoo (>=2.8.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "markdown"
|
||||
version = "3.7"
|
||||
description = "Python implementation of John Gruber's Markdown."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "Markdown-3.7-py3-none-any.whl", hash = "sha256:7eb6df5690b81a1d7942992c97fad2938e956e79df20cbc6186e9c3a77b1c803"},
|
||||
{file = "markdown-3.7.tar.gz", hash = "sha256:2ae2471477cfd02dbbf038d5d9bc226d40def84b4fe2986e49b59b6b472bbed2"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
docs = ["mdx-gh-links (>=0.2)", "mkdocs (>=1.5)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"]
|
||||
testing = ["coverage", "pyyaml"]
|
||||
|
||||
[[package]]
|
||||
name = "mypy"
|
||||
version = "1.11.1"
|
||||
description = "Optional static typing for Python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "mypy-1.11.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a32fc80b63de4b5b3e65f4be82b4cfa362a46702672aa6a0f443b4689af7008c"},
|
||||
{file = "mypy-1.11.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c1952f5ea8a5a959b05ed5f16452fddadbaae48b5d39235ab4c3fc444d5fd411"},
|
||||
@ -560,6 +616,7 @@ version = "1.0.0"
|
||||
description = "Type system extensions for programs checked with the mypy type checker."
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"},
|
||||
{file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"},
|
||||
@ -571,6 +628,7 @@ version = "1.9.1"
|
||||
description = "Node.js virtual environment builder"
|
||||
optional = false
|
||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"},
|
||||
{file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"},
|
||||
@ -582,6 +640,7 @@ version = "24.1"
|
||||
description = "Core utilities for Python packages"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main", "dev"]
|
||||
files = [
|
||||
{file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"},
|
||||
{file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"},
|
||||
@ -593,6 +652,7 @@ version = "0.12.1"
|
||||
description = "Utility library for gitignore style pattern matching of file paths."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"},
|
||||
{file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"},
|
||||
@ -604,6 +664,7 @@ version = "4.2.2"
|
||||
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"},
|
||||
{file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"},
|
||||
@ -620,6 +681,7 @@ version = "3.8.0"
|
||||
description = "A framework for managing and maintaining multi-language pre-commit hooks."
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "pre_commit-3.8.0-py2.py3-none-any.whl", hash = "sha256:9a90a53bf82fdd8778d58085faf8d83df56e40dfe18f45b19446e26bf1b3a63f"},
|
||||
{file = "pre_commit-3.8.0.tar.gz", hash = "sha256:8bb6494d4a20423842e198980c9ecf9f96607a07ea29549e180eef9ae80fe7af"},
|
||||
@ -638,6 +700,7 @@ version = "0.20.0"
|
||||
description = "Python client for the Prometheus monitoring system."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "prometheus_client-0.20.0-py3-none-any.whl", hash = "sha256:cde524a85bce83ca359cc837f28b8c0db5cac7aa653a588fd7e84ba061c329e7"},
|
||||
{file = "prometheus_client-0.20.0.tar.gz", hash = "sha256:287629d00b147a32dcb2be0b9df905da599b2d82f80377083ec8463309a4bb89"},
|
||||
@ -652,6 +715,7 @@ version = "3.0.47"
|
||||
description = "Library for building powerful interactive command lines in Python"
|
||||
optional = false
|
||||
python-versions = ">=3.7.0"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "prompt_toolkit-3.0.47-py3-none-any.whl", hash = "sha256:0d7bfa67001d5e39d02c224b663abc33687405033a8c422d0d675a5a13361d10"},
|
||||
{file = "prompt_toolkit-3.0.47.tar.gz", hash = "sha256:1e1b29cb58080b1e69f207c893a1a7bf16d127a5c30c9d17a25a5d77792e5360"},
|
||||
@ -666,6 +730,7 @@ version = "2.9.9"
|
||||
description = "psycopg2 - Python-PostgreSQL Database Adapter"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "psycopg2-binary-2.9.9.tar.gz", hash = "sha256:7f01846810177d829c7692f1f5ada8096762d9172af1b1a28d4ab5b77c923c1c"},
|
||||
{file = "psycopg2_binary-2.9.9-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c2470da5418b76232f02a2fcd2229537bb2d5a7096674ce61859c3229f2eb202"},
|
||||
@ -747,6 +812,7 @@ version = "2.9.0.post0"
|
||||
description = "Extensions to the standard Python datetime module"
|
||||
optional = false
|
||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"},
|
||||
{file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"},
|
||||
@ -761,6 +827,7 @@ version = "1.0.1"
|
||||
description = "Read key-value pairs from a .env file and set them as environment variables"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"},
|
||||
{file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"},
|
||||
@ -775,6 +842,7 @@ version = "2024.1"
|
||||
description = "World timezone definitions, modern and historical"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "pytz-2024.1-py2.py3-none-any.whl", hash = "sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"},
|
||||
{file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"},
|
||||
@ -786,6 +854,7 @@ version = "6.0.2"
|
||||
description = "YAML parser and emitter for Python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"},
|
||||
{file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"},
|
||||
@ -848,6 +917,7 @@ version = "5.0.8"
|
||||
description = "Python client for Redis database and key-value store"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "redis-5.0.8-py3-none-any.whl", hash = "sha256:56134ee08ea909106090934adc36f65c9bcbbaecea5b21ba704ba6fb561f8eb4"},
|
||||
{file = "redis-5.0.8.tar.gz", hash = "sha256:0c5b10d387568dfe0698c6fad6615750c24170e548ca2deac10c649d463e9870"},
|
||||
@ -866,6 +936,7 @@ version = "2.32.3"
|
||||
description = "Python HTTP for Humans."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"},
|
||||
{file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"},
|
||||
@ -887,6 +958,7 @@ version = "1.16.0"
|
||||
description = "Python 2 and 3 compatibility utilities"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
|
||||
@ -898,6 +970,7 @@ version = "0.5.1"
|
||||
description = "A non-validating SQL parser."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "sqlparse-0.5.1-py3-none-any.whl", hash = "sha256:773dcbf9a5ab44a090f3441e2180efe2560220203dc2f8c0b0fa141e18b505e4"},
|
||||
{file = "sqlparse-0.5.1.tar.gz", hash = "sha256:bb6b4df465655ef332548e24f08e205afc81b9ab86cb1c45657a7ff173a3a00e"},
|
||||
@ -907,12 +980,25 @@ files = [
|
||||
dev = ["build", "hatch"]
|
||||
doc = ["sphinx"]
|
||||
|
||||
[[package]]
|
||||
name = "tokenize-rt"
|
||||
version = "6.1.0"
|
||||
description = "A wrapper around the stdlib `tokenize` which roundtrips."
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "tokenize_rt-6.1.0-py2.py3-none-any.whl", hash = "sha256:d706141cdec4aa5f358945abe36b911b8cbdc844545da99e811250c0cee9b6fc"},
|
||||
{file = "tokenize_rt-6.1.0.tar.gz", hash = "sha256:e8ee836616c0877ab7c7b54776d2fefcc3bde714449a206762425ae114b53c86"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tomli"
|
||||
version = "2.0.1"
|
||||
description = "A lil' TOML parser"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||
@ -924,6 +1010,7 @@ version = "6.4.1"
|
||||
description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "tornado-6.4.1-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:163b0aafc8e23d8cdc3c9dfb24c5368af84a81e3364745ccb4427669bf84aec8"},
|
||||
{file = "tornado-6.4.1-cp38-abi3-macosx_10_9_x86_64.whl", hash = "sha256:6d5ce3437e18a2b66fbadb183c1d3364fb03f2be71299e7d10dbeeb69f4b2a14"},
|
||||
@ -944,6 +1031,7 @@ version = "2.32.0.20240712"
|
||||
description = "Typing stubs for requests"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "types-requests-2.32.0.20240712.tar.gz", hash = "sha256:90c079ff05e549f6bf50e02e910210b98b8ff1ebdd18e19c873cd237737c1358"},
|
||||
{file = "types_requests-2.32.0.20240712-py3-none-any.whl", hash = "sha256:f754283e152c752e46e70942fa2a146b5bc70393522257bb85bd1ef7e019dcc3"},
|
||||
@ -958,6 +1046,7 @@ version = "4.12.2"
|
||||
description = "Backported and Experimental Type Hints for Python 3.8+"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main", "dev"]
|
||||
files = [
|
||||
{file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"},
|
||||
{file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"},
|
||||
@ -969,6 +1058,7 @@ version = "2024.1"
|
||||
description = "Provider of IANA time zone data"
|
||||
optional = false
|
||||
python-versions = ">=2"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "tzdata-2024.1-py2.py3-none-any.whl", hash = "sha256:9068bc196136463f5245e51efda838afa15aaeca9903f49050dfa2679db4d252"},
|
||||
{file = "tzdata-2024.1.tar.gz", hash = "sha256:2674120f8d891909751c38abcdfd386ac0a5a1127954fbc332af6b5ceae07efd"},
|
||||
@ -980,23 +1070,45 @@ version = "2.2.2"
|
||||
description = "HTTP library with thread-safe connection pooling, file post, and more."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main", "dev"]
|
||||
files = [
|
||||
{file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"},
|
||||
{file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"]
|
||||
brotli = ["brotli (>=1.0.9) ; platform_python_implementation == \"CPython\"", "brotlicffi (>=0.8.0) ; platform_python_implementation != \"CPython\""]
|
||||
h2 = ["h2 (>=4,<5)"]
|
||||
socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||
zstd = ["zstandard (>=0.18.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "versioning"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
optional = false
|
||||
python-versions = "^3.10"
|
||||
groups = ["main"]
|
||||
files = []
|
||||
develop = false
|
||||
|
||||
[package.dependencies]
|
||||
django = "^3.2"
|
||||
markdown = "^3.7"
|
||||
|
||||
[package.source]
|
||||
type = "git"
|
||||
url = "https://git.cybercode.pro/zakhy/versioning.git"
|
||||
reference = "HEAD"
|
||||
resolved_reference = "5acc472975b5c3adccd3bebf30cd408ab4461c38"
|
||||
|
||||
[[package]]
|
||||
name = "vine"
|
||||
version = "5.1.0"
|
||||
description = "Python promises."
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "vine-5.1.0-py3-none-any.whl", hash = "sha256:40fdf3c48b2cfe1c38a49e9ae2da6fda88e4794c810050a728bd7413811fb1dc"},
|
||||
{file = "vine-5.1.0.tar.gz", hash = "sha256:8b62e981d35c41049211cf62a0a1242d8c1ee9bd15bb196ce38aefd6799e61e0"},
|
||||
@ -1008,6 +1120,7 @@ version = "20.26.3"
|
||||
description = "Virtual Python Environment builder"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "virtualenv-20.26.3-py3-none-any.whl", hash = "sha256:8cc4a31139e796e9a7de2cd5cf2489de1217193116a8fd42328f1bd65f434589"},
|
||||
{file = "virtualenv-20.26.3.tar.gz", hash = "sha256:4c43a2a236279d9ea36a0d76f98d84bd6ca94ac4e0f4a3b9d46d05e10fea542a"},
|
||||
@ -1020,7 +1133,7 @@ platformdirs = ">=3.9.1,<5"
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"]
|
||||
test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"]
|
||||
test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8) ; platform_python_implementation == \"PyPy\" or platform_python_implementation == \"CPython\" and sys_platform == \"win32\" and python_version >= \"3.13\"", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10) ; platform_python_implementation == \"CPython\""]
|
||||
|
||||
[[package]]
|
||||
name = "wcwidth"
|
||||
@ -1028,12 +1141,13 @@ version = "0.2.13"
|
||||
description = "Measures the displayed width of unicode strings in a terminal"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "wcwidth-0.2.13-py2.py3-none-any.whl", hash = "sha256:3da69048e4540d84af32131829ff948f1e022c1c6bdb8d6102117aac784f6859"},
|
||||
{file = "wcwidth-0.2.13.tar.gz", hash = "sha256:72ea0c06399eb286d978fdedb6923a9eb47e1c486ce63e9b4e64fc18303972b5"},
|
||||
]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
lock-version = "2.1"
|
||||
python-versions = "~3.10"
|
||||
content-hash = "329ca421a9211ca34d1c853447757aa9aac41bb76d3d7bed9b7dac9787fe397c"
|
||||
content-hash = "5fe1024dd0a02fce3a8ed5a9f60cc7d1c4413f73f19f615f1a6581f433eb0ec8"
|
||||
|
||||
@ -16,6 +16,7 @@ psycopg2-binary = "^2.9.9"
|
||||
redis = "^5.0.8"
|
||||
requests = "^2.32.3"
|
||||
python-dotenv = "^1.0.1"
|
||||
versioning = {git = "https://git.cybercode.pro/zakhy/versioning.git"}
|
||||
|
||||
|
||||
|
||||
@ -24,6 +25,7 @@ black = "^24.8.0"
|
||||
pre-commit = "^3.8.0"
|
||||
types-requests = "^2.32.0.20240712"
|
||||
mypy = "^1.11.1"
|
||||
django-upgrade = "^1.24.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
|
||||
@ -9,14 +9,18 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize',
|
||||
'apps.main.apps.MainConfig', # Стартовая страница
|
||||
'apps.montorem.apps.MontoremConfig', # Подсистема монторем
|
||||
'apps.management.apps.ManagementConfig',
|
||||
'apps.finance.apps.FinanceConfig',
|
||||
'versioning',
|
||||
]
|
||||
|
||||
"""Информация о приложении """
|
||||
SITE_TITLE = 'Система отчетов'
|
||||
SITE_TITLE_S = 'СиО'
|
||||
APP_VERSION = '0.9.1'
|
||||
APP_VERSION = '1.0.11.0'
|
||||
APP_VEK = '2024 г'
|
||||
APP_COPPIRIGHT = 'Система отчетов'
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import os
|
||||
|
||||
from celery import Celery
|
||||
from celery.schedules import crontab
|
||||
|
||||
# Установить модуль с настройками. Должна идти до следующей строчки
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'repcofkk.settings')
|
||||
@ -19,16 +18,12 @@ app.conf.beat_schedule = {
|
||||
'task': 'apps.main.tasks.create_worktime_data',
|
||||
'schedule': 30,
|
||||
},
|
||||
'scales_control': {
|
||||
'task': 'apps.main.tasks.create_scales_control_data',
|
||||
'schedule': 30,
|
||||
},
|
||||
# 'scales_control': {
|
||||
# 'task': 'apps.main.tasks.create_scales_control_data',
|
||||
# 'schedule': 30,
|
||||
# },
|
||||
'write_scale_control_data_to_redis': {
|
||||
'task': 'apps.main.tasks.write_scale_control_data_to_redis',
|
||||
'schedule': 30,
|
||||
},
|
||||
'shift_report': {
|
||||
'task': 'apps.main.tasks.create_shift_report',
|
||||
'schedule': crontab(hour='7,19', minute=50),
|
||||
},
|
||||
}
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
bind = "127.0.0.1:8000"
|
||||
workers = 1
|
||||
timeout = 600
|
||||
user = "cybercode"
|
||||
|
||||
max_requests = 2048
|
||||
threads = 2
|
||||
keepalive = 5
|
||||
worker_connections = 1024
|
||||
worker_class = "gthread"
|
||||
|
||||
|
||||
errorlog = "/home/cybercode/repcofkk/log/gunicorn_error.log"
|
||||
loglevel = "error"
|
||||
@ -1,12 +1,14 @@
|
||||
import os
|
||||
import zoneinfo
|
||||
|
||||
DEBUG = False
|
||||
|
||||
TIME_ZONE = "Asia/Krasnoyarsk"
|
||||
TIME_ZONE = 'Asia/Krasnoyarsk'
|
||||
TIME_ZONE_OBJECT = zoneinfo.ZoneInfo(TIME_ZONE)
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
"127.0.0.1",
|
||||
"*",
|
||||
'127.0.0.1',
|
||||
'*',
|
||||
]
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@ -15,31 +17,31 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
# STATIC_ROOT = 'static'
|
||||
# MEDIA_ROOT = 'media'
|
||||
|
||||
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static/"),)
|
||||
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static/'),)
|
||||
|
||||
ATT_ROOT = ""
|
||||
ADR_LOCAL = ""
|
||||
DOWNLOAD_ROOT = ""
|
||||
ATT_ROOT = ''
|
||||
ADR_LOCAL = ''
|
||||
DOWNLOAD_ROOT = ''
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
||||
"HOST": os.environ.get("POSTGRES_HOST", "127.0.0.1"),
|
||||
"PORT": int(os.environ.get("POSTGRES_PORT", "5432")),
|
||||
"NAME": os.environ.get("POSTGRES_DB", "repcofkk_db"),
|
||||
"USER": os.environ.get("POSTGRES_USER", "repcofkk_user"),
|
||||
"PASSWORD": os.environ.get("POSTGRES_PASSWORD", "Angstrem*45"),
|
||||
"CONN_MAX_AGE": None,
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'HOST': os.environ.get('POSTGRES_HOST', '127.0.0.1'),
|
||||
'PORT': int(os.environ.get('POSTGRES_PORT', '5432')),
|
||||
'NAME': os.environ.get('POSTGRES_DB', 'repcofkk_db'),
|
||||
'USER': os.environ.get('POSTGRES_USER', 'repcofkk_user'),
|
||||
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', 'Angstrem*45'),
|
||||
'CONN_MAX_AGE': None,
|
||||
},
|
||||
}
|
||||
|
||||
REDIS_HOST = os.getenv("REDIS_HOST")
|
||||
REDIS_PORT = os.getenv("REDIS_PORT")
|
||||
REDIS_HOST = os.getenv('REDIS_HOST')
|
||||
REDIS_PORT = os.getenv('REDIS_PORT')
|
||||
|
||||
CELERY_BROKER_URL = "redis://" + REDIS_HOST + ":" + REDIS_PORT + "/0"
|
||||
CELERY_BROKER_TRANSPORT_OPTIONS = {"visibility_timeout": 3600}
|
||||
CELERY_RESULT_BACKEND = "redis://" + REDIS_HOST + ":" + REDIS_PORT + "/0"
|
||||
CELERY_BROKER_URL = 'redis://' + REDIS_HOST + ':' + REDIS_PORT + '/0'
|
||||
CELERY_BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 3600}
|
||||
CELERY_RESULT_BACKEND = 'redis://' + REDIS_HOST + ':' + REDIS_PORT + '/0'
|
||||
|
||||
CELERY_ACCEPT_CONTENT = ["application/json"]
|
||||
CELERY_TASK_SERIALIZER = "json"
|
||||
CELERY_RESULT_SERIALIZER = "json"
|
||||
CELERY_ACCEPT_CONTENT = ['application/json']
|
||||
CELERY_TASK_SERIALIZER = 'json'
|
||||
CELERY_RESULT_SERIALIZER = 'json'
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import os
|
||||
import zoneinfo
|
||||
|
||||
from django.conf import settings
|
||||
from dotenv import load_dotenv
|
||||
from sabron.util import logging
|
||||
|
||||
@ -21,10 +23,9 @@ TEMPLATES_ROOT = os.path.join(BASE_DIR, 'templates')
|
||||
MEDIA_URL = '/media/'
|
||||
STATIC_URL = '/static/'
|
||||
LANGUAGE_CODE = 'ru'
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
USE_TZ = False
|
||||
USE_TZ = True
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||
|
||||
MIDDLEWARE = [
|
||||
@ -90,6 +91,11 @@ LOGIN_REDIRECT_URL = '/'
|
||||
|
||||
logging.set()
|
||||
|
||||
# Настройки для версирования
|
||||
|
||||
GET_VERSION_FROM_DB_FUNCTION = 'apps.util.version.get_version_from_db'
|
||||
ON_UPDATE_FUNCTION = 'apps.util.version.print_update'
|
||||
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError:
|
||||
|
||||
@ -1,22 +1,24 @@
|
||||
from django.contrib import admin
|
||||
from django.conf.urls import url
|
||||
from django.conf.urls import include
|
||||
from django.conf.urls.static import static
|
||||
from django.conf import settings
|
||||
from django.views.generic import RedirectView
|
||||
from . import views
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path, re_path
|
||||
from versioning.core import Update
|
||||
|
||||
from . import views
|
||||
from .views import router
|
||||
|
||||
urlpatterns = [
|
||||
url(
|
||||
r"^$", RedirectView.as_view(url="/main/", permanent=True)
|
||||
), # Перенаправляет все запросы
|
||||
url(r"^main/", include("apps.main.urls")),
|
||||
url(r"^montorem/", include("apps.montorem.urls")),
|
||||
url(r"^accounts/logout/", views.user_logout, name="user_logout"),
|
||||
url(r"^accounts/", views.user_login, name="user_login"),
|
||||
url(r"^admin/", admin.site.urls),
|
||||
path('', router, name='router'), # Перенаправляет все запросы
|
||||
path('main/', include('apps.main.urls')),
|
||||
path('montorem/', include('apps.montorem.urls')),
|
||||
re_path(r'^accounts/logout/', views.user_logout, name='user_logout'),
|
||||
re_path(r'^accounts/', views.user_login, name='user_login'),
|
||||
re_path(r'^admin/', admin.site.urls),
|
||||
path('management/', include('apps.management.urls'), name='management'),
|
||||
path('finance/', include('apps.finance.urls'), name='finance'),
|
||||
]
|
||||
|
||||
urlpatterns += static(settings.DOWNLOAD_URL, document_root=settings.DOWNLOAD_ROOT)
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
Update().ready()
|
||||
|
||||
@ -1,14 +1,24 @@
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import redirect
|
||||
from django.contrib.auth import authenticate
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth import logout
|
||||
from apps.util.generalmodule import get_context_template
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpResponseRedirect
|
||||
|
||||
from django.shortcuts import redirect, render
|
||||
from django.views.decorators.cache import never_cache
|
||||
from users.models import Profile
|
||||
|
||||
from apps.util import generalmodule
|
||||
|
||||
@login_required(login_url='/accounts/login/?next=')
|
||||
@never_cache
|
||||
def router(request):
|
||||
user = request.user
|
||||
group_names = [group.name for group in user.groups.all()]
|
||||
context = get_context_template(request)
|
||||
if 'Уголь' in group_names:
|
||||
return redirect('main_index')
|
||||
elif 'Финансы' in group_names:
|
||||
return redirect('finance:fin_index')
|
||||
else:
|
||||
return render(request, 'default.html', context)
|
||||
|
||||
|
||||
def user_block(request, user):
|
||||
@ -29,57 +39,69 @@ def user_api(request, user):
|
||||
return False
|
||||
|
||||
|
||||
def user_have_groups(request, user):
|
||||
return bool(user.groups.exists())
|
||||
|
||||
|
||||
def user_login(request):
|
||||
if request.method == "POST":
|
||||
username = request.POST.get("username")
|
||||
password = request.POST.get("password")
|
||||
if request.method == 'POST':
|
||||
username = request.POST.get('username')
|
||||
password = request.POST.get('password')
|
||||
user = authenticate(username=username, password=password)
|
||||
if user:
|
||||
if user_api(request, user):
|
||||
context = {
|
||||
"error": True,
|
||||
"comment": "API пользователь не имеет доступ к Личному Кабинету",
|
||||
'error': True,
|
||||
'comment': 'API пользователь не имеет доступ к Личному Кабинету',
|
||||
}
|
||||
return render(request, "registration/login.html", context)
|
||||
return render(request, 'registration/login.html', context)
|
||||
|
||||
if not user_have_groups(request, user):
|
||||
context = {
|
||||
'error': True,
|
||||
'comment': 'Данный пользователь не имеет доступ к ни одной из панелей системы.'
|
||||
'\nОбратитесь к администратору системы',
|
||||
}
|
||||
return render(request, 'registration/login.html', context)
|
||||
|
||||
if user_block(request, user):
|
||||
login(request, user)
|
||||
context = {
|
||||
"user": user,
|
||||
"login": username,
|
||||
"logout": "accounts/logout/",
|
||||
'user': user,
|
||||
'login': username,
|
||||
'logout': 'accounts/logout/',
|
||||
}
|
||||
return HttpResponseRedirect("/", context)
|
||||
return HttpResponseRedirect('/', context)
|
||||
else:
|
||||
context = {
|
||||
"error": True,
|
||||
"login": username,
|
||||
"comment": "Пользователь заблокирован",
|
||||
'error': True,
|
||||
'login': username,
|
||||
'comment': 'Пользователь заблокирован',
|
||||
}
|
||||
return render(request, "registration/login.html", context)
|
||||
return render(request, 'registration/login.html', context)
|
||||
else:
|
||||
context = {
|
||||
"error": True,
|
||||
"login": username,
|
||||
"comment": "Не верный логин или пароль",
|
||||
'error': True,
|
||||
'login': username,
|
||||
'comment': 'Не верный логин или пароль',
|
||||
}
|
||||
return render(request, "registration/login.html", context)
|
||||
return render(request, 'registration/login.html', context)
|
||||
else:
|
||||
if request.user.is_anonymous:
|
||||
context = {
|
||||
"error": False,
|
||||
"comment": "",
|
||||
'error': False,
|
||||
'comment': '',
|
||||
}
|
||||
return render(request, "registration/login.html", context)
|
||||
return render(request, 'registration/login.html', context)
|
||||
|
||||
else:
|
||||
return redirect("/")
|
||||
return redirect('/')
|
||||
|
||||
|
||||
def user_logout(request):
|
||||
logout(request)
|
||||
context = {
|
||||
"user": "",
|
||||
"logout": "accounts/logout/",
|
||||
'user': '',
|
||||
'logout': 'accounts/logout/',
|
||||
}
|
||||
return HttpResponseRedirect("/", context)
|
||||
return HttpResponseRedirect('/', context)
|
||||
|
||||
Binary file not shown.
@ -1,5 +1,4 @@
|
||||
from django.db import ProgrammingError
|
||||
|
||||
from sabron.models import Settings
|
||||
|
||||
|
||||
@ -12,13 +11,13 @@ def set_settings(name, value):
|
||||
settings_token.save()
|
||||
|
||||
|
||||
def get_settings(name: str) -> str:
|
||||
def get_settings(name: str, default: str = '') -> str:
|
||||
try:
|
||||
settings_token = Settings.objects.filter(name=name).first()
|
||||
if settings_token is None:
|
||||
Settings.objects.create(name=name, value="")
|
||||
return ""
|
||||
Settings.objects.create(name=name, value=default)
|
||||
return default
|
||||
else:
|
||||
return settings_token.value
|
||||
except ProgrammingError:
|
||||
return ""
|
||||
return ''
|
||||
|
||||
@ -1,34 +1 @@
|
||||
[
|
||||
{
|
||||
"model": "sabron.settings",
|
||||
"pk": 1,
|
||||
"fields": {
|
||||
"name": "api_login",
|
||||
"value": "user_api"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "sabron.settings",
|
||||
"pk": 2,
|
||||
"fields": {
|
||||
"name": "api_password",
|
||||
"value": "qwerty*1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "sabron.settings",
|
||||
"pk": 3,
|
||||
"fields": {
|
||||
"name": "api_host",
|
||||
"value": "http://192.168.10.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "sabron.settings",
|
||||
"pk": 4,
|
||||
"fields": {
|
||||
"name": "control_conveyor",
|
||||
"value": "SIEMENSPLC.AZG01.ReportProdDB.Pos4AverSmena"
|
||||
}
|
||||
}
|
||||
]
|
||||
[{"model": "sabron.settings", "pk": 1, "fields": {"name": "scales_db", "value": "vesi_db"}}, {"model": "sabron.settings", "pk": 2, "fields": {"name": "scales_db_user", "value": "ktp_user"}}, {"model": "sabron.settings", "pk": 3, "fields": {"name": "scales_db_password", "value": "rb,thrjl"}}, {"model": "sabron.settings", "pk": 4, "fields": {"name": "scales_db_host", "value": "192.168.10.2"}}, {"model": "sabron.settings", "pk": 5, "fields": {"name": "scales_db_port", "value": "5432"}}, {"model": "sabron.settings", "pk": 6, "fields": {"name": "control_conveyor", "value": "SIEMENSPLC.AZG01.ReportProdDB.ProdPos4.Productivity"}}, {"model": "sabron.settings", "pk": 7, "fields": {"name": "api_login", "value": "user_api"}}, {"model": "sabron.settings", "pk": 8, "fields": {"name": "api_password", "value": "qwerty*1"}}, {"model": "sabron.settings", "pk": 9, "fields": {"name": "api_host", "value": "http://192.168.10.3"}}, {"model": "sabron.settings", "pk": 10, "fields": {"name": "conveyor_month", "value": "SIEMENSPLC.AZG01.ReportProdDB.ProdPos4.Month"}}, {"model": "sabron.settings", "pk": 11, "fields": {"name": "fabric_goal", "value": "300000"}}, {"model": "sabron.settings", "pk": 12, "fields": {"name": "meteo_api_token", "value": "17cf44cf-ffe8-4aa1-88d8-428eb592070d"}}, {"model": "sabron.settings", "pk": 13, "fields": {"name": "post_id", "value": "1218"}}, {"model": "sabron.settings", "pk": 14, "fields": {"name": "APP_VERSION", "value": "1.0.10.6"}}, {"model": "sabron.settings", "pk": 15, "fields": {"name": "conveyor_bool", "value": "SIEMENSPLC.AZG01.Area I.inPos4DKS"}}, {"model": "sabron.settings", "pk": 16, "fields": {"name": "fabric_unloaded_val", "value": "5"}}]
|
||||
|
||||
@ -226,3 +226,39 @@ body {
|
||||
.m-card-user.m-card-user--skin-dark .m-card-user__details .m-card-user__name {
|
||||
color: #29292b;
|
||||
}
|
||||
|
||||
/* Основные стили для контейнера бегущей строки */
|
||||
.marquee {
|
||||
width: 50vw;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
background-color: #f0f0f0;
|
||||
padding: 10px 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc; /* Для наглядности */
|
||||
}
|
||||
|
||||
/* Контейнер для содержимого бегущей строки */
|
||||
.marquee-content {
|
||||
display: inline-block;
|
||||
padding-left: 100%; /* Начальное смещение за пределы экрана */
|
||||
animation: marquee 40s linear infinite;
|
||||
}
|
||||
|
||||
/* Стили для элементов внутри бегущей строки */
|
||||
.marquee-content div {
|
||||
display: inline-block;
|
||||
margin-right: 40px; /* Расстояние между элементами */
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* Анимация для бегущей строки */
|
||||
@keyframes marquee {
|
||||
0% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,6 +139,7 @@
|
||||
if (sensors.length === 0) {
|
||||
const densityContainer = document.querySelector('#densityContainer')
|
||||
densityContainer.innerHTML = `<div class="col-12 d-flex justify-content-center"><span>Нет данных.</span</div>`
|
||||
setTimeout(main, 3000)
|
||||
}
|
||||
drawChart(sensors['respose'][0], spark1Chart)
|
||||
drawChart(sensors['respose'][1], spark2Chart)
|
||||
|
||||
0
app/static/js/charts/meteo.js
Normal file
0
app/static/js/charts/meteo.js
Normal file
@ -93,6 +93,22 @@
|
||||
<span class="m-menu__link-text">Обзорный экран</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="m-menu__item " m-menu-link-redirect="1"
|
||||
aria-haspopup="true">
|
||||
<a href="/main/scada/flotation/" class="m-menu__link "
|
||||
target="_blank">
|
||||
<i class="m-menu__link-icon flaticon-graphic-2"></i>
|
||||
<span class="m-menu__link-text">Флотация</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="m-menu__item " m-menu-link-redirect="1"
|
||||
aria-haspopup="true">
|
||||
<a href="/main/scada/charger/" class="m-menu__link "
|
||||
target="_blank" id="chargerLink">
|
||||
<i class="m-menu__link-icon flaticon-graphic-2"></i>
|
||||
<span class="m-menu__link-text">Шихтовщик</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="m-menu__item">
|
||||
@ -149,10 +165,56 @@
|
||||
<li class="m-menu__item"></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="m_header_topbar" class="m-topbar m-stack m-stack--ver m-stack--general m-stack--fluid">
|
||||
<div class="m-stack__item m-topbar__nav-wrapper">
|
||||
<ul class="m-topbar__nav m-nav m-nav--inline">
|
||||
|
||||
<li class="m-nav__item">
|
||||
<div class="marquee" id="meteoMarquee">
|
||||
<div class="marquee-content">
|
||||
<div>
|
||||
PM2.5:
|
||||
<b><span class="meteo_pm2"></span> мгк/м<sup>3</sup></b>
|
||||
</div>
|
||||
<div>
|
||||
PM10:
|
||||
<b><span class="meteo_pm10"></span> мгк/м<sup>3</sup></b>
|
||||
</div>
|
||||
<div>
|
||||
CO: <b><span class="meteo_co"></span> мгк/м<sup>3</sup></b>
|
||||
</div>
|
||||
<div>
|
||||
NO<sub>2</sub>: <b><span class="meteo_no2"></span> мгк/м<sup>3</sup></b>
|
||||
</div>
|
||||
<div>
|
||||
SO<sub>2</sub>: <b><span class="meteo_so2"></span> мгк/м<sup>3</sup></b>
|
||||
</div>
|
||||
<div>
|
||||
O<sub>3</sub>: <b><span class="meteo_o3"></span> мгк/м<sup>3</sup></b>
|
||||
</div>
|
||||
<div>
|
||||
H<sub>2</sub>S: <b><span class="meteo_h2s"></span> мгк/м<sup>3</sup></b>
|
||||
</div>
|
||||
<div>
|
||||
Температура: <b><span class="meteo_temperature"></span>°C</b>
|
||||
</div>
|
||||
<div>
|
||||
Давление: <b><span class="meteo_pressure"></span> мм.рт.ст.</b>
|
||||
</div>
|
||||
<div>
|
||||
Относительная влажность: <b><span class="meteo_humidity"></span>%</b>
|
||||
</div>
|
||||
<div>
|
||||
Направление ветра: <b><span class="meteo_wda"></span></b>
|
||||
<i class="fa fa-arrow-up wda-dir" style="color: var(--primary);"></i>
|
||||
</div>
|
||||
<div>
|
||||
Скорость ветра: <b><span class="meteo_wva"></span> м/c</b>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="m-nav__item m-topbar__user-profile m-topbar__user-profile--img m-dropdown m-dropdown--medium m-dropdown--arrow m-dropdown--header-bg-fill m-dropdown--align-right m-dropdown--mobile-full-width m-dropdown--skin-light"
|
||||
m-dropdown-toggle="click">
|
||||
<a href="#" class="m-nav__link m-dropdown__toggle">
|
||||
@ -185,7 +247,7 @@
|
||||
</li>
|
||||
{% if request.user.is_superuser or request.user.is_staff %}
|
||||
<li class="m-nav__item mb-2">
|
||||
<a href="{% url 'administration' %}"
|
||||
<a href="{% url 'management:administration' %}"
|
||||
class="btn m-btn--pill btn-secondary m-btn m-btn--custom m-btn--label-brand m-btn--bolder ">Администрирование</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
@ -218,6 +280,30 @@
|
||||
class="m-aside-menu m-aside-menu--skin-dark m-aside-menu--submenu-skin-dark position-relative"
|
||||
m-menu-vertical="1" m-menu-scrollable="1" m-menu-dropdown-timeout="500">
|
||||
<ul class="m-menu__nav m-menu__nav--dropdown-submenu-arrow ">
|
||||
{% if user_have_coal_group %}
|
||||
<li class="m-menu__item " aria-haspopup="true">
|
||||
<a href="{% url 'main_index' %}" class="m-menu__link ">
|
||||
<i class="m-menu__link-icon flaticon-analytics"></i>
|
||||
<span class="m-menu__link-title">
|
||||
<span class="m-menu__link-wrap">
|
||||
<span class="m-menu__link-text">Уголь</span>
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if user_have_fin_group %}
|
||||
<li class="m-menu__item " aria-haspopup="true">
|
||||
<a href="{% url 'finance:fin_index' %}" class="m-menu__link ">
|
||||
<i class="m-menu__link-icon flaticon-graphic-1"></i>
|
||||
<span class="m-menu__link-title">
|
||||
<span class="m-menu__link-wrap">
|
||||
<span class="m-menu__link-text">Финансы</span>
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -259,7 +345,116 @@
|
||||
src="{% static '/metronic/assets/app/js/dashboard.js' %}?ver={% settings_value 'APP_VERSION' %}"></script>
|
||||
<script src="{% static 'js/main.js' %}?ver={% settings_value 'APP_VERSION' %}"></script>
|
||||
<script src="{% static 'metronic/plugins/apexcharts/dist/apexcharts.js' %}?ver={% settings_value 'APP_VERSION' %}"></script>
|
||||
<script>
|
||||
function getWindDirection(degrees) {
|
||||
// Нормализуем значение углов до диапазона 0-360 градусов
|
||||
degrees = (degrees + 360) % 360;
|
||||
|
||||
if (degrees >= 348.75 || degrees < 11.25) {
|
||||
return "С";
|
||||
} else if (degrees >= 11.25 && degrees < 33.75) {
|
||||
return "С-СВ";
|
||||
} else if (degrees >= 33.75 && degrees < 56.25) {
|
||||
return "СВ";
|
||||
} else if (degrees >= 56.25 && degrees < 78.75) {
|
||||
return "В-СВ";
|
||||
} else if (degrees >= 78.75 && degrees < 101.25) {
|
||||
return "В";
|
||||
} else if (degrees >= 101.25 && degrees < 123.75) {
|
||||
return "В-ЮВ";
|
||||
} else if (degrees >= 123.75 && degrees < 146.25) {
|
||||
return "ЮВ";
|
||||
} else if (degrees >= 146.25 && degrees < 168.75) {
|
||||
return "Ю-ЮВ";
|
||||
} else if (degrees >= 168.75 && degrees < 191.25) {
|
||||
return "Ю";
|
||||
} else if (degrees >= 191.25 && degrees < 213.75) {
|
||||
return "Ю-ЮЗ";
|
||||
} else if (degrees >= 213.75 && degrees < 236.25) {
|
||||
return "ЮЗ";
|
||||
} else if (degrees >= 236.25 && degrees < 258.75) {
|
||||
return "З-ЮЗ";
|
||||
} else if (degrees >= 258.75 && degrees < 281.25) {
|
||||
return "З";
|
||||
} else if (degrees >= 281.25 && degrees < 303.75) {
|
||||
return "З-СЗ";
|
||||
} else if (degrees >= 303.75 && degrees < 326.25) {
|
||||
return "СЗ";
|
||||
} else if (degrees >= 326.25 && degrees < 348.75) {
|
||||
return "С-СЗ";
|
||||
}
|
||||
}
|
||||
|
||||
let meteoBroken = false
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
async function drawMeteoData() {
|
||||
const response = await fetch('/main/meteo/')
|
||||
const json = await response.json()
|
||||
if (Object.keys(json).length === 0) {
|
||||
const marquee = document.querySelector(".marquee-content")
|
||||
if (marquee) {
|
||||
marquee.innerHTML = "Метеостанция не отвечает"
|
||||
}
|
||||
|
||||
document.querySelector(".marquee-content").innerHTML = "Метеостанция не отвечает"
|
||||
|
||||
const widgetTab1 = document.querySelector("#m_portlet_tab_1_1")
|
||||
const widgetTab2 = document.querySelector("#m_portlet_tab_1_2")
|
||||
if (widgetTab1 && widgetTab2) {
|
||||
widgetTab1.innerHTML = "<h4>Метеостанция не отвечает</h4>"
|
||||
widgetTab2.innerHTML = "<h4>Метеостанция не отвечает</h4>"
|
||||
}
|
||||
|
||||
|
||||
meteoBroken = true
|
||||
}
|
||||
if (meteoBroken && Object.keys(json).length !== 0) {
|
||||
window.location.reload()
|
||||
}
|
||||
for (let item in json) {
|
||||
{#if (item === "date" || item === "version" || item === "postId" || item === "aqi") continue#}
|
||||
const elements = document.querySelectorAll(`.meteo_${item}`)
|
||||
for (let element of elements) {
|
||||
if (item === "wda") {
|
||||
const arrows = document.querySelectorAll('.wda-dir')
|
||||
for (let arrow of arrows) {
|
||||
arrow.style.transformOrigin = "center"
|
||||
arrow.style.transform = `scale(1, -1) rotate(${-json[item]}deg)`
|
||||
}
|
||||
element.textContent = `${getWindDirection(json[item])} ( ${parseFloat(json[item]).toFixed(2)}\u00B0 )`
|
||||
continue
|
||||
}
|
||||
element.textContent = parseFloat(json[item]).toFixed(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await drawMeteoData()
|
||||
setInterval(drawMeteoData, 30000)
|
||||
})
|
||||
|
||||
</script>
|
||||
<script>
|
||||
document.getElementById("chargerLink").addEventListener("click", () => {
|
||||
const data = new URLSearchParams();
|
||||
data.append('grant_type', 'password');
|
||||
data.append('username', '{{ charger_username }}');
|
||||
data.append('password', '{{ charger_password }}');
|
||||
|
||||
fetch('https://rp.cofkk.ru/api/v1/auth/token/app', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: data
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => localStorage.setItem("ihmi_user_token", data["access_token"]))
|
||||
.catch(error => console.error('Ошибка:', error));
|
||||
|
||||
})
|
||||
</script>
|
||||
{% block script_footer %}{% endblock script_footer %}
|
||||
|
||||
</body>
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Register your models here.
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from .models import Profile
|
||||
from .user_login import UserLogin
|
||||
|
||||
|
||||
class UserInline(admin.StackedInline):
|
||||
|
||||
model = Profile
|
||||
can_delete = False
|
||||
verbose_name_plural = "Параметры пользователя"
|
||||
verbose_name_plural = 'Параметры пользователя'
|
||||
|
||||
|
||||
# Определяем новый класс настроек для модели User
|
||||
@ -20,7 +20,7 @@ class UserAdmin(UserAdmin):
|
||||
|
||||
|
||||
class ProfileAdmin(admin.ModelAdmin):
|
||||
list_display = ("user",)
|
||||
list_display = ('user',)
|
||||
|
||||
|
||||
# Перерегистрируем модель User
|
||||
@ -28,3 +28,8 @@ admin.site.unregister(User)
|
||||
admin.site.register(User, UserAdmin)
|
||||
|
||||
# admin.site.register(Profile,ProfileAdmin)
|
||||
|
||||
|
||||
@admin.register(UserLogin)
|
||||
class UserLoginAdmin(admin.ModelAdmin):
|
||||
list_display = ['user', 'login_time', 'logout_time']
|
||||
|
||||
43
app/users/migrations/0002_userlogin.py
Normal file
43
app/users/migrations/0002_userlogin.py
Normal file
@ -0,0 +1,43 @@
|
||||
# Generated by Django 3.2.25 on 2025-04-10 01:27
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('users', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='UserLogin',
|
||||
fields=[
|
||||
(
|
||||
'id',
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name='ID',
|
||||
),
|
||||
),
|
||||
('login_time', models.DateTimeField(auto_now_add=True)),
|
||||
('logout_time', models.DateTimeField(blank=True, null=True)),
|
||||
(
|
||||
'user',
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Вход пользователя',
|
||||
'verbose_name_plural': 'Входы пользователей',
|
||||
},
|
||||
),
|
||||
]
|
||||
37
app/users/user_login.py
Normal file
37
app/users/user_login.py
Normal file
@ -0,0 +1,37 @@
|
||||
from apps.main.services.base_service import DashboardBaseService
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.signals import user_logged_in, user_logged_out
|
||||
from django.db import models
|
||||
from django.dispatch import receiver
|
||||
|
||||
|
||||
class UserLogin(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
login_time = models.DateTimeField(auto_now_add=True)
|
||||
logout_time = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.user.username} logged in at {self.login_time}'
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Вход пользователя'
|
||||
verbose_name_plural = 'Входы пользователей'
|
||||
|
||||
|
||||
@receiver(user_logged_in)
|
||||
def log_user_login(sender, request, user, **kwargs):
|
||||
UserLogin.objects.create(user=user)
|
||||
|
||||
|
||||
@receiver(user_logged_out)
|
||||
def log_user_logout(sender, request, user, **kwargs):
|
||||
if user:
|
||||
print(f'Пользователь {user.username} вышел из системы.')
|
||||
try:
|
||||
rec = UserLogin.objects.filter(user=user, logout_time__isnull=True).latest(
|
||||
'login_time'
|
||||
)
|
||||
rec.logout_time = DashboardBaseService.get_current_time()
|
||||
rec.save()
|
||||
except UserLogin.DoesNotExist:
|
||||
return
|
||||
@ -1,33 +1,33 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
# web:
|
||||
# image: repcofkk:latest
|
||||
# build: ./app
|
||||
# command: gunicorn --workers=2 repcofkk.wsgi:application --bind 0.0.0.0:8000
|
||||
# ports:
|
||||
# - '8000:8000'
|
||||
# expose:
|
||||
# - 8000
|
||||
# env_file:
|
||||
# - .env
|
||||
# depends_on:
|
||||
# postgres:
|
||||
# condition: service_healthy
|
||||
# volumes:
|
||||
# - ./app/static:/home/app/web/static/
|
||||
web:
|
||||
image: repcofkk:latest
|
||||
build: ./app
|
||||
command: gunicorn --workers=2 repcofkk.wsgi:application --bind 0.0.0.0:8000
|
||||
ports:
|
||||
- '8000:8000'
|
||||
expose:
|
||||
- 8000
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./app/static:/home/app/web/static/
|
||||
# - ./app:/home/app/web/
|
||||
#
|
||||
# nginx:
|
||||
# build: ./nginx/dev
|
||||
# volumes:
|
||||
# - ./app/static/:/home/app/web/static/
|
||||
# ports:
|
||||
# - "80:80"
|
||||
# - "443:443"
|
||||
# depends_on:
|
||||
# web:
|
||||
# condition: service_started
|
||||
|
||||
nginx:
|
||||
build: ./nginx/dev
|
||||
volumes:
|
||||
- ./app/static/:/home/app/web/static/
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
depends_on:
|
||||
web:
|
||||
condition: service_started
|
||||
|
||||
celery:
|
||||
image: repcofkk:latest
|
||||
@ -38,6 +38,8 @@ services:
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_started
|
||||
|
||||
@ -49,6 +51,8 @@ services:
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_started
|
||||
|
||||
|
||||
@ -8,12 +8,10 @@ services:
|
||||
sh -c "
|
||||
python manage.py makemigrations --noinput &&
|
||||
python manage.py migrate --noinput &&
|
||||
gunicorn --workers=2 repcofkk.wsgi:application --bind 0.0.0.0:8000
|
||||
gunicorn --workers=2 repcofkk.wsgi:application --bind 0.0.0.0:80
|
||||
"
|
||||
ports:
|
||||
- '8000:8000'
|
||||
expose:
|
||||
- 8000
|
||||
- '8095:80'
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
@ -21,6 +19,7 @@ services:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./app/static:/home/app/web/static/
|
||||
- ./app/log:/home/app/web/log/
|
||||
restart: always
|
||||
|
||||
celery:
|
||||
@ -90,29 +89,6 @@ services:
|
||||
- CELERY_BROKER_URL=redis://redis:6379/0
|
||||
restart: always
|
||||
|
||||
nginx:
|
||||
build: ./nginx/prod
|
||||
volumes:
|
||||
- ./app/static/:/home/app/web/static/
|
||||
- /etc/letsencrypt/:/etc/letsencrypt/
|
||||
- /certbot/www:/var/www/certbot
|
||||
- ./nginx/prod/options-ssl-nginx.conf:/etc/letsencrypt/options-ssl-nginx.conf
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
depends_on:
|
||||
web:
|
||||
condition: service_started
|
||||
restart: always
|
||||
|
||||
certbot:
|
||||
image: certbot/certbot
|
||||
volumes:
|
||||
- ./certbot/conf:/etc/letsencrypt
|
||||
- ./certbot/www:/var/www/certbot
|
||||
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user