crappy
This commit is contained in:
		@@ -1,2 +1,3 @@
 | 
			
		||||
from .auth import *
 | 
			
		||||
from .deal import *
 | 
			
		||||
from .client import *
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								models/client.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								models/client.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
from sqlalchemy import Column, Integer, String, DateTime
 | 
			
		||||
 | 
			
		||||
from models import BaseModel
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Client(BaseModel):
 | 
			
		||||
    __tablename__ = 'clients'
 | 
			
		||||
    id = Column(Integer, autoincrement=True, primary_key=True, index=True)
 | 
			
		||||
    name = Column(String, nullable=False, unique=True, comment='Название клиента')
 | 
			
		||||
    address = Column(String)
 | 
			
		||||
    created_at = Column(DateTime, nullable=False, comment='Дата создания')
 | 
			
		||||
@@ -8,12 +8,13 @@ from models.base import BaseModel
 | 
			
		||||
 | 
			
		||||
@unique
 | 
			
		||||
class DealStatus(IntEnum):
 | 
			
		||||
    AWAITING_ACCEPTANCE = 0
 | 
			
		||||
    PACKAGING = 1
 | 
			
		||||
    AWAITING_SHIPMENT = 2
 | 
			
		||||
    AWAITING_PAYMENT = 3
 | 
			
		||||
    COMPLETED = 4
 | 
			
		||||
    CANCELLED = 5
 | 
			
		||||
    CREATED = 0
 | 
			
		||||
    AWAITING_ACCEPTANCE = 1
 | 
			
		||||
    PACKAGING = 2
 | 
			
		||||
    AWAITING_SHIPMENT = 3
 | 
			
		||||
    AWAITING_PAYMENT = 4
 | 
			
		||||
    COMPLETED = 5
 | 
			
		||||
    CANCELLED = 6
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Deal(BaseModel):
 | 
			
		||||
@@ -23,7 +24,10 @@ class Deal(BaseModel):
 | 
			
		||||
    created_at = Column(DateTime, nullable=False, comment='Дата создания')
 | 
			
		||||
    current_status = Column(Integer, nullable=False, comment='Текущий статус')
 | 
			
		||||
 | 
			
		||||
    status_history = relationship('DealStatusHistory', back_populates='deal')
 | 
			
		||||
    client_id = Column(Integer, ForeignKey('clients.id'), nullable=False, comment='ID клиента')
 | 
			
		||||
    client = relationship('Client', backref='deals')
 | 
			
		||||
 | 
			
		||||
    status_history = relationship('DealStatusHistory', back_populates='deal', cascade="all, delete-orphan")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealStatusHistory(BaseModel):
 | 
			
		||||
@@ -39,3 +43,6 @@ class DealStatusHistory(BaseModel):
 | 
			
		||||
    changed_at = Column(DateTime, nullable=False, comment='Дата и время когда произошла смена статуса')
 | 
			
		||||
    from_status = Column(Integer, nullable=False, comment='Предыдущий статус')
 | 
			
		||||
    to_status = Column(Integer, nullable=False, comment='Новый статус')
 | 
			
		||||
 | 
			
		||||
    next_status_deadline = Column(DateTime,
 | 
			
		||||
                                  comment='Дедлайн до которого сделку нужно перевести на следующий этап')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user