Esempio n. 1
0
class Message(db.Model):
    __tablename__ = 'chat_messages'

    id = db.Column(db.Integer(), primary_key=True)
    text = db.Column(db.Unicode())
    created_date = db.Column(db.DateTime())
    room_id = db.Column(db.Integer(), db.ForeignKey('chat_rooms.id'))
    user_name = db.Column(db.String(), db.ForeignKey('users.username'))
Esempio n. 2
0
class Karma(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(CIText(), unique=True)
    value = db.Column(db.Integer())

    def __init__(self, name):
        self.name = name
        self.value = 0

    def __repr__(self):
        return self.name + ': ' + str(self.value)
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 __str__(self):
        return self.name
Esempio n. 4
0
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer(), primary_key=True)
    username = db.Column(db.Unicode())
    password = db.Column(db.String())
    email = db.Column(db.String(128), unique=True)
Esempio n. 5
0
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer(), primary_key=True)
    password = db.Column(db.String())
    email = db.Column(db.String(128), nullable=False, unique=True)
    first_name = db.Column(db.Unicode(30))
    last_name = db.Column(db.Unicode(30))
    facebook_id = db.Column(db.Unicode(256))

    def password_match(self, input_password):
        return pbkdf2_sha256.verify(input_password, self.password)
Esempio n. 6
0
class Karma(db.Model):

    __hash__ = None
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(CIText(), unique=True)
    value = db.Column(db.Integer())

    def __init__(self, name):
        self.name = name
        self.value = 0

    def __repr__(self):
        return self.name + ': ' + str(self.value)

    def __lt__(self, other):
        return self.value < other.value

    def __eq__(self, other):
        return self.value == other.value and self.name == other.name

    def __ne__(self, other):
        return not self == other
Esempio n. 7
0
from flask_security import RoleMixin, UserMixin
from core.db import db
from core.view import BaseAdminView

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'))
)


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 __str__(self):
        return self.name


class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key = True)
    first_name = db.Column(db.String(255))
    last_name = db.Column(db.String(255))
    email = db.Column(db.String(255), unique = True, nullable = False)
    password = db.Column(db.String(255), nullable = False)
    active = db.Column(db.Boolean(), nullable = False)
    roles = db.relationship('Role', secondary = roles_users, backref = 'users')

    def __str__(self):
        return self.first_name + " " + self.last_name + " <" + self.email + ">"
Esempio n. 8
0
class Room(db.Model):
    __tablename__ = 'chat_rooms'

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.Unicode(30))
    created_date = db.Column(db.DateTime())
Esempio n. 9
0
class Subscription(db.Model):
    __tablename__ = 'chat_subscriptions'

    room_id = db.Column(db.Integer(), db.ForeignKey('chat_rooms.id'))
    user_id = db.Column(db.Integer(), db.ForeignKey('users.id'))
Esempio n. 10
0
class User(BaseModelMixin, db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    username = db.Column(db.Unicode(), default="noname")