This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def main(): | |
config: Config = load_conf() | |
bot = Bot(token=config.telegram.token) | |
dp = Dispatcher() | |
dp.message.middleware(DataBaseMiddleware(config)) | |
dp.include_router(start_commands.router) | |
dp.include_router(bot_join_in_group.router) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession | |
from sqlalchemy.orm import sessionmaker, declarative_base | |
Base = declarative_base() | |
def create_poll(user: str, password: str, host: str, name: str) -> sessionmaker: | |
engine = create_async_engine( | |
f"postgresql+asyncpg://{user}:{password}@{host}/{name}", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Callable, Any, Awaitable, Dict | |
from aiogram import BaseMiddleware | |
from aiogram.types import CallbackQuery | |
from bot.data.config import Config | |
from bot.models.base import create_poll | |
class DataBaseMiddleware(BaseMiddleware): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sql = update(TrackedAccounts) \ | |
.where(TrackedAccounts.auth_key == deep_link_key) \ | |
.values( | |
is_active=True, | |
chat_id=chat_id, | |
auth_key=None, | |
updated_at=datetime.fromisoformat(datetime.now().isoformat()), | |
).returning(TrackedAccounts.id) | |
async with db_session() as session: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@admin.register(models.OwnersDetails) | |
class OwnersDetailsAdmin(admin.ModelAdmin): | |
list_filter = ("name_organization",) | |
search_fields = ["name_organization", "inn_organization"] | |
list_display = ["get_sn", "inn_organization", "name_organization", "first_name", "last_name"] | |
inlines = [DeviceInline, RepairOrderInline] | |
@display(ordering='device__serial_number', description='Device') | |
def get_sn(self, obj): | |
return obj.device.serial_number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OwnersDetails(models.Model): | |
first_name = models.CharField(verbose_name="Фамилия", max_length=50, blank=True) | |
last_name = models.CharField(verbose_name="Имя", max_length=50, blank=True) | |
name_organization = models.CharField(verbose_name="Наименование организации", max_length=150, blank=True) | |
inn_organization = models.BigIntegerField(verbose_name="ИНН организации", blank=True) | |
person_number_phone = models.BigIntegerField(verbose_name="Номер телефона", blank=True) | |
city = models.CharField(verbose_name="Город", max_length=100, blank=True) | |
street = models.CharField(verbose_name="Улица", max_length=100, blank=True) | |
house_number = models.CharField(verbose_name="Номер дома / офиса", max_length=50, blank=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import time | |
import network | |
from machine import Pin | |
class WIFI: | |
def __init__(self): | |
self.wlan = network.WLAN(network.STA_IF) |