class Template(db.Model):
    __tablename__ = "template"
    id = db.Column(db.Integer, primary_key=True)
    mailchimp_id = db.Column(db.String(50))
    brand_id = db.Column(db.Integer, db.ForeignKey('brand.id'))
    folder_id = db.Column(db.Integer, db.ForeignKey('folder.id'))
    category_id = db.Column(db.Integer,
                            db.ForeignKey('template_category.id'),
                            nullable=True)
    folder = db.relationship("Folder", backref="templates")
    category = db.relationship("TemplateCategory", backref="templates")
    name = db.Column(db.String(200))
    type = db.Column(db.String(50))
    active = db.Column(db.Boolean, default=True)
    thumbnail = db.Column(db.String(1024), nullable=True)
    html = db.Column(db.Text, nullable=False)
    sections = db.relationship("TemplateSection",
                               backref="template",
                               lazy="dynamic")
    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))
    updated = db.Column(db.DateTime)
    updated_by = db.Column(db.String(10))

    def __init__(self):
        self.created = datetime.datetime.now()
        self.updated = datetime.datetime.now()
class ExportDefinition(db.Model):
    __tablename__ = "export_definition"
    id = db.Column(db.Integer, primary_key=True)
    brand_id = db.Column(db.Integer, db.ForeignKey('brand.id'))
    folder_id = db.Column(db.Integer, db.ForeignKey("folder.id"))
    name = db.Column(db.String(200))
    file_path = db.Column(db.String(1024))
    file_delimiter = db.Column(db.String(1), default=",")
    target_type = db.Column(db.String(200))
    target_folder_id = db.Column(db.Integer, db.ForeignKey("folder.id"), nullable=True)
    target_list_id = db.Column(db.Integer, db.ForeignKey('list.id'), nullable=True)
    target_segment_id = db.Column(db.Integer, db.ForeignKey("segment.id"), nullable=True)
    target_objects = db.relationship("ExportObject", lazy="dynamic")
    export_type = db.Column(db.Integer, default=1)
    system_definition = db.Column(db.Boolean, default=False)
    notify_addresses = db.Column(db.String(1024), nullable=True)
    fields = db.relationship("ExportField", lazy="dynamic")
    activity = db.relationship("ExportActivity", lazy="dynamic")
    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))
    updated = db.Column(db.DateTime)
    updated_by = db.Column(db.String(10))

    def __init__(self):
        self.created = datetime.datetime.now()
        self.updated = datetime.datetime.now()
Esempio n. 3
0
class Segment(db.Model):
    __tablename__ = "segment"
    id = db.Column(db.Integer, primary_key=True)
    mailchimp_id = db.Column(db.String(50))
    brand_id = db.Column(db.Integer, db.ForeignKey('brand.id'))
    folder_id = db.Column(db.Integer, db.ForeignKey('folder.id'))
    list_id = db.Column(db.Integer, db.ForeignKey("list.id"))
    name = db.Column(db.String(200))
    type = db.Column(db.String(50), default="saved")
    match = db.Column(db.String(3), default="any")
    subscribers = db.relationship('ListSubscriber',
                                  secondary=segment_subscribers,
                                  lazy='dynamic',
                                  cascade="all,delete")
    conditions = db.relationship("SegmentCondition",
                                 lazy='dynamic',
                                 cascade="all,delete",
                                 backref="segment")
    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))
    updated = db.Column(db.DateTime)
    updated_by = db.Column(db.String(10))

    def __init__(self):
        self.created = datetime.datetime.now()
        self.updated = datetime.datetime.now()
Esempio n. 4
0
class Question(db.Model):
    __tablename__ = 'questions'

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

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(50), nullable=False)
    text = db.Column(db.String(500), nullable=False)
    timestamp = db.Column(db.DateTime(),
                          nullable=False,
                          server_default=func.now())

    topic_id = db.Column(db.Integer,
                         db.ForeignKey('topics.id'),
                         nullable=False)
    topic = db.relationship('Topic', uselist=False, back_populates='questions')

    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    user = db.relationship('User', back_populates='questions')

    answers = db.relationship('Answer',
                              back_populates='question',
                              order_by=Answer.id)

    def serialize(self):
        return {'id': self.id, 'title': self.title, 'text': self.text, \
            'timestampStr': self.timestamp.strftime('%d/%m/%Y, %H:%M:%S')}
Esempio n. 5
0
class Medicamento(db.Model):
    __tablename__ = "Medicamento"
    idMedicamento = db.Column(db.Integer, primary_key=True)
    nombre = db.Column(db.String(45), unique=True)
    cantidad = db.Column(db.Integer)
    porcion = db.Column(db.Float)
    descripcion = db.Column(db.String(250))
    fechaE = db.Column(db.Date)
    fechaV = db.Column(db.Date)
    idProveedor = db.Column('idProveedor', db.Integer,
                            db.ForeignKey("Proveedor.idProveedor"))
    idUsuario = db.Column('idUsuario', db.Integer,
                          db.ForeignKey("Usuario.idUsuario"))
    precio = db.Column(db.Float)
    imagen = db.Column(db.String(300))
    detallePedido = relationship("DetallePedido", backref="Medicamento")

    def __init__(self, idProveedor, idUsuario, nombre, cantidad, porcion,
                 descripcion, fechaE, fechaV, precio, imagen):
        self.idProveedor = idProveedor
        self.idUsuario = idUsuario
        self.nombre = nombre
        self.cantidad = cantidad
        self.porcion = porcion
        self.descripcion = descripcion
        self.fechaE = fechaE
        self.fechaV = fechaV
        self.precio = precio
        self.imagen = imagen

    def __repr__(self):
        return ''
Esempio n. 6
0
class RaceUnit(db.Model):
    __tablename__ = 'race_units'
    race_id = db.Column(db.Integer,
                        db.ForeignKey('races.id'),
                        primary_key=True)
    unit_id = db.Column(db.Integer,
                        db.ForeignKey('units.id'),
                        primary_key=True)
    created_at = db.Column(db.DateTime,
                           default=datetime.datetime.utcnow,
                           nullable=False)
    updated_at = db.Column(db.DateTime)

    def __init__(self, race_id, unit_id):
        self.race_id = race_id
        self.unit_id = unit_id

    @property
    def serialize(self):
        """Return object data in easily serializable format"""
        return {
            'race_id': self.race_id,
            'unit_id': self.unit_id,
            'created_at': dump_datetime(self.created_at)
        }

    def __repr__(self):
        return '<RaceUnit race:%i unit:%i>' % (self.race_id, self.unit_id)
Esempio n. 7
0
class ListSubscriber(db.Model):
    __tablename__ = "list_subscriber"
    id = db.Column(db.Integer, primary_key=True)
    brand_id = db.Column(db.Integer, db.ForeignKey('brand.id'))
    list_id = db.Column(db.Integer, db.ForeignKey('list.id'))
    email_id = db.Column(db.String(50))
    email_address = db.Column(db.String(200))
    unique_email_id = db.Column(db.String(200))
    email_type = db.Column(db.String(10), default="html")
    status = db.Column(db.String(20))
    location = db.relationship("ListSubscriberLocation",
                               lazy="dynamic",
                               cascade="delete")
    merge_fields = db.relationship('ListSubscriberMergeField',
                                   backref='list_subscriber',
                                   lazy='dynamic',
                                   cascade="delete")
    activity = db.relationship("ListSubscriberActivity",
                               backref="list_subscriber",
                               lazy="dynamic",
                               cascade="delete")
    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))
    updated = db.Column(db.DateTime)
    updated_by = db.Column(db.String(10))

    def __init__(self):
        self.created = datetime.datetime.now()
        self.updated = datetime.datetime.now()
Esempio n. 8
0
class Classroom(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), nullable=False)
    desc = db.Column(db.String(80), nullable=True)
    code = db.Column(db.String(CLASS_CODE_LENGTH), nullable=False, unique=True)

    teacher_id = db.Column(db.Integer, db.ForeignKey("teacher.id"))
    student_ids = db.Column(db.Integer, db.ForeignKey("student.id"))

    assignments = db.relationship("Assignment", backref="classroom", lazy=True)

    def __init__(self, name, desc, teacher):
        self.name = name
        self.desc = desc
        self.code = self.generate_class_code()
        self.teacher = teacher

    def generate_class_code(self):
        code = "".join(choices(ascii_letters, k=CLASS_CODE_LENGTH))
        while True:
            if Classroom.query.filter_by(code=code).first() is None:
                break
            code = "".join(choices(ascii_letters, k=CLASS_CODE_LENGTH))
        return code

    def enroll_student(self, student):
        self.students.append(student)

    def remove_student(self, student):
        if student in self.students:
            self.students.remove(student)
            return True
        return False
Esempio n. 9
0
class Subject(db.Model):
    __tablename__ = 'subjects'

    def __init__(self, name, description, student_year_id, module_id):
        self.name = name
        self.description = description
        self.student_year_id = student_year_id
        self.module_id = module_id

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    description = db.Column(db.String(200))

    student_year_id = db.Column(db.Integer, db.ForeignKey('student_years.id'))
    student_year = db.relationship('StudentYear',
                                   uselist=False,
                                   back_populates='subject')

    # TODO jedan predmet moze na vise modula
    module_id = db.Column(db.Integer, db.ForeignKey('modules.id'))
    module = db.relationship('Module', uselist=False, back_populates='subject')

    topics = db.relationship('Topic', back_populates='subject')
    proffessors = db.relationship('User',
                                  secondary=ProffessorSubject,
                                  back_populates='subjects')
    consultations = db.relationship('Consultation', back_populates='subject')

    def serialize(self):
        return {'id': self.id, 'name': self.name, 'description': self.description, \
                'studentYearId': self.student_year_id, 'moduleId': self.module_id}
Esempio n. 10
0
class Post(db.Model):
    pid = db.Column(db.Integer, primary_key=True)
    uid = db.Column(db.ForeignKey('user.id', ondelete="SET NULL"))
    lid = db.Column(db.ForeignKey('location.id'), nullable=False)
    time_posted = db.Column(db.DateTime, nullable=False)
    photo = db.Column(db.BINARY(16), nullable=False)
    caption = db.Column(db.String(300), nullable=False)
    hashtags = db.Column(db.String(200))
class DataView_Open(db.Model):
    __tablename__ = "data_view_open"
    id = db.Column(db.Integer, primary_key=True)
    brand_id = db.Column(db.Integer, db.ForeignKey('brand.id'))
    campaign_id = db.Column(db.Integer, db.ForeignKey("campaign.id"))
    email_id = db.Column(db.String(50))
    email_address = db.Column(db.String(200))
    unique_email_id = db.Column(db.String(200))
    list_id = db.Column(db.Integer, db.ForeignKey("list.id"))
    event_date = db.Column(db.TIMESTAMP)
    campaign_title = db.Column(db.String(200), nullable=True)
Esempio n. 12
0
class CommentLike(db.Model):
    comment_id = db.Column(db.ForeignKey("comment.comment_id",
                                         ondelete="CASCADE"),
                           nullable=False,
                           primary_key=True)
    uid = db.Column(db.ForeignKey("user.id", ondelete="CASCADE"),
                    nullable=False,
                    primary_key=True)
    timestamp = db.Column(db.DateTime)

    def __repr__(self):
        return '<CommentLike>'
Esempio n. 13
0
class PostLike(db.Model):
    pid = db.Column(db.ForeignKey("post.pid", ondelete="CASCADE"),
                    nullable=False,
                    primary_key=True)
    uid = db.Column(db.ForeignKey("user.id", ondelete="CASCADE"),
                    nullable=False,
                    primary_key=True,
                    index=True)
    timestamp = db.Column(db.DateTime)

    def __repr__(self):
        return '<PostLike>'
Esempio n. 14
0
class Comment(db.Model):
    comment_id = db.Column(db.Integer, primary_key=True)
    pid = db.Column(db.ForeignKey("post.pid", ondelete="CASCADE"),
                    nullable=False,
                    index=True)
    uid = db.Column(db.ForeignKey("user.id", ondelete="SET NULL"),
                    nullable=False)
    comment = db.Column(db.String(300))
    timestamp = db.Column(db.DateTime, index=True)

    def __repr__(self):
        return '<Comment>'
class Log(db.Model):
    __tablename__ = "process_log"
    id = db.Column(db.Integer, primary_key=True)
    brand_id = db.Column(db.Integer, db.ForeignKey("brand.id"))
    brand = db.relationship("Brand", backref="logs")
    tool_id = db.Column(db.Integer, db.ForeignKey("tool.id"))
    tool = db.relationship("Tool", backref="logs")
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    user = db.relationship("User", backref="logs")
    request_route = db.Column(db.String(150))
    crud_operation = db.Column(db.String(20))
    esp_interaction = db.Column(db.Integer, default=0)
    esp_object = db.Column(db.String(150))
    esp_object_key = db.Column(db.String(40))
    esp_object_name = db.Column(db.String(200))
    esp_operation = db.Column(db.String(50))
    esp_data = db.Column(db.String(2000))
    esp_response = db.Column(db.String(10))
    esp_response_msg = db.Column(db.String(2000))
    rows_affected = db.Column(db.Integer, default=0)
    created = db.Column(db.DateTime, default=datetime.datetime.now())

    def __init__(self,
                 brand_id,
                 tool_id,
                 user_id,
                 route,
                 op=None,
                 e_int=0,
                 e_obj=None,
                 e_obj_key=None,
                 e_obj_name=None,
                 e_op=None,
                 e_data=None,
                 e_resp=None,
                 e_resp_msg=None,
                 rows=0):
        self.brand_id = brand_id
        self.tool_id = tool_id
        self.user_id = user_id
        self.request_route = route
        self.crud_operation = op
        self.esp_interaction = e_int
        self.esp_object = e_obj
        self.esp_object_key = e_obj_key
        self.esp_object_name = e_obj_name
        self.esp_operation = e_op
        self.esp_data = e_data
        self.esp_response = e_resp
        self.esp_response_msg = e_resp_msg
        self.rows_affected = rows
class TemplateCategory(db.Model):
    __tablename__ = "template_category"
    id = db.Column(db.Integer, primary_key=True)
    brand_id = db.Column(db.Integer, db.ForeignKey("brand.id"))
    folder_id = db.Column(db.Integer, db.ForeignKey("folder.id"))
    name = db.Column(db.String(200))
    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))
    updated = db.Column(db.DateTime)
    updated_by = db.Column(db.String(10))

    def __init__(self):
        self.created = datetime.datetime.now()
        self.updated = datetime.datetime.now()
Esempio n. 17
0
class Image(db.Model):
    __tablename__ = 'images'

    id = db.Column(db.Integer, primary_key=True)
    path = db.Column(db.String(50), nullable=False)

    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
    user = db.relationship('User', back_populates='image')

    answer_id = db.Column(db.Integer, db.ForeignKey('answers.id'))
    answer = db.relationship('Answer', back_populates='images')

    def serialize(self):
        return {'id': self.id, 'path': self.path, 'userId': self.user_id, \
                'answerId': self.answer_id}
class VariateCampaignCombination(db.Model):
    __tablename__ = "variate_campaign_combination"
    id = db.Column(db.Integer, primary_key=True)
    variate_campaign_id = db.Column(db.Integer, db.ForeignKey("variate_campaign.id"))
    mailchimp_id = db.Column(db.String(50))
    email_id = db.Column(db.Integer, db.ForeignKey("email.id"))
    send_time = db.Column(db.TIMESTAMP, nullable=True)
    subject_line = db.Column(db.String(200))
    from_name = db.Column(db.String(200))
    reply_to = db.Column(db.String(200))
    recipients = db.Column(db.Integer)
    created = db.Column(db.DateTime)

    def __init__(self):
        self.created = datetime.datetime.now()
class TrackedCampaignVariateDetail(db.Model):
    __tablename__ = "tracking_variate_detail"
    id = db.Column(db.Integer, primary_key=True)
    tracking_id = db.Column(db.Integer, db.ForeignKey("tracking.id"))
    email_name = db.Column(db.String(200))
    email_id = db.Column(db.Integer, db.ForeignKey("email.id"))
    send_time = db.Column(db.TIMESTAMP, nullable=True)
    subject_line = db.Column(db.String(200))
    from_name = db.Column(db.String(200))
    reply_to = db.Column(db.String(200))
    recipients = db.Column(db.Integer)
    is_winner = db.Column(db.Boolean, default=False)
    created = db.Column(db.DateTime)

    def __init__(self):
        self.created = datetime.datetime.now()
class FormField(db.Model):
    __tablename__ = "form_field"
    id = db.Column(db.Integer, primary_key=True)
    group_id = db.Column(db.Integer, db.ForeignKey('form_group.id'))
    name = db.Column(db.String(100))
    label = db.Column(db.String(100))
    rank = db.Column(db.Integer, default=1)
    required = db.Column(db.Boolean, default=True)
    create = db.Column(db.Boolean, default=True)
    update = db.Column(db.Boolean, default=True)
    search = db.Column(db.Boolean, default=False)
    export = db.Column(db.Boolean, default=True)
    tag = db.Column(db.String(20))
    field_type = db.Column(db.String(20))
    max_length = db.Column(db.Integer, default=1)
    default_value = db.Column(db.String(200), nullable=True)
    options = db.relationship("FormFieldOption",
                              backref="form_field",
                              lazy="dynamic")
    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))
    updated = db.Column(db.DateTime)
    updated_by = db.Column(db.String(10))

    def __init__(self):
        self.created = datetime.datetime.now()
        self.updated = datetime.datetime.now()
Esempio n. 21
0
class ListMergeField(db.Model):
    __tablename__ = "list_merge_field"
    id = db.Column(db.Integer, primary_key=True)
    list_id = db.Column(db.Integer, db.ForeignKey('list.id'))
    mailchimp_id = db.Column(db.Integer)
    tag = db.Column(db.String(20))
    name = db.Column(db.String(200))
    type = db.Column(db.String(20))
    required = db.Column(db.Boolean, default=True)
    default_value = db.Column(db.String(200), nullable=True)
    public = db.Column(db.Boolean, default=True)
    display_order = db.Column(db.Integer, default=0)
    choices = db.relationship("ListMergeFieldChoice",
                              lazy="dynamic",
                              cascade="all,delete")
    size = db.Column(db.Integer, default=0)
    default_country = db.Column(db.String(5), nullable=True)
    phone_format = db.Column(db.String(50), nullable=True)
    date_format = db.Column(db.String(50), nullable=True)

    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))
    updated = db.Column(db.DateTime)
    updated_by = db.Column(db.String(10))

    def __init__(self):
        self.created = datetime.datetime.now()
        self.updated = datetime.datetime.now()
Esempio n. 22
0
class Tool(db.Model):
    __tablename__ = "tool"
    __table_args__ = {'useexisting': True}
    id = db.Column(db.Integer, primary_key=True)
    group_id = db.Column(db.Integer, db.ForeignKey("tool_group.id"))
    name = db.Column(db.String(200))
    description = db.Column(db.String(200))
    alias = db.Column(db.String(200))
    home_route = db.Column(db.String(200))
    rank = db.Column(db.Integer, default=0)
    is_admin = db.Column(db.Integer, default=0)
    settings = db.relationship("ToolSetting",
                               backref="tool",
                               lazy='dynamic',
                               cascade="all,delete")
    group = db.relationship("ToolGroup", backref="tool")
    brands = db.relationship('Brand', secondary=brand_tools, lazy='dynamic')
    status = db.Column(db.Integer, default=1)
    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))
    updated = db.Column(db.DateTime)
    updated_by = db.Column(db.String(10))

    def __init__(self, name=None, alias=None):
        self.name = name
        self.alias = alias
        self.created = datetime.datetime.now()
        self.updated = datetime.datetime.now()
Esempio n. 23
0
class ListSubscriberMergeField(db.Model):
    __tablename__ = "list_subscriber_merge_field"
    id = db.Column(db.Integer, primary_key=True)
    list_subscriber_id = db.Column(db.Integer,
                                   db.ForeignKey('list_subscriber.id'))
    list_merge_field_id = db.Column(
        db.Integer, db.ForeignKey('list_merge_field.id', ondelete='CASCADE'))
    value = db.Column(db.String(200))

    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))
    updated = db.Column(db.DateTime)
    updated_by = db.Column(db.String(10))

    def __init__(self):
        self.created = datetime.datetime.now()
        self.updated = datetime.datetime.now()
Esempio n. 24
0
class Notification(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    uid = db.Column(db.ForeignKey('user.id', ondelete="SET NULL"))
    message = db.Column(db.String(300), nullable=False)
    notif_type = db.Column(db.String(1), nullable=False)
    link = db.Column(db.String(64), nullable=False)
    read = db.Column(db.Boolean, default=False, nullable=False)
    timestamp = db.Column(db.DateTime, nullable=False)
Esempio n. 25
0
class Conversation(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first_user_id = db.Column(db.Integer,
                              db.ForeignKey('user.id'),
                              nullable=False)
    second_user_id = db.Column(db.Integer,
                               db.ForeignKey('user.id'),
                               nullable=False)
    messages = db.relationship('Message', backref="conversation")

    def __init__(self, first_user_id, second_user_id):
        self.first_user_id = first_user_id
        self.second_user_id = second_user_id

    def __repr__(self):
        return '<Conversation %r between user %r and user %r>' % (
            self.id, self.first_user_id, self.second_user_id)
Esempio n. 26
0
class Sensor(db.Model):
    __tablename__ = "sensor"
    id = db.Column(db.Integer, primary_key=True)
    type = db.Column(db.Integer)
    threshold = db.Column(db.Float, nullable=False)
    greater_than_or_eq = db.Column(db.Boolean, nullable=False, default=True)
    sensor_node_id = db.Column(db.Integer, db.ForeignKey("sensor_node.id"))
    readings = db.relationship("SensorReading",
                               backref="sensor",
                               lazy='dynamic')
Esempio n. 27
0
class ListSubscriberActivity(db.Model):
    __tablename__ = "list_subscriber_activity"
    id = db.Column(db.Integer, primary_key=True)
    list_subscriber_id = db.Column(db.Integer,
                                   db.ForeignKey('list_subscriber.id'))
    action = db.Column(db.String(200), nullable=True)
    timestamp = db.Column(db.TIMESTAMP, nullable=True)
    url = db.Column(db.String(200), nullable=True)
    type = db.Column(db.String(200), nullable=True)
    variate_campaign_id = db.Column(db.Integer,
                                    db.ForeignKey("variate_campaign.id"))
    campaign_id = db.Column(db.Integer, db.ForeignKey("campaign.id"))
    title = db.Column(db.String(200), nullable=True)
    #parent_campaign = db.Column(db.String(20))

    created = db.Column(db.DateTime)
    created_by = db.Column(db.String(10))

    def __init__(self):
        self.created = datetime.datetime.now()
Esempio n. 28
0
class SegmentCondition(db.Model):
    __tablename__ = "segment_condition"
    id = db.Column(db.Integer, primary_key=True)
    segment_id = db.Column(db.Integer, db.ForeignKey("segment.id"))
    type = db.Column(db.String(50))
    op = db.Column(db.String(50))
    field = db.Column(db.String(100))
    value = db.Column(db.String(200))
    created = db.Column(db.DateTime)

    def __init__(self):
        self.created = datetime.datetime.now()
Esempio n. 29
0
class Comment(db.Model):
    __tablename__='comments'

    def __init__(self, text, answer_id, user_id):
        self.text = text
        self.answer_id = answer_id
        self.user_id = user_id
       
    id = db.Column(db.Integer, primary_key=True)
    text = db.Column(db.String(500), nullable=False)
    timestamp = db.Column(db.DateTime(), nullable=False, server_default=func.now())

    answer_id = db.Column(db.Integer, db.ForeignKey('answers.id'), nullable=False)
    answer = db.relationship('Answer', back_populates='comments')
    
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    user = db.relationship('User', back_populates='comments')

    def serialize(self):
        return {'id': self.id, 'text': self.text, 'timestampStr': self.timestamp, \
                'answerId': self.answer_id, 'userId': self.user_id }
Esempio n. 30
0
class Person(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(500))
    town = db.Column(db.Integer, db.ForeignKey('town.id'))
    status = db.Column(db.String(500), default='alive')

    def __init__(self, name, town, status):
        self.name = name
        self.town = town
        self.status = status

    def __repr__(self):
        return '<Person %r>' % self.name