Esempio n. 1
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    user_profile_id = db.Column(
        db.Integer(), db.ForeignKey('user_profile.id', ondelete='CASCADE'))

    # User authentication information
    username = db.Column(db.String(50), nullable=False, unique=True)
    password = db.Column(db.String(255), nullable=False, server_default='')
    reset_password_token = db.Column(db.String(100),
                                     nullable=False,
                                     server_default='')
    is_active = db.Column('is_active',
                          db.Boolean(),
                          nullable=False,
                          server_default='0')

    # User email information
    email = db.Column(db.String(255), nullable=False, unique=True)
    confirmed_at = db.Column(db.DateTime())

    # Relationships
    user_profile = db.relationship('UserProfile',
                                   uselist=False,
                                   foreign_keys=[user_profile_id])

    def __repr__(self):
        return '<id: {}, user_profile_id: {}, username: {}, is_active: {}, email: {}' \
            .format(self.id, self.user_profile_id, self.username, self.is_active, self.email)
Esempio n. 2
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer(), primary_key=True)

    email = db.Column(db.String(255), unique=True)
    password = db.Column(db.String(255))
    scores = db.Column(db.Integer(), default=0)
    active = db.Column(db.Boolean(), default=True)

    roles = db.relationship('Role',
                            secondary=role_user_link,
                            backref=db.backref('users', lazy='dynamic'))

    palindromes = db.relationship('Palindrome',
                                  secondary=palindrome_user_link,
                                  backref=db.backref('users', lazy='dynamic'))

    def __repr__(self):
        return 'ID: {}, Email: {}'.format(self.id, self.email)
Esempio n. 3
0
class Role(db.Model, RoleMixin):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))

    def __repr__(self):
        return self.name

    @property
    def admin_url(self):
        return "%s/%s/%s" % (app.config['ADMIN_URL'], 'role', self.id)
Esempio n. 4
0
# -*- coding: utf-8 -*-

from datetime import datetime

from flask.ext.security import UserMixin, RoleMixin, SQLAlchemyUserDatastore, Security
from __init__ import app, db
from flask_security.forms import RegisterForm
from wtforms.validators import Required, Length
from wtforms import TextField, TextAreaField, BooleanField

roles_users = db.Table(
    'roles_users',
    db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
    db.Column('role_id', db.Integer(), db.ForeignKey('role.id'))
)

conversation_users = db.Table(
    'conversation_users',
    db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
    db.Column('conversation_id', db.Integer(), db.ForeignKey('conversation.id'))
)

categories_types = db.Table(
    'categories_types',
    db.Column('category_id', db.Integer(), db.ForeignKey('category.id')),
    db.Column('stufftype_id', db.Integer(), db.ForeignKey('stufftype.id'))
)

"""
stuff_type_stuff_list = db.Table('stuff_type_stuff_list',
        db.Column('stuff_id', db.Integer(), db.ForeignKey('stuff.id')),
Esempio n. 5
0
class Palindrome(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    title = db.Column(db.String(255))

    def __repr__(self):
        return 'ID: {}, Title: {}'.format(self.id, self.title)
Esempio n. 6
0
class Role(db.Model, RoleMixin):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(50), unique=True)

    def __repr__(self):
        return 'ID: {}, Name: {}'.format(self.id, self.name)
Esempio n. 7
0
from __init__ import db
from flask_security import UserMixin, RoleMixin

role_user_link = db.Table(
    'role_user', db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
    db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))

palindrome_user_link = db.Table(
    'palindrome_user',
    db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
    db.Column('palindrome_id', db.Integer(), db.ForeignKey('palindrome.id')))


class User(db.Model, UserMixin):
    id = db.Column(db.Integer(), primary_key=True)

    email = db.Column(db.String(255), unique=True)
    password = db.Column(db.String(255))
    scores = db.Column(db.Integer(), default=0)
    active = db.Column(db.Boolean(), default=True)

    roles = db.relationship('Role',
                            secondary=role_user_link,
                            backref=db.backref('users', lazy='dynamic'))

    palindromes = db.relationship('Palindrome',
                                  secondary=palindrome_user_link,
                                  backref=db.backref('users', lazy='dynamic'))

    def __repr__(self):
        return 'ID: {}, Email: {}'.format(self.id, self.email)
Esempio n. 8
0
        return f'polls_text:{self.text}'


class Choice(db.Model):
    __tablename__ = 'choice'
    choice_id = Column(Integer,
                       unique=True,
                       primary_key=True,
                       autoincrement=True)
    choice_text = Column(String, nullable=False)
    votes = Column(Integer, default=0, nullable=False)
    question_id = Column(Integer, ForeignKey('polls.id', ondelete='CASCADE'))


roles_users = db.Table(
    "roles_users", Column('user_id', db.Integer(), db.ForeignKey('users.id')),
    Column('role_id', db.Integer(), db.ForeignKey('roles.id')))


class Role(db.Model):
    __tablename__ = 'roles'
    id = Column(Integer, primary_key=True)
    name = Column(String(80), unique=True)
    description = Column(String(255))

    def __repr__(self):
        return self.name


class User(db.Model):
    __tablename__ = 'users'
Esempio n. 9
0
class notificationruletemplate(db.Model):
    rule_template_id = db.Column(db.Integer(), primary_key=True)
    templates = db.Column(db.String(20))
    notifrules = db.relationship("notificationrules",
                                 backref="notificationruletemplate",
                                 lazy="dynamic")
Esempio n. 10
0
class Ranking(Base):
    __tablename__ = 'ranking'
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))