Exemplo n.º 1
0
class Crisis(db.Model):
    __tablename__ = 'crisis'

    id = db.Column(db.Integer, unique=True, primary_key=True)
    title = db.Column(db.String(50), nullable=False)
    type = db.Column(db.String(50))
    steps = db.relationship('Step', backref=db.backref('Crisis', lazy=True))

    def __init__(self, title, type):
        self.title = title
        self.type = type

    def __repr__(self):
        return '<Crisis: %r>' % (self.title)
Exemplo n.º 2
0
class Step(db.Model):
    __tablename__ = 'step'

    id = db.Column(db.Integer, unique=True, primary_key=True)
    text = db.Column(db.String(300), nullable=False)
    url = db.Column(db.String(200))
    crisis_id = db.Column(db.Integer, db.ForeignKey('crisis.id'))

    def __init__(self, text, url, crisis_id):
        self.text = text
        self.url = url
        self.crisis_id = crisis_id

    def __repr__(self):
        return '<Step: %r>' % (self.text)
Exemplo n.º 3
0
class User(db.Model, UserMixin):
    __tablename__ = 'user'

    id = db.Column(db.Integer, primary_key=True, unique=True)
    first_name = db.Column(db.String(60))
    last_name = db.Column(db.String(60))
    email = db.Column(db.String(60), unique=True)
    phone = db.Column(db.String(15))
    password = db.Column(db.String(300))
    user_role = db.Column(db.String(15))
    last_seen = db.Column(db.Date)

    day_info = db.relationship('DayInfo',
                               backref=db.backref('User', lazy=True))
    remember_topics = db.relationship('RememberTopic',
                                      backref=db.backref('User', lazy=True))
    therapist = db.relationship('User',
                                secondary=pairs,
                                primaryjoin=(pairs.c.patient_id == id),
                                secondaryjoin=(pairs.c.therapist_id == id),
                                backref=db.backref('pairs', lazy='dynamic'),
                                lazy='dynamic')

    def __init__(self, first_name, last_name, email, phone, password,
                 user_role):
        self.first_name = first_name
        self.last_name = last_name
        self.email = email
        self.phone = phone
        self.password = password
        self.user_role = user_role

    def __repr__(self):
        return '<User: %r %r>' % (self.first_name, self.last_name)
Exemplo n.º 4
0
class RememberTopic(db.Model):
    __tablename__ = 'remember_topic'

    id = db.Column(db.Integer, unique=True, primary_key=True)
    title = db.Column(db.String(100))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    topic_answers = db.relationship('TopicAnswers',
                                    backref=db.backref('RememberTopic',
                                                       lazy=True))

    def __init__(self, title, user_id):
        self.title = title
        self.user_id = user_id

    def __repr__(self):
        return '<RememberTopic: %r>' % (self.title)
Exemplo n.º 5
0
class TopicAnswers(db.Model):
    __tablename__ = 'topic_answers'

    id = db.Column(db.Integer, unique=True, primary_key=True)
    answer = db.Column(db.String(300))
    date = db.Column(db.Date)

    topic_id = db.Column(db.Integer,
                         db.ForeignKey('remember_topic.id'),
                         nullable=False)

    def __init__(self, answer, date, topic_id):
        self.answer = answer
        self.date = date
        self.topic_id = topic_id

    def __repr__(self):
        return '<Topic Answers: %r>' % (self.answer)