w
This commit is contained in:
commit
4716effcf7
309 files changed
+153369
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,25 @@
|
||||
# ! Запросы для создания форинов в проекте
|
||||
|
||||
# TRUNCATE TABLE public.projectstatuses CASCADE;
|
||||
# INSERT INTO public.projectstatuses (name) VALUES ('Черновик'),('На согласовании'),('Утвержден'),('Отклонен'),('В работе'),('Приостановлен'),('Завершен');
|
||||
|
||||
# TRUNCATE TABLE public.taskstatuses CASCADE;
|
||||
# INSERT INTO public.taskstatuses (name) VALUES ('Черновик'),('В работе'),('Приостановлена'),('На проверке'),('Завершена');
|
||||
|
||||
# TRUNCATE TABLE public.assignmentstatuses CASCADE;
|
||||
# INSERT INTO public.assignmentstatuses (name) VALUES ('Черновик'),('Назначено'),('В работе'),('Приостановлено'),('На проверке'),('Завершено');
|
||||
|
||||
|
||||
# TRUNCATE TABLE public.projecttypes CASCADE;
|
||||
# INSERT INTO public.projecttypes (name) VALUES ('Стратегический'),('Оперативный');
|
||||
# ! Тестовый проект
|
||||
# TE TABLE public.projectroles CASCADE;
|
||||
# INSERT INTO public.projectroles (name) VALUES ('Директор'),('Руководитель проекта'),('Секретарь'),('Координатор'),('Участник'),('Наблюдатель');
|
||||
|
||||
# TRUNCATE TABLE public.historyactions CASCADE;
|
||||
# INSERT INTO public.historyactions (name) VALUES ('Создание'),('Изменение'),('Удаление');
|
||||
# TRUNCATE TABLE public.historylevels CASCADE;
|
||||
# INSERT INTO public.historylevels (name) VALUES ('Проект'),('Задача'),('Работа'),('Поручение');
|
||||
|
||||
# TRUNCATE TABLE public.doctypes CASCADE;
|
||||
# INSERT INTO public.doctypes (name) VALUES ('Приказ'),('Паспорт'),('Состав РГ'),('План'),('План КС'),('Отчет'),('Итог'),('Протокол');
|
||||
@@ -0,0 +1,373 @@
|
||||
from email.policy import default
|
||||
from typing import Optional
|
||||
from datetime import date, datetime
|
||||
from ormar import pre_delete
|
||||
from ormar import Integer,JSON, String, Boolean, ForeignKey, Model, ModelMeta, ManyToMany, Date, Text, DateTime, pre_save, pre_update, property_field,UniqueColumns
|
||||
from conf.sessions import database, metadata
|
||||
from enum import Enum
|
||||
import pydantic
|
||||
|
||||
# *-------------------- Base --------------------* #
|
||||
async def change_lastchanged(sender,instance):
|
||||
# print(sender)
|
||||
# print(instance.id)
|
||||
ttoup=await Project.objects.get(id=instance.id)
|
||||
|
||||
upit = {'lastchanged':datetime.now()}
|
||||
|
||||
# if instance.datestart and (not ttoup.datestart or instance.datestart < ttoup.datestart):
|
||||
# upit['datestart'] = instance.datestart
|
||||
# if instance.dateend and (not ttoup.dateend or instance.dateend < ttoup.dateend):
|
||||
# upit['dateend'] = instance.dateend
|
||||
await ttoup.update(**upit)
|
||||
|
||||
|
||||
class BaseId():
|
||||
"""
|
||||
Базовый класс, добавляющий в дочерние Первичный ключ ID
|
||||
"""
|
||||
id: int = Integer(primary_key=True)
|
||||
|
||||
class BaseMeta(ModelMeta):
|
||||
"""
|
||||
Обязательно к добавлению во все таблицы
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
"""
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
# !-------------------- User --------------------! #
|
||||
# *-------------------- Foreign Key --------------------* #
|
||||
class Organization(Model, BaseId):
|
||||
name: str = String(max_length=500, unique=True)
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
class Department(Model, BaseId):
|
||||
name: str = String(max_length=100, sql_nullable=True, unique=True)
|
||||
postal_code = String(max_length=100,sql_nullable=True, nullable=True)
|
||||
city = String(max_length=200,sql_nullable=True, nullable=True)
|
||||
region = String(max_length=200,sql_nullable=True, nullable=True)
|
||||
street = String(max_length=200,sql_nullable=True, nullable=True)
|
||||
# organization: Organization=ForeignKey(Organization,sql_nullable=True, nullable=True, related_name = "organization_department")
|
||||
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
|
||||
class Otdel(Model, BaseId):
|
||||
name: str = String(max_length=200, unique=True)
|
||||
shortname: str = String(max_length=7, nullable=True, default="")
|
||||
# department:Department=ForeignKey(Department,sql_nullable=True, nullable=True, related_name = "department_otdel")
|
||||
|
||||
class Meta(BaseMeta):
|
||||
tablename = "otdels"
|
||||
...
|
||||
|
||||
class Position(Model, BaseId):
|
||||
name: str = String(max_length=100, unique=True)
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
|
||||
class Rank(Model, BaseId):
|
||||
name: str = String(max_length=100, unique=True)
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
|
||||
|
||||
|
||||
# *-------------------- Base --------------------* #
|
||||
|
||||
class User(Model, BaseId):
|
||||
|
||||
username: str = String(max_length=250, unique=True,sql_nullable=False,nullable=True)
|
||||
givenName: str = String(max_length=250, sql_nullable=False,nullable=True )
|
||||
sn: str = String(max_length=100,sql_nullable=False,nullable=True)
|
||||
telephoneNumber: Optional[str] = String(max_length=100, sql_nullable=True,nullable=True)
|
||||
phone: Optional[str] = String(max_length=50,sql_nullable=True, nullable=True)
|
||||
email: Optional[str] = String(max_length=250, unique=True,sql_nullable=True, nullable=True)
|
||||
otdel: Otdel = ForeignKey(Otdel,sql_nullable=True, nullable=True, related_name = "otdel_user")
|
||||
department: Department = ForeignKey(Department, nullable=True, sql_nullable=True, related_name = "department_user")
|
||||
organization:Organization=ForeignKey(Organization)
|
||||
position: Position = ForeignKey(Position, nullable=True,sql_nullable=True,)
|
||||
physicalDeliveryOfficeName: Optional[str]=String(max_length=100, sql_nullable=True, nullable=True)
|
||||
# hardskills: Optional[list[UserHardSkill]] = ManyToMany(HardSkill,through=UserHardSkill)
|
||||
# softskills: Optional[list[UserSoftSkill]] = ManyToMany(SoftSkill,through=UserSoftSkill)
|
||||
avatar=Text(nullable=True,default="/static/default/avatardef.png")
|
||||
rank: Rank = ForeignKey(Rank,nullable=True,sql_nullable=True)
|
||||
active: bool = Boolean(default=True)
|
||||
superuser: bool = Boolean(default=False)
|
||||
# ! ВОЗможно потом сделаем проверку по последнему входу - так будет ясно, надо-ли обновлять пользователя в AD
|
||||
# last_login: Optional[datetime]= DateTime(default=datetime.now())
|
||||
@property_field
|
||||
def fullname(self)-> str:
|
||||
return f'{self.sn} {self.givenName}'
|
||||
|
||||
class Meta(BaseMeta):
|
||||
include_props_in_dict = True
|
||||
...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# !-------------------- Project --------------------! #
|
||||
# *-------------------- Foreign Key --------------------* #
|
||||
|
||||
class DocType(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
name:str = String(max_length=100,unique=True)
|
||||
|
||||
|
||||
class ProjectStatus(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
tablename: str = "projectstatuses"
|
||||
name:str = String(max_length=100,unique=True, sql_nullable=False,nullable=True)
|
||||
|
||||
|
||||
class ProjectType(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
name:str = String(max_length=100,unique=True,sql_nullable=False,nullable=True)
|
||||
|
||||
# *-------------------- Base --------------------* #
|
||||
|
||||
class Projectrole(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
name:str = String(max_length=100,unique=True,sql_nullable=False,nullable=True)
|
||||
|
||||
|
||||
|
||||
class Project(Model, BaseId):
|
||||
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
name: Optional[str] = String(max_length=255, sql_nullable=True,nullable=True)
|
||||
longname: Optional[str] = String(max_length=500, sql_nullable=True,nullable=True)
|
||||
status: Optional[ProjectStatus] = ForeignKey(ProjectStatus,nullable=True, sql_nullable=True)
|
||||
author: User = ForeignKey(User, related_name = "author_user",sql_nullable=False,nullable=True)
|
||||
datestart: Optional[date] = Date(sql_nullable=True,nullable=True, default=date.today())
|
||||
dateend: Optional[date] = Date(sql_nullable=True,nullable=True, default=date.today())
|
||||
lastchanged: Optional[datetime] = DateTime(nullable=True)
|
||||
ptype: Optional[ProjectType] = ForeignKey(ProjectType)
|
||||
difficult: int= Integer(default=3)
|
||||
info: Optional[JSON]=JSON(nullable=True, sql_nullable=True)
|
||||
|
||||
|
||||
|
||||
|
||||
class ProjectUser(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
constraints = [UniqueColumns("project","user","role")]
|
||||
...
|
||||
user: User = ForeignKey(User)
|
||||
project: Project = ForeignKey(Project, related_name="user_project")
|
||||
role: Projectrole =ForeignKey(Projectrole)
|
||||
involved:Optional[Boolean] = Boolean(default=False)
|
||||
percent: Optional[int] = Integer(sql_nullable=True,nullable=True, default=0)
|
||||
|
||||
class ChatUser(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
|
||||
...
|
||||
|
||||
class Chat(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
constraints = [UniqueColumns("level","parent")]
|
||||
...
|
||||
name: str = Text(nullable=True)
|
||||
users: Optional[list[ProjectUser]] = ManyToMany(User, through=ChatUser, related_name = "chat_x_user")
|
||||
level: int= Integer(default=0,minimum=0, maximum=4, nullable=True)
|
||||
# Проект -1, задача - 2, работа = 3, поручение 4
|
||||
parent: int=Integer(minimum=0,nullable=True)
|
||||
admin: User = ForeignKey(User,nullable=True)
|
||||
|
||||
|
||||
|
||||
|
||||
class ChatMessage(Model,BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
chat: Chat = ForeignKey(Chat, related_name="chat_message", ondelete="CASCADE")
|
||||
sender: User = ForeignKey(User)
|
||||
text: str = Text()
|
||||
messagetime: Optional[datetime]= DateTime(default=datetime.now)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# *-------------------- Documentation --------------------* #
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Documentation(Model, BaseId):
|
||||
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
project: Project = ForeignKey(Project, related_name="project_doc")
|
||||
doctype: DocType = ForeignKey(DocType)
|
||||
docnumber: Optional[str]= String(max_length=100, nullable=True)
|
||||
created: datetime = DateTime()
|
||||
vrersion = JSON()
|
||||
comment:str = Text(nullable=True)
|
||||
approved: int= Integer(default=0,minimum=0, maximum=4)
|
||||
approver: User = ForeignKey(User,nullable=True)
|
||||
approvedtime: Optional[datetime]= DateTime(nullable=True)
|
||||
path: Optional[str]= String(max_length=400, nullable=True)
|
||||
# согласованность: 0 = не утверждено, 1 -отправлено на утверждение, 2 - утверждено
|
||||
|
||||
class DocUser(Model,BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
user: User = ForeignKey(User)
|
||||
comment:str = Text(nullable=True)
|
||||
accepted: int= Integer(default=0,minimum=0, maximum=4)
|
||||
acceptedtime: Optional[datetime]= DateTime(nullable=True)
|
||||
doc: Documentation = ForeignKey(Documentation, related_name="doc_user", ondelete="CASCADE")
|
||||
|
||||
|
||||
|
||||
# *-------------------- History --------------------* #
|
||||
|
||||
class HistoryAction(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
name: str = String(max_length=100,unique=True)
|
||||
|
||||
|
||||
# !-------------------- Task --------------------! #
|
||||
# *-------------------- Foreign Key --------------------* #
|
||||
|
||||
class TaskStatus(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
tablename: str = "taskstatuses"
|
||||
name:str = String(max_length=100,unique=True)
|
||||
|
||||
class TaskStage(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
name:str = String(max_length=500,unique=True)
|
||||
|
||||
# *-------------------- Base --------------------* #
|
||||
|
||||
|
||||
class Task(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
parent: Project = ForeignKey(Project, related_name = "project_task",sql_nullable=True, nullable=True, ondelete="CASCADE")
|
||||
longname: Optional[str] = String(max_length=500, sql_nullable=True,nullable=True)
|
||||
name: Optional[str] = String(max_length=500, sql_nullable=True, nullable=True)
|
||||
status: TaskStatus = ForeignKey(TaskStatus, sql_nullable=True,nullable=True,)
|
||||
description: Optional[Text] = Text(nullable=True)
|
||||
datestart: Optional[date] = Date(nullable=True)
|
||||
dateend: Optional[date] = Date(nullable=True)
|
||||
responsible: Optional[User] = ForeignKey(User, nullable=True, related_name = "responsible_user")
|
||||
lastchanged: Optional[datetime] = DateTime(default=datetime.now)
|
||||
difficult: int= Integer(default=3)
|
||||
# comment: Optional[JSON]=JSON(nullable=True,default=[])
|
||||
|
||||
|
||||
class Work(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
parent: Task = ForeignKey(Task, related_name = "task_work", ondelete="CASCADE")
|
||||
name: Optional[str] = String(max_length=500, sql_nullable=False,nullable=True)
|
||||
longname: Optional[str] = String(max_length=500, sql_nullable=True,nullable=True)
|
||||
status: TaskStatus = ForeignKey(TaskStatus, sql_nullable=True,nullable=True)
|
||||
responsible: User = ForeignKey(User, nullable=True, related_name = "work_responsible_user")
|
||||
description: Optional[Text] = Text(nullable=True)
|
||||
datestart: Optional[date] = Date(nullable=True)
|
||||
dateend: Optional[date] = Date(nullable=True)
|
||||
lastchanged: Optional[datetime] = DateTime(default=datetime.now())
|
||||
difficult: int= Integer(default=3)
|
||||
# comment: Optional[JSON]=JSON(nullable=True,default=[])
|
||||
|
||||
|
||||
|
||||
# !-------------------- Assignment --------------------! #
|
||||
# *-------------------- Foreign Key --------------------* #
|
||||
|
||||
class AssignmentStatus(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
tablename: str = "assignmentstatuses"
|
||||
name: str = String(max_length=100,unique=True)
|
||||
|
||||
# *-------------------- Base --------------------* #
|
||||
|
||||
class Assignment(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
author: User = ForeignKey(User, related_name="assignment_author",nullable=True)
|
||||
parent = ForeignKey(Work, related_name="work_assignment", ondelete="CASCADE", sql_nullable=False,nullable=True)
|
||||
name: str = String(max_length=255, sql_nullable=False,nullable=True)
|
||||
longname: Optional[str] = String(max_length=500, sql_nullable=True,nullable=True)
|
||||
responsible: User = ForeignKey(User,nullable=True, related_name = "ass_responsible_user")
|
||||
status: Optional[AssignmentStatus] = ForeignKey(AssignmentStatus, sql_nullable=False,nullable=True)
|
||||
datestart: Optional[date] = Date(nullable=True)
|
||||
dateend: Optional[date] = Date(nullable=True)
|
||||
timeneeded: Optional[int] = Integer(default=0)
|
||||
lastchanged: Optional[datetime] = DateTime(default=datetime.now())
|
||||
description: Optional[str] = Text(nullable=True)
|
||||
getstarted:Optional[datetime] = DateTime(nullable=True)
|
||||
difficult: int= Integer(default=3)
|
||||
info: Optional[JSON]=JSON(nullable=True, sql_nullable=True)
|
||||
# comment: Optional[JSON]=JSON(nullable=True,default=[])
|
||||
|
||||
|
||||
# *-------------------- Files --------------------* #
|
||||
class ProjectHistory(Model, BaseId):
|
||||
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
|
||||
author: User = ForeignKey(User)
|
||||
info: Optional[JSON]=JSON(nullable=True, sql_nullable=True)
|
||||
project: int= Integer()
|
||||
task: int= Integer(nullable=True, sql_nullable=True)
|
||||
work: int= Integer(nullable=True, sql_nullable=True)
|
||||
assignment: int= Integer(nullable=True, sql_nullable=True)
|
||||
action: HistoryAction = ForeignKey(HistoryAction)
|
||||
createdate: datetime = DateTime(default=datetime.now)
|
||||
level:int=Integer(default=1)
|
||||
comment: Optional[Text] = Text(nullable=True, sql_nullable=True)
|
||||
|
||||
|
||||
class Projectfile(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
project:Project=ForeignKey(Project, nullable=True, related_name='project_files')
|
||||
task:Task = ForeignKey(Task,nullable=True, related_name='task_files')
|
||||
work:Work=ForeignKey(Work,nullable=True, related_name="work_files")
|
||||
assignment: Assignment = ForeignKey(Assignment, nullable=True, related_name="assignment_files")
|
||||
sender: User = ForeignKey(User)
|
||||
datetime: datetime = DateTime()
|
||||
filepath: str = Text()
|
||||
visible:str=String(max_length=5,nullable=True,)
|
||||
counter:int=Integer(sql_nullable=True,default=0)
|
||||
|
||||
class ProjectCheckpoint(Model, BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
project:Project=ForeignKey(Project, nullable=True, related_name='project_checkpoints')
|
||||
checkpoint: date = Date(nullable=True)
|
||||
|
||||
class UserRating(Model,BaseId):
|
||||
class Meta(BaseMeta):
|
||||
...
|
||||
user: User = ForeignKey(User, related_name = "user_score",sql_nullable=False,nullable=True)
|
||||
rating: int= Integer(default=0)
|
||||
level: int=Integer(default=0)
|
||||
project:Project=ForeignKey(Project, nullable=True, related_name='project_score')
|
||||
task:Task = ForeignKey(Task,nullable=True, related_name='task_score')
|
||||
work:Work=ForeignKey(Work,nullable=True, related_name="work_score")
|
||||
assignment: Assignment = ForeignKey(Assignment, nullable=True, related_name="assignment_score")
|
||||
author: User = ForeignKey(User, related_name = "user_authorrating",sql_nullable=False,nullable=True)
|
||||
createdate: datetime = DateTime(default=datetime.now)
|
||||
|
||||
# !-------------------- Event --------------------! #
|
||||
@@ -0,0 +1,113 @@
|
||||
import asyncio
|
||||
from types import FunctionType
|
||||
|
||||
from aioredis.client import PubSub, Redis
|
||||
from fastapi import (
|
||||
WebSocket,
|
||||
WebSocketDisconnect
|
||||
)
|
||||
|
||||
from conf.sessions import get_redis_pool
|
||||
# from conf.log import logger
|
||||
import json
|
||||
|
||||
class RedisWorker:
|
||||
""" Обработчик редис запросов """
|
||||
|
||||
@classmethod
|
||||
async def create_channels(cls, ws: WebSocket, consumer: FunctionType = None, channels=("main",), save_info: dict=None):
|
||||
|
||||
""" Создает каналы, для асинхронной отправки сообщений
|
||||
|
||||
Args:
|
||||
ws (WebSocket): Клиентский сокет
|
||||
consumer (Function): Функция обработки принятого сообщения
|
||||
channels (tuple): Список каналов для подключения
|
||||
|
||||
Raises:
|
||||
WebSocketDisconnect: [
|
||||
Отключение сокета ->
|
||||
отправляяет сообщение для остановки бесконечного цикла и отписывает пользователя от канала
|
||||
]
|
||||
"""
|
||||
|
||||
conn: Redis = await get_redis_pool()
|
||||
if save_info:
|
||||
for channel, info in save_info.items():
|
||||
|
||||
await conn.set(channel, json.dumps(info))
|
||||
pubsub = conn.pubsub()
|
||||
|
||||
async def consumer_handler(conn: Redis, ws: WebSocket, channels: tuple, save_info: dict):
|
||||
""" Публикует каналы в редис
|
||||
|
||||
Args:
|
||||
conn (Redis): Подключение редис
|
||||
ws (WebSocket): Клиентский сокет
|
||||
channels (tuple): Список каналов для подключения
|
||||
"""
|
||||
try:
|
||||
while True:
|
||||
message = await ws.receive_text()
|
||||
if message:
|
||||
if consumer:
|
||||
result: dict = await consumer(message, conn)
|
||||
|
||||
for (channel, answer) in result.items():
|
||||
await conn.publish(channel, answer)
|
||||
|
||||
except WebSocketDisconnect:
|
||||
|
||||
if save_info:
|
||||
for channel in save_info.keys():
|
||||
await conn.delete(channel)
|
||||
await conn.publish(channels[0], "StopSocket")
|
||||
print(f"close {channels[0]}")
|
||||
await conn.close()
|
||||
return
|
||||
|
||||
|
||||
async def producer_handler(pubsub: PubSub, ws: WebSocket, channels: tuple):
|
||||
""" Рассылает сообщение пользователям в зависимости от канала
|
||||
|
||||
Args:
|
||||
pubsub (PubSub): Публикации, подписанных на канал
|
||||
ws (WebSocket): Клиентский сокет
|
||||
channels (tuple): Список каналов для подключения
|
||||
|
||||
Raises:
|
||||
WebSocketDisconnect: кидаем исключение при получение сообщения об отключении сокета
|
||||
"""
|
||||
|
||||
await pubsub.subscribe(*channels)
|
||||
|
||||
try:
|
||||
while True:
|
||||
message = await pubsub.get_message(ignore_subscribe_messages=True)
|
||||
|
||||
if message:
|
||||
# print(message,"message")
|
||||
if message.get('data') == "StopSocket":
|
||||
raise WebSocketDisconnect()
|
||||
|
||||
await ws.send_text(message.get('data'))
|
||||
|
||||
|
||||
except WebSocketDisconnect:
|
||||
await pubsub.unsubscribe()
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
# logger.exception(e)
|
||||
|
||||
|
||||
consumer_task = consumer_handler(conn=conn, ws=ws, channels=channels, save_info=save_info)
|
||||
producer_task = producer_handler(pubsub=pubsub, ws=ws, channels=channels)
|
||||
|
||||
done, pending = await asyncio.wait(
|
||||
[consumer_task, producer_task], return_when=asyncio.FIRST_COMPLETED,
|
||||
)
|
||||
|
||||
for task in pending:
|
||||
task.cancel()
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# SCHEMA_REDIS = {
|
||||
# "Реестр проектов": {
|
||||
# "given_repr_route": {"Список проектов", "Количество завершенных задач", "Общее количество задач"},
|
||||
# "given_repr_user": {"Календарь топ", "Оповещения"},
|
||||
# "change_repr": {}
|
||||
# },
|
||||
# "Реестр задач проекта": {
|
||||
# "given_repr_route": {"Список задач", "Количество завершенных поручений", "Общее количество поручений"},
|
||||
# "given_repr_user": {"Календарь топ", "Оповещения"},
|
||||
# "change_repr": {}
|
||||
# },
|
||||
# "Проект": {
|
||||
# "given_repr_route": {"Информацию по проекту", "Список задач","История проекта", "История задач", "История поручений"},
|
||||
# "given_repr_user": {"Календарь топ", "Оповещения"},
|
||||
# "change_repr": {"Список проектов", "История проекта"}
|
||||
# },
|
||||
# "Задача": {
|
||||
# "given_repr_route": {"Информацию по задаче", "Информация о поручениях", "Чаты", "Файлы", "История задачи", "История поручений"},
|
||||
# "given_repr_user": {"Календарь топ", "Оповещения"},
|
||||
# "change_repr": {
|
||||
# "Количество завершенных задач", "Общее количество задач", "Список задач", "Количество завершенных поручений",
|
||||
# "Общее количество поручений", "История задач", "История поручений", "Календарь топ", "Календарь"
|
||||
# }
|
||||
# }
|
||||
|
||||
|
||||
|
||||
# }
|
||||
|
||||
|
||||
SCHEMA_REDIS_KEYS ={
|
||||
"users:user/id": "Ключ пользователя со всей его информацией"
|
||||
}
|
||||
@@ -0,0 +1,447 @@
|
||||
from datetime import datetime
|
||||
import email
|
||||
from email import message
|
||||
from lib2to3.pytree import Base
|
||||
from .models import *
|
||||
from pydantic import BaseModel, Json
|
||||
from typing import List, Optional
|
||||
from pydantic_computed import Computed, computed
|
||||
|
||||
# *-------------------- User schema --------------------* #
|
||||
# class Restore_U(BaseModel):
|
||||
# email: str
|
||||
# lotus_key:str
|
||||
# password:str
|
||||
|
||||
class Codeconfirm(BaseModel):
|
||||
action:str
|
||||
email:Optional[str]
|
||||
|
||||
|
||||
class UserLogin(BaseModel):
|
||||
username:str
|
||||
password: str
|
||||
email:Optional[str]
|
||||
|
||||
create_user = {"username", "givenName", "sn", "telephoneNumber", "otdel__name", "position__name", "rank__name", "superuser",'department__name','department__postal_code','department__city','department__region','department__street' ,'organization__name', 'physicalDeliveryOfficeName'}
|
||||
claim_user = {'id',"sn","username", "givenName","telephoneNumber","email","department__name","department__id", "otdel__name","otdel__id", "position__name", "rank__name", "organization__id", "organization__name", "superuser"}
|
||||
create_user_mult = {"first_name", "last_name", "middle_name", "innerphone","email", "otdel__name", "position__name", "rank__name",'department__name','organization__name'}
|
||||
|
||||
UserMultiUpload = User.get_pydantic(include=create_user_mult)
|
||||
UserRegister = User.get_pydantic(include=create_user)
|
||||
|
||||
# UserLogin = User.get_pydantic(include={"username", "password"})
|
||||
UserLoad = User.get_pydantic(exclude={"password",})
|
||||
# UserList = User.get_pydantic(include={"id", "first_name","middle_name","last_name","otdel__name"})
|
||||
|
||||
|
||||
|
||||
class UserList(BaseModel):
|
||||
id: int
|
||||
given_name: str
|
||||
# middle_name: str
|
||||
last_name: str
|
||||
otdel: Otdel
|
||||
|
||||
|
||||
# ProjectCreate = Project.get_pydantic(include={"id","name", "description", "status__id", "customer", "author__id", "leader__id", "users__id", "lastchanged"})
|
||||
class UserFullName(BaseModel):
|
||||
sn:str
|
||||
givenName:str
|
||||
fullname: Computed[str]
|
||||
position: Optional[Position]
|
||||
|
||||
|
||||
@computed('fullname')
|
||||
def fullnamed(sn:str, givenName:str):
|
||||
return f'{sn} {givenName}'
|
||||
|
||||
class UserProjectFullName(UserFullName):
|
||||
id:int
|
||||
|
||||
class UserFullInfo(UserProjectFullName):
|
||||
username:Optional[str]
|
||||
telephoneNumber:Optional[str]
|
||||
phone:Optional[str]
|
||||
email:Optional[str]
|
||||
otdel:Optional[Otdel.get_pydantic(include={"id","name"})]
|
||||
department:Optional[Department.get_pydantic(include={"id","name"})]
|
||||
organization:Optional[Organization.get_pydantic(include={"id","name"})]
|
||||
position:Optional[Position.get_pydantic(include={"id","name"})]
|
||||
avatar:Optional[str]
|
||||
physicalDeliveryOfficeName: Optional[str]
|
||||
|
||||
|
||||
class GetFilters():
|
||||
filters: List
|
||||
|
||||
class ProjectHistoryModel(BaseModel):
|
||||
id:int
|
||||
text: str
|
||||
createdate: datetime
|
||||
action: dict
|
||||
author: User.get_pydantic(include={"id","sn"})
|
||||
level: dict
|
||||
|
||||
|
||||
class BaseCreateProjectTask(BaseModel):
|
||||
name: Optional[str]
|
||||
longname: Optional[str]
|
||||
datestart: Optional[date]
|
||||
dateend: Optional[date]
|
||||
# description: Optional[str]
|
||||
|
||||
|
||||
class ProjectCreate(BaseCreateProjectTask):
|
||||
status: Optional[ProjectStatus.get_pydantic(include={"id"})]
|
||||
author: Optional[User.get_pydantic(include={"id"})]
|
||||
|
||||
info: Optional[dict]
|
||||
|
||||
|
||||
users: Optional[list]
|
||||
lastchanged: Optional[datetime] = datetime.now()
|
||||
|
||||
ptype:Optional[ProjectType.get_pydantic(include={"id"})]
|
||||
|
||||
|
||||
|
||||
|
||||
class ProjectUpdate(ProjectCreate):
|
||||
# watchers:Optional[list[ProjectUser.get_pydantic(include={"id"})]]
|
||||
id: int
|
||||
|
||||
|
||||
idname = {"id","givenName", "sn"}
|
||||
# ProjectUser.get_pydantic(include={"id","involved","user__id","user","user__sn"})
|
||||
class ProjectGet(BaseCreateProjectTask):
|
||||
id:int
|
||||
status: Optional[ProjectStatus.get_pydantic(include={"id","name"})]
|
||||
pcode: Optional[str]
|
||||
project_task:Optional[list[Task.get_pydantic(include={"id"})]]
|
||||
ptype:Optional[ProjectType.get_pydantic(include={"id","name"})]
|
||||
author: Optional[User.get_pydantic(include={"id"})]
|
||||
# director:Optional[User.get_pydantic(include={"id"})]
|
||||
# secretary:Optional[User.get_pydantic(include={"id"})]
|
||||
# rp: Optional[User.get_pydantic(include={"id"})]
|
||||
users: Optional[list]
|
||||
difficult: Optional[int]
|
||||
info:Optional[dict]
|
||||
# watchers:Optional[list]
|
||||
# coordinator:Optional[User.get_pydantic(include={"id"})]
|
||||
|
||||
class ProjectUserSchema(BaseModel):
|
||||
role:Projectrole.get_pydantic(include={"id","name"})
|
||||
user:User.get_pydantic(include={"id"})
|
||||
percent: Optional[int]
|
||||
class ProjectReestrUserSchema(BaseModel):
|
||||
role:Projectrole.get_pydantic(include={"id"})
|
||||
user:User.get_pydantic(include={"id","sn"})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ProjectReestrSchema(BaseModel):
|
||||
id:int
|
||||
name: Optional[str]
|
||||
datestart: Optional[date]
|
||||
dateend: Optional[date]
|
||||
lastchanged:Optional[datetime]
|
||||
status:ProjectStatus.get_pydantic(include={"id","name"})
|
||||
user_project: Optional[list[ProjectReestrUserSchema]]
|
||||
project_task:Optional[list[Task.get_pydantic(include={"id","name","status__id","dateend","status__name","responsible","responsible__sn"})]]
|
||||
# role:Projectrole.get_pydantic(include={"id","name"})
|
||||
# user:User.get_pydantic(include={"id",'name'})
|
||||
|
||||
class TaskReestrSchema(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
parent:Project.get_pydantic(include={"id"})
|
||||
datestart: Optional[date]
|
||||
dateend: Optional[date]
|
||||
lastchanged:Optional[datetime]
|
||||
status:TaskStatus.get_pydantic(include={"id","name"})
|
||||
responsible: Optional[User.get_pydantic(include={"id","sn"})]
|
||||
task_work: Optional[list[Work.get_pydantic(include={"id","name","status__id","dateend","status__name","responsible","responsible__sn"})]]
|
||||
|
||||
class WorkReestrSchema(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
parent:Task.get_pydantic(include={"id","parent"})
|
||||
# parent__parent:int
|
||||
datestart: Optional[date]
|
||||
dateend: Optional[date]
|
||||
lastchanged:Optional[datetime]
|
||||
status:TaskStatus.get_pydantic(include={"id","name"})
|
||||
responsible: Optional[User.get_pydantic(include={"id","sn"})]
|
||||
work_assignment: Optional[list[Assignment.get_pydantic(include={"id","name","status__id","dateend","status__name","responsible","responsible__sn"})]]
|
||||
|
||||
class AsPP(BaseModel):
|
||||
id:int
|
||||
parent:Project.get_pydantic(include={"id"})
|
||||
|
||||
class ASgnmParent(BaseModel):
|
||||
id:int
|
||||
# parent: Task.get_pydantic(include={"id"})
|
||||
|
||||
class AssignmReestrSchema(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
parent:ASgnmParent
|
||||
|
||||
datestart: Optional[date]
|
||||
dateend: Optional[date]
|
||||
lastchanged:Optional[datetime]
|
||||
status:TaskStatus.get_pydantic(include={"id","name"})
|
||||
responsible: Optional[User.get_pydantic(include={"id","sn"})]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class AssignmentinTask(BaseModel):
|
||||
id:int
|
||||
name:str
|
||||
status:AssignmentStatus.get_pydantic(include={'id','name'})
|
||||
datestart:Optional[date]
|
||||
dateend: Optional[date]
|
||||
responsible: User.get_pydantic(include={"id"})
|
||||
|
||||
class Work4project(BaseModel):
|
||||
id:int
|
||||
difficult: Optional[int]
|
||||
longname: Optional[str]
|
||||
work_assignment:Optional[list[Assignment.get_pydantic(include={"id"})]]
|
||||
parent:Task.get_pydantic(include={'id','parent__id'})
|
||||
name: str
|
||||
status: TaskStatus.get_pydantic(include={"id","name"})
|
||||
responsible:Optional[User.get_pydantic(include={"id","sn", "givenName"})]
|
||||
dateend: Optional[date]
|
||||
datestart:Optional[date]
|
||||
description: Optional[Text]
|
||||
work_assignment:Optional[list[Assignment.get_pydantic(include={"id"})]]
|
||||
|
||||
|
||||
class History4Status(BaseModel):
|
||||
id: int
|
||||
project: Optional[int]
|
||||
task:Optional[int]
|
||||
work:Optional[int]
|
||||
assignment: Optional[int]
|
||||
info: dict
|
||||
level:int
|
||||
author: User.get_pydantic(include={"id","sn","avatar"})
|
||||
createdate: datetime
|
||||
action: HistoryAction.get_pydantic(include={"id","name"})
|
||||
comment:Optional[Text]
|
||||
|
||||
# History4Status
|
||||
|
||||
|
||||
class WorkAssignments4project(Work4project):
|
||||
work_assignment:list[AssignmentinTask]
|
||||
|
||||
class AllProjectDocumentation(BaseModel):
|
||||
id:int
|
||||
doctype:DocType.get_pydantic(include={"id","name"})
|
||||
created: datetime
|
||||
approved: Optional[int]
|
||||
approvedtime:Optional[datetime]
|
||||
approver: Optional[UserProjectFullName]
|
||||
docnumber:Optional[str]
|
||||
accepters:Optional[list]
|
||||
path:Optional[str]
|
||||
|
||||
class ProjectDockInfo(AllProjectDocumentation):
|
||||
vrersion: dict
|
||||
comment:Optional[str]
|
||||
path:Optional[str]
|
||||
# accepters:Optional[list]
|
||||
|
||||
class Task4ProjectGetBase(BaseModel):
|
||||
id:int
|
||||
parent: Optional[Project.get_pydantic(include={'id'})]
|
||||
status: Optional[TaskStatus.get_pydantic(include={"id","name"})]
|
||||
name: Optional[str]
|
||||
responsible:Optional[User.get_pydantic(include={"id","sn","givenName"})]
|
||||
dateend: Optional[date]
|
||||
datestart:Optional[date]
|
||||
description:Optional[str]
|
||||
difficult: Optional[int]
|
||||
longname: Optional[str]
|
||||
# comment:Optional[list]
|
||||
|
||||
class Task4ProjectGet(Task4ProjectGetBase):
|
||||
task_work:list[Work.get_pydantic(include={"id"})]
|
||||
|
||||
class WorkAssignmentsInTask(Task4ProjectGetBase):
|
||||
work_assignment:list[AssignmentinTask]
|
||||
# pass
|
||||
class Task4Proj(BaseModel):
|
||||
task:Optional[list[Task4ProjectGetBase]]
|
||||
|
||||
class History4ProjectGet(BaseModel):
|
||||
id:int
|
||||
info: Json
|
||||
action: HistoryAction.get_pydantic(include={"id","name"})
|
||||
createdate: datetime
|
||||
# level: HistoryLevel.get_pydantic(include={"id","name"})
|
||||
author: UserFullName
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TaskCreate(BaseCreateProjectTask):
|
||||
parent: int
|
||||
name: str
|
||||
# status: Optional[TaskStatus.get_pydantic(include={"id"})]
|
||||
datestart:date
|
||||
dateend: date
|
||||
responsible: User.get_pydantic(include={"id"})
|
||||
# users: Optional[list[ProjectUser.get_pydantic(include={"id"})]]
|
||||
|
||||
class TaskUpdate(TaskCreate):
|
||||
id:int
|
||||
|
||||
|
||||
class AssignmentCreate(BaseModel):
|
||||
task: Optional[Task.get_pydantic(include={"id"})]
|
||||
name: str
|
||||
user: Optional[User.get_pydantic(include={"id"})]
|
||||
status: Optional[AssignmentStatus.get_pydantic(include={"id"})]
|
||||
datetimeend:Optional[datetime] = datetime.now()
|
||||
|
||||
class AssignmentUpdate(AssignmentCreate):
|
||||
id:int
|
||||
datetimestart: Optional[datetime] = datetime.now()
|
||||
timeneeded: Optional[int]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# -----------------------------------Схемы чатов
|
||||
|
||||
|
||||
class ChatUserschema(BaseModel):
|
||||
id:int
|
||||
sn: str
|
||||
givenName:str
|
||||
# username:str
|
||||
class LastChatMessage(BaseModel):
|
||||
id:int
|
||||
text:str
|
||||
messagetime: datetime
|
||||
sender:ChatUserschema
|
||||
|
||||
class LchMesWithParent(LastChatMessage):
|
||||
chat:Chat.get_pydantic(include={'id',"parent",'level'})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Chatschema(BaseModel):
|
||||
id:int
|
||||
name:Optional[str]
|
||||
users: List[ChatUserschema]
|
||||
level:Optional[int]
|
||||
parent:Optional[int]
|
||||
admin:Optional[User.get_pydantic(include={'id'})]
|
||||
# chat: Chat.get_pydantic(include={"id","name"})
|
||||
# users:list[CHatuser]
|
||||
|
||||
# class ChatList(Chatl):
|
||||
# list:Optional[list[Chatl]]
|
||||
|
||||
|
||||
# class ChatParamsToPost(ChatlistBase):
|
||||
# sender: int
|
||||
|
||||
|
||||
# Поручен
|
||||
class AAW(BaseModel):
|
||||
id:int
|
||||
name:str
|
||||
datestart: date
|
||||
dateend: date
|
||||
|
||||
|
||||
class FileGetterUpdated(BaseModel):
|
||||
id:int
|
||||
project: Optional[Project.get_pydantic(include={"id"})]
|
||||
task: Optional[Task.get_pydantic(include={"id"})]
|
||||
work:Optional[Work.get_pydantic(include={"id"})]
|
||||
assignment:Optional[Assignment.get_pydantic(include={"id"})]
|
||||
visible:str
|
||||
|
||||
class Filegetter(FileGetterUpdated):
|
||||
|
||||
sender:Optional[User.get_pydantic(include={'id',"sn","givenName"})]
|
||||
datetime: datetime
|
||||
filepath: str
|
||||
counter: int
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# !Новый
|
||||
class AssAndWork(AAW):
|
||||
responsible: Optional[User.get_pydantic(include={'id','sn','givenName'})]
|
||||
description: Optional[str]
|
||||
difficult: Optional[int]
|
||||
longname: Optional[str]
|
||||
# comment:Optional[list]
|
||||
|
||||
class Parent_Parent(AAW):
|
||||
rp: Optional[User.get_pydantic(include={'id'})]
|
||||
|
||||
class AssignmentinWork(AssAndWork):
|
||||
timeneeded: Optional[int]
|
||||
author: User.get_pydantic(include={'id'})
|
||||
status: AssignmentStatus.get_pydantic(include={'id','name'})
|
||||
getstarted: Optional[datetime]
|
||||
parent:Work.get_pydantic(include={'id'})
|
||||
|
||||
|
||||
|
||||
# assignment_files:Optional[list[Filegetter]]
|
||||
|
||||
class TaskinWork(AssAndWork):
|
||||
parent: Parent_Parent
|
||||
|
||||
class FullWork(AssAndWork):
|
||||
parent: AssAndWork
|
||||
lastchanged:Optional[date]
|
||||
status:TaskStatus.get_pydantic(include={'id',"name"})
|
||||
work_assignment:Optional[list[AssignmentinWork]]
|
||||
work_files:Optional[list[Filegetter]]
|
||||
|
||||
class WorkonlyFiles(BaseModel):
|
||||
work_files:Optional[list[Filegetter]]
|
||||
|
||||
class AssignmentUpdated(BaseModel):
|
||||
id:int
|
||||
status: AssignmentStatus.get_pydantic(include={'id','name'})
|
||||
getstarted: Optional[datetime]
|
||||
timeneeded: Optional[int]
|
||||
|
||||
# !Новый
|
||||
class WorkforAssignment(BaseModel):
|
||||
responsible:User.get_pydantic(include={'id'})
|
||||
status:TaskStatus.get_pydantic(include={'id',"name"})
|
||||
|
||||
parent:Task.get_pydantic(include={'id','parent__id'})
|
||||
work_assignment:Optional[list[Assignment.get_pydantic(include={"id"})]]
|
||||
work_files:Optional[list[Filegetter]]
|
||||
Whitespace-only changes.
Reference in new issue
Block a user