@anonymous/

PoliteHappyScales

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# models/participant.py
from message import Message
from message_reference import Message_Reference

class Participant(Base):
    __tablename__ = 'participant'

    uuid = Column(UUID, primary_key=True, default=uuid.uuid4)
    conference = Column(UUID, ForeignKey('conference.uuid'), nullable=False)
    user = Column(UUID, ForeignKey('user.uuid'), nullable=False)

    def messages(self):
        return session.query(Message).join(Message_Reference).filter(
            Message_Reference.user == self.user).all()


# models/message.py
import text_message
import voice_message

class Message(ConcreteBase, Base):
    __tablename__ = 'message'

    uuid = Column(UUID, primary_key = True, default = uuid.uuid4)
    author = Column(UUID, nullable = False)
    readed = Column(BOOLEAN, nullable = False, default = False)
    date =  Column(TIMESTAMP(timezone = True), nullable = False, default = datetime.datetime.utcnow)

    __mapper_args__ = {
        'polymorphic_identity': 'message',
        'concrete': True
    }


# models/text_message.py
from message import Message

# Traceback (most recent call last):
#   File "init.py", line 22, in <module>
#     from participant import Participant
#   File "Models\participant.py", line 11, in <module>
#     from message import Message
#   File "Models\message.py", line 13, in <module>
#     import text_message
#   File "Models\text_message.py", line 10, in <module>
#     from message import Message
# ImportError: cannot import name 'Message'
class Text_Message(Message):
    __tablename__ = 'text_message'

    uuid = Column(UUID, primary_key = True, default = uuid.uuid4)
    author = Column(UUID, nullable = False)
    readed = Column(BOOLEAN, nullable = False, default = False)
    date =  Column(TIMESTAMP(timezone = True), nullable = False, default = datetime.datetime.utcnow)
    content = Column(TEXT, nullable = False)
    edited = Column(BOOLEAN, nullable = False, default = False)

    __mapper_args__ = {
        'polymorphic_identity': 'text_message',
        'concrete': True
    }