80 строки
1.6 KiB
Python
80 строки
1.6 KiB
Python
|
from aiogram.types.reply_keyboard import ReplyKeyboardMarkup as _ReplyKeyboardMarkup
|
||
|
from datetime import date, time, datetime, timedelta
|
||
|
from pydantic import BaseModel
|
||
|
import re
|
||
|
from typing import Literal
|
||
|
|
||
|
|
||
|
email_address = re.compile(r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)')
|
||
|
phone_number = re.compile(r'\D*')
|
||
|
iso_datetime = re.compile(r'(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d{0,6})([+-]?\d{0,2}:?\d{0,2})')
|
||
|
max_comment_length = 1024
|
||
|
|
||
|
|
||
|
class ReplyKeyboardMarkup(_ReplyKeyboardMarkup):
|
||
|
def __init__(self, keyboard=None):
|
||
|
super().__init__(
|
||
|
keyboard=keyboard,
|
||
|
resize_keyboard=True,
|
||
|
)
|
||
|
|
||
|
|
||
|
class Category(BaseModel):
|
||
|
id: int
|
||
|
name: str
|
||
|
description: str
|
||
|
|
||
|
|
||
|
class Subcategory(BaseModel):
|
||
|
category: Category
|
||
|
id: int
|
||
|
name: str
|
||
|
description: str
|
||
|
|
||
|
|
||
|
class Executor(BaseModel):
|
||
|
id: int
|
||
|
name: str
|
||
|
|
||
|
|
||
|
class TimeRange(BaseModel):
|
||
|
id: int
|
||
|
start_time: time
|
||
|
end_time: time
|
||
|
|
||
|
def __hash__(self):
|
||
|
return self.id
|
||
|
|
||
|
|
||
|
class FreeToOrder(BaseModel):
|
||
|
date: date
|
||
|
time_range: TimeRange
|
||
|
executor: Executor
|
||
|
busy_interval: timedelta
|
||
|
|
||
|
|
||
|
class Order(BaseModel):
|
||
|
id: int
|
||
|
subcategory: Subcategory
|
||
|
date: date
|
||
|
time_range: TimeRange
|
||
|
executor: Executor
|
||
|
telegram_id: int
|
||
|
email_address: str
|
||
|
phone_number: str
|
||
|
comment: str
|
||
|
start_time: datetime = None
|
||
|
end_time: datetime = None
|
||
|
|
||
|
|
||
|
class Issue(BaseModel):
|
||
|
id: int
|
||
|
key: str
|
||
|
status: Literal[
|
||
|
'undefined',
|
||
|
'new',
|
||
|
'indeterminate',
|
||
|
'done',
|
||
|
]
|
||
|
telegram_id: int
|