Exemplo n.º 1
0
class Posts(db.Model, CRUD_MixIn):
    id = db.Column(db.Integer, primary_key=True)
    author = db.Column(db.String(250), nullable=False)
    title = db.Column(db.Text, nullable=False)
    slug = db.Column(db.String(250), nullable=False)
    date = db.Column(
        db.TIMESTAMP, server_default=db.func.current_timestamp(), nullable=False)
    date_gmt = db.Column(
        db.TIMESTAMP, server_default=db.func.current_timestamp(), nullable=False)
    content = db.Column(db.Text, nullable=False)
    excerpt = db.Column(db.Text, nullable=False)
    status = db.Column(db.String(250), server_default='publish', nullable=False)
    modified = db.Column(
        db.TIMESTAMP, server_default=db.func.current_timestamp(), nullable=False)
    modified_gmt = db.Column(
        db.TIMESTAMP, server_default=db.func.current_timestamp(), nullable=False)
    type = db.Column(db.String(250), server_default='post', nullable=False)
    parent = db.Column(db.Integer, nullable=False)
    #featured Image Path
    path = db.Column(db.Text)
    terms = db.relationship('Terms', secondary=term_relationships, backref='posts' )
    comments = db.relationship('Comments', backref="post", cascade="all, delete-orphan" , lazy='dynamic')

    def __init__(self,  author,  title,  slug,  content,  excerpt,  status,  type,  parent, path):

        self.author = author
        self.title = title
        self.slug = slug
        self.content = content
        self.excerpt = excerpt
        self.status = status
        self.type = type
        self.parent = parent
        self.path = path
Exemplo n.º 2
0
class Users(db.Model, CRUD_MixIn):
    id = db.Column(db.Integer, primary_key=True)

    email = db.Column(db.String(250), nullable=False, unique=True)
    password = db.Column(db.String(250), nullable=False)
    name = db.Column(db.String(250), nullable=False)
    active = db.Column(db.Integer, nullable=False)
    creation_time = db.Column(db.TIMESTAMP,
                              server_default=db.func.current_timestamp(),
                              nullable=False)
    role = db.Column(db.String(250), db.ForeignKey('roles.name'))
    role_relation = db.relationship('Roles', backref="users")

    def __init__(
        self,
        email,
        password,
        name,
        active,
        role,
    ):

        self.email = email
        self.password = password
        self.name = name
        self.active = active
        self.role = role
Exemplo n.º 3
0
class Surveys(db.Model, CRUD_MixIn):
    id = db.Column(db.Integer, primary_key=True)

    title = db.Column(db.String(250), nullable=False)
    description = db.Column(db.String(250), nullable=False)
    active = db.Column(db.Integer, nullable=False)
    creation_time = db.Column(db.TIMESTAMP,
                              server_default=db.func.current_timestamp())
    modification_time = db.Column(db.TIMESTAMP,
                                  server_default=db.func.current_timestamp())
    # Relationships
    questions = db.relationship('Questions', backref='surveys', lazy='dynamic')

    def __init__(
        self,
        title,
        description,
        active,
        creation_time,
        modification_time,
        question,
    ):

        self.title = title
        self.description = description
        self.active = active
        self.creation_time = creation_time
        self.modification_time = modification_time
        self.question = question
Exemplo n.º 4
0
class Students(db.Model, CRUD_MixIn):
    id = db.Column(db.Integer, primary_key=True)

    studentname = db.Column(db.String(250), nullable=False)
    degree = db.Column(db.String(250), nullable=False)
    major = db.Column(db.String(250), nullable=False)
    courses = db.relationship('Courses', secondary=student_course, backref='students')  
    def __init__(self,  studentname,  degree,  major):

        self.studentname = studentname
        self.degree = degree
        self.major = major
Exemplo n.º 5
0
class Questions(db.Model, CRUD_MixIn):
    id = db.Column(db.Integer, primary_key=True)

    name = db.Column(db.String(250), nullable=False)
    survey_id = db.Column(db.Integer(),
                          db.ForeignKey('surveys.id', ondelete='CASCADE'))
    order = db.Column(db.Integer())
    creation_time = db.Column(db.TIMESTAMP,
                              server_default=db.func.current_timestamp())
    updated = db.Column(db.DateTime,
                        default=db.func.current_timestamp(),
                        onupdate=db.func.current_timestamp())
    # Relationships
    responses = db.relationship('Responses',
                                backref='questions',
                                lazy='dynamic')

    def __init__(
        self,
        name,
    ):

        self.name = name