예제 #1
0
class PredioTable(db.Model):
    __tablename__ = 'predio'

    id = db.Column(db.Integer, primary_key=True)
    evento = db.Column(db.Boolean, nullable=False)

    #Configuração dos relacionamentos
    apartamento_idpredio = db.relationship('ApartamentoTable',
                                           backref='apartamento_idpredio')
    morador_idpredio = db.relationship('MoradorTable',
                                       backref='morador_idpredio',
                                       single_parent=True,
                                       cascade="all, delete-orphan")
    entrada_idpredio = db.relationship('EntradaTable',
                                       backref='entrada_idpredio')
    evento_idpredio = db.relationship('EventoTable',
                                      backref='evento_idpredio',
                                      single_parent=True,
                                      cascade="all, delete-orphan")
    problema_idpredio = db.relationship('ProblemaTable',
                                        backref='problema_idpredio',
                                        single_parent=True,
                                        cascade="all, delete-orphan")

    def __init__(self, evento):
        self.evento = evento
예제 #2
0
class UserData(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    pseudo = db.Column(db.String(20), nullable=False)
    age = db.Column(db.Integer, nullable=False)
    gender = db.Column(db.String(20), nullable=False)
    grade = db.relationship('Grades', backref='user_grade', lazy='dynamic')
    rec = db.relationship('Recommendations', backref='user_rec', lazy='dynamic')
class Biddings(db.Model, UserMixin):
    petname = db.Column(db.String,
                        db.ForeignKey('pets.petname', ondelete='CASCADE'),
                        primary_key=True,
                        nullable=False)
    pcontact = db.Column(db.Integer,
                         db.ForeignKey('pets.pcontact', ondelete='CASCADE'),
                         primary_key=True,
                         nullable=False)
    ccontact = db.Column(db.Integer,
                         db.ForeignKey('users.contact', ondelete='CASCADE'),
                         primary_key=True,
                         nullable=False)
    startdate = db.Column(db.Date, primary_key=True, nullable=False)
    enddate = db.Column(db.Date, primary_key=True, nullable=False)
    paymentmode = db.Column(db.String, nullable=False)
    deliverymode = db.Column(db.String, nullable=False)
    status = db.Column(db.String, nullable=False)

    pcontactrel = db.relationship("Pets", foreign_keys=[pcontact])
    petnamerel = db.relationship("Pets", foreign_keys=[petname])

    # reviewpetname = db.relationship('Reviews', backref='pet')
    # reviewpcontact = db.relationship('Reviews', backref='petonwercontact')
    # reviewccontact = db.relationship('Reviews', backref='caretakercontact')
    # reviewstartdate = db.relationship('Reviews', backref='start')
    # reviewenddate = db.relationship('Reviews', backref='end')

    def get_status(self):
        return self.status

    def get_key(self):
        return (self.startdate, self.enddate, self.ccontact, self.petname,
                self.pcontact)
예제 #4
0
class Song(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    src = db.Column(db.String(255), nullable=False)
    img = db.Column(db.Binary, nullable=False)
    song_meta = db.relationship('Metadata', backref='song_meta', lazy='dynamic')
    song_grade = db.relationship('Grades', backref='song_grade', lazy='dynamic')
    song_rec = db.relationship('Recommendations', backref='song_rec', lazy='dynamic')
예제 #5
0
파일: models.py 프로젝트: jqjZhu/WeConnect
class User(db.Model, UserMixin):

    __tablename__ = 'users'
    __table_args__ = {'extend_existing': True}

    id = db.Column(db.Integer, primary_key=True)
    profile_image = db.Column(db.String(64),
                              nullable=False,
                              default='default_profile.png')
    email = db.Column(db.String(64), unique=True, index=True)
    username = db.Column(db.String(64), unique=True, index=True)
    password_hash = db.Column(db.String(128))

    posts = db.relationship('BlogPost', backref='author', lazy=True)
    # sender = db.relationship('Chat', backref = 'sender_chat', lazy = True)
    # receiver = db.relationship('Chat', backref = 'receiver_chat', lazy = True)
    comments = db.relationship('BlogComment',
                               backref='user_comment',
                               lazy=True)

    def __init__(self, email, username, password):
        self.email = email
        self.username = username
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)

    def __repr__(self):
        return f"Username {self.username}"
예제 #6
0
class Message(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    to_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    to_user = db.relationship('User',
                              backref='incoming_messages',
                              foreign_keys=[to_user_id])
    from_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    from_user = db.relationship('User',
                                backref='messages',
                                foreign_keys=[from_user_id])
    conversation_id = db.Column(db.Integer, db.ForeignKey('conversation.id'))
    conversation = db.relationship('Conversation', backref='messages')
    txt = db.Column(db.String(1000))
    created_at = db.Column(db.DateTime, default=datetime.now)
    status = db.Column(db.Integer, default=0)

    def __repr__(self):
        return self.txt

    @property
    def admin_url(self):
        return "%s/%s/%s" % (app.config['ADMIN_URL'], 'conversation', self.id)

    @property
    def url(self):
        return "%s/%s" % ('conversation', self.id)
예제 #7
0
파일: models.py 프로젝트: 3shmawyz/Cantiin
class User(db.Model, MyModel):
    #__metaclass__=MyModel
    __tablename__ = "user"
    # Autoincrementing, unique primary key
    id = db.Column(Integer(), primary_key=True)
    # String username
    username = db.Column(String(), unique=True, nullable=False)
    # username could be like "fish"
    # username has to be unique
    # not allowing several users to have the same username
    password = db.Column(String(), unique=False, nullable=False)
    # Password is a string
    # Example: "12345", "abc"
    # it doesn't have to be unique

    products = db.relationship("Product",
                               cascade="all, delete-orphan",
                               passive_deletes=False,
                               backref="seller")
    orders = db.relationship("Order",
                             cascade="all, delete-orphan",
                             passive_deletes=False,
                             backref="buyer")

    #images = db.relationship("Image",cascade="all, delete-orphan",
    #	passive_deletes=False,backref="seller")

    def __init__(self, **kwargs):
        MyModel.__init__(self, **kwargs)
예제 #8
0
class Users(db.Model, UserMixin):
    username = db.Column(db.String, nullable=False)
    password = db.Column(db.String, nullable=False)
    contact = db.Column(db.Integer, primary_key=True)
    usertype = db.Column(db.String, nullable=True)
    card = db.Column(db.String)
    isparttime = db.Column(db.Boolean)
    postalcode = db.Column(db.String)
    
    biddingccontact = db.relationship('Biddings', backref='contact')
    cantakecareccontact = db.relationship('Cantakecare', backref='contact')
    pet = db.relationship('Pets', backref='owner')
    
    # Relationships
    roles = db.relationship('Role', secondary='user_roles',
    backref=db.backref('users', lazy='dynamic'))
    
    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self.contact
예제 #9
0
class PartType(db.Model):
    __tablename__ = 'part_types'
    id = db.Column(db.Integer, primary_key=True)
    partName = db.Column(
        db.String(80)
    )  #We may want to change the primary key to use 2 strings such as battery, low
    price = db.Column(db.Float)
    startDate = db.Column(db.DateTime)
    endDate = db.Column(db.DateTime)
    deletedAt = db.Column(db.DateTime)
    parts = db.relationship('Part', backref='part_type', lazy='dynamic')

    # phoneTypes = db.relationship('PhoneType', backref='part_types', lazy='dynamic')
    batteryPart = db.relationship('PhoneType',
                                  backref='battery',
                                  lazy='dynamic',
                                  foreign_keys='[PhoneType.batteryTypeId]')
    screenPart = db.relationship('PhoneType',
                                 backref='screen',
                                 lazy='dynamic',
                                 foreign_keys='[PhoneType.screenTypeId]')
    memoryPart = db.relationship('PhoneType',
                                 backref='memory',
                                 lazy='dynamic',
                                 foreign_keys='[PhoneType.memoryTypeId]')

    def __init__(self, partName, price):
        self.partName = partName
        self.price = price
        self.startDate = datetime.utcnow()
        self.endDate = None
        self.deletedAt = None
예제 #10
0
class UserRoles(db.Model):
    __tablename__ = 'user_roles'
    contact = db.Column(db.Integer, db.ForeignKey('users.contact', ondelete='CASCADE'), primary_key=True, nullable=False)
    usertype = db.Column(db.String, db.ForeignKey('role.name', ondelete='CASCADE'), nullable=False)
    
    userrolecontact = db.relationship('Users', foreign_keys=[contact])
    userrolerole = db.relationship('Role', foreign_keys=[usertype])
예제 #11
0
class Stuff(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(255), nullable=False)
    detail = db.Column(db.String(10000))
    owner_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    owner = db.relationship('User', backref='stuff_list')
    address_id = db.Column(db.Integer, db.ForeignKey('address.id'))
    stuff_address = db.relationship('Address', backref='stuff_list')
    date = db.Column(db.DateTime, default=datetime.now)
    stuff_type = db.relationship('StuffType', backref='stuff_list')
    type_id = db.Column(db.Integer, db.ForeignKey('stufftype.id'))
    category = db.relationship('Category', backref='stuff_list')
    category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    group_id = db.Column(db.Integer, db.ForeignKey('group.id'))
    group = db.relationship('Group', backref='stuff_list')
    approved = db.Column(db.Integer, default=0)
    status = db.Column(db.Integer, default=1)
    is_wanted = db.Column(db.Boolean, default=False)
    created_at = db.Column(db.DateTime, default=datetime.now)

    def __repr__(self):
        return "%s" % (self.title)

    @property
    def admin_url(self):
        return "%s/%s/%s" % (app.config['ADMIN_URL'], 'stuff', self.id)

    @property
    def edit_url(self):
        return "%s/%s" % ('edit_stuff', self.id)

    @property
    def url(self):
        return "%s/%s" % ('show_stuff', self.id)
예제 #12
0
class StuffPhoto(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    filename = db.Column(db.String(255), nullable=False)
    owner_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    owner = db.relationship('User', backref='object_photos')
    stuff_id = db.Column(db.Integer, db.ForeignKey('stuff.id'))
    stuff = db.relationship('Stuff', backref='photos')
예제 #13
0
파일: models.py 프로젝트: adle29/cs373-idb
class Team(Base):
    """
    Team has everything related to a team in soccer with the name, nickname, logo, and market_val
    """
    __tablename__ = 'team'
    __table_args__ = {'extend_existing': True}
    # Here we define columns for the table address.
    # Notice that each column is also a normal Python instance attribute.
    team_id = db.Column(db.Integer, primary_key=True)
    api_team_id = db.Column(Integer, unique=True)
    team_name = db.Column(db.String(250), nullable=False)
    logo_url = db.Column(db.String(250))
    nickname = db.Column(db.String(250))
    market_val = db.Column(db.String(250))
    # relationships
    t_season = db.relationship("Season",
                               secondary=season_team,
                               back_populates="s_team")  # many to many
    t_standing = db.relationship("Standing",
                                 back_populates="r_team")  # 1 to many
    t_player = db.relationship("Player", back_populates="p_team")  # 1 to many

    #t_game = db.relationship("Game", secondary=team_game, back_populates="g_team")  # many to many
    #t_game_home = db.relationship("Game", back_populates="g_team_home") # 1 to many
    #t_game_away = db.relationship("Game", back_populates="g_team_away") # 1 to many

    def __init__(self, api_team_id, team_name, logo_url, nickname, market_val):
        """
        initializes everything in the Team class
        :param self:
        :param api_team_id: Integer
        :param team_name: String
        :param logo_url: String
        :param nickname: String
        :param market_val: String
        """
        self.api_team_id = api_team_id
        self.team_name = team_name
        self.logo_url = logo_url
        self.nickname = nickname
        self.market_val = market_val

    def display(self):
        """
        :param self:
        :return: display
        :rtype: OrderedDict
        """
        display = OrderedDict()
        display['api_team_id'] = self.api_team_id
        display['team_id'] = self.team_id
        display['team_id'] = self.team_id
        display['team_name'] = self.team_name.title()
        display['logo_url'] = self.logo_url
        display['nickname'] = self.nickname
        display['market_val'] = self.market_val
        display['players'] = [player.player_id for player in self.t_player]
        #display['games'] = [game.game_id for game in self.t_game]
        return display
예제 #14
0
class Weapon(db.Model):
    __tablename__ = "weapons" 

    weapon_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), unique=True)
    rounds_min = db.Column(db.Integer)
    planes_offensive_weapons = db.relationship('PlaneOffensiveWeapon', backref='plane_off_weapon')
    planes_offensive_weapons = db.relationship('PlaneDefensiveWeapon', backref='plane_def_weapon')
예제 #15
0
class Season(db.Model):
    __tablename__ = 'seasons'
    id = db.Column(db.Integer, primary_key=True)
    start_year = db.Column(db.String(8), nullable=False)
    end_year = db.Column(db.String(8), nullable=False)

    teams = db.relationship('Team', secondary='team_stats')
    players = db.relationship('Player', secondary='player_stats')
예제 #16
0
class Team(db.Model):
    __tablename__ = 'teams'
    id = db.Column(db.Integer, primary_key=True)
    country = db.Column(db.String)
    statistics = db.relationship('Statistics', back_populates="team")
    games = db.relationship(
        'Game',
        secondary='statistics',
        back_populates='teams'
    )
예제 #17
0
class Game(db.Model):
    __tablename__ = 'games'
    id = db.Column(db.Integer, primary_key=True)
    venue = db.Column(db.String)
    winner = db.Column(db.String)
    statistics = db.relationship('Statistics', back_populates="game")
    teams = db.relationship(
        'Team',
        secondary='statistics',
        back_populates='games'
    )
예제 #18
0
class Ware(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(512), index=True)

    st_ware = db.relationship("WareStorage",
                              back_populates="wares",
                              cascade='all')
    op_ware = db.relationship("WareOperation",
                              back_populates='wares',
                              cascade='all')

    def __repr__(self):
        return "Ware {}".format(self.name)
예제 #19
0
class Material(db.Model):
    '''
    Model contains list of materials
    '''
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), unique=False, nullable=False)
    factory_config = db.relationship('FactoryConfig',
                                     backref='factory',
                                     lazy=True)
    user_config = db.relationship('UserConfig', backref='user', lazy=True)

    def __repr__(self):
        return f'Material: {self.name}, ID: {self.id}'
예제 #20
0
파일: models.py 프로젝트: wupperwufei/marry
class User(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)  # 会员号
    iphone = db.Column(db.String(11),  unique=True)  # 手机号
    pwd = db.Column(db.String(32))  # 密码
    create_time = db.Column(db.DateTime,default=datetime.now,)  # 注册时间
    update_time = db.Column(db.DateTime,default=datetime.now,onupdate=datetime.now)  # 登录时间
    times = db.Column(db.Integer,default=0)  # 登录次数
    user_info = db.relationship('User_info', backref='user', uselist=False)  # 一对一
    friend = db.relationship('Friend', backref='user', uselist=False)  # 一对一

    def __repr__(self):
        return '<User:%r>' % self.iphone
예제 #21
0
class notificationheaders(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    notification_uuid = db.Column(db.String(20), unique=True)
    user_uuid = db.Column(db.String(20))
    company_uuid = db.Column(db.String(20))
    title = db.Column(db.String(20))
    type = db.Column(db.String(20))
    severity = db.Column(db.String(20))
    frequency = db.Column(db.String(20))
    notif2web = db.relationship("notification2websites",
                                backref="notificationheaders",
                                lazy="select")
    notif2prod = db.relationship("notification2products",
                                 backref="notificationheaders",
                                 lazy="dynamic")
    notif2search = db.relationship("notification2searchstring",
                                   backref="notificationheaders",
                                   lazy="dynamic")
    notif2contact = db.relationship("notification2contacts",
                                    backref="notificationheaders",
                                    lazy="dynamic")
    notifrules = db.relationship("notificationrules",
                                 backref="notificationheaders",
                                 lazy="dynamic")

    #def __repr__(self):
    #return "{'id': '%s', 'notification_uuid': '%s', 'user_uuid': '%s', 'company_uuid': '%s', 'title': '%s', 'type': '%s', 'severity': '%s', 'frequency': '%s'}" % (self.id, self.notification_uuid, self.user_uuid, self.company_uuid, self.title, self.type, self.severity, self.frequency)
    #return str(self.id)

    def getData(self):
        response = {}

        response["id"] = self.id
        response["notification_uuid"] = self.notification_uuid
        response["user_uuid"] = self.user_uuid
        response["company_uuid"] = self.company_uuid
        response["title"] = self.title
        response["type"] = self.type
        response["severity"] = self.severity
        response["frequency"] = self.frequency

        return response

    def getSpecificColumn(self, indexList):
        cols = self.getData()
        response = {}

        for index in indexList:
            response[index] = cols[index]

        return response
예제 #22
0
class Statistics(db.Model):
    __tablename__ = 'statistics'
    id = db.Column(db.Integer, primary_key=True)
    game_id = db.Column(db.Integer, db.ForeignKey('games.id'))
    team_id = db.Column(db.Integer, db.ForeignKey('teams.id'))
    name = db.Column(db.String)
    goals = db.Column(db.Integer)
    game = db.relationship('Game', back_populates='statistics')
    team = db.relationship('Team', back_populates='statistics')

    ball_possession=db.Column(db.Integer)
    distance_covered=db.Column(db.Integer)
    on_target=db.Column(db.Integer)
    pass_accuracy=db.Column(db.Integer)
예제 #23
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer,primary_key=True)
    first_name = db.Column(db.String(200),index = True)
    last_name = db.Column(db.String(200),index = True)
    username = db.Column(db.String(200), index = True)
    email = db.Column(db.String(200), index = True)
    password = db.Column(db.String(200),index = True)
    year = db.Column(db.Date)
    active = db.Column(db.Boolean())
    roles = db.relationship('Role',secondary = roles_user, backref = 'users')
    book = db.relationship('Book', secondary = book_user, lazy = 'select')

    def leave_book(self,book):
        self.book.remove(book)
예제 #24
0
class WareStorage(db.Model):
    ware_id = db.Column(db.Integer,
                        db.ForeignKey('ware.id', onupdate='CASCADE'),
                        primary_key=True)
    storage_id = db.Column(db.Integer,
                           db.ForeignKey('storage.id', onupdate='CASCADE'),
                           primary_key=True)
    ware_count = db.Column(db.INTEGER, default=1)
    wares = db.relationship("Ware", back_populates='st_ware')
    storages = db.relationship("Storage", back_populates='st_ware')

    def __repr__(self):
        return "Ware_id: {}, Storage_id: {}, Ware_count: {}".format(
            self.ware_id, self.storage_id, self.ware_count)
예제 #25
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)
    authority = db.Column(db.Integer, nullable=False)
    bookmarks = db.relationship('Bookmark', backref='user', lazy='dynamic')
    password_hash = db.Column(db.String)


    @property
    def password(self):
        raise AttributeError('password: write-only field')

    @password.setter
    def password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
            return check_password_hash(self.password_hash, password)

    @staticmethod
    def get_by_username(username):
        return User.query.filter_by(username=username).first()

    @staticmethod
    def get_by_email(email):
        return User.query.filter_by(email=email).first()
    def __repr__(self):
		return '<User %r>'% self.username
예제 #26
0
파일: models.py 프로젝트: driftbee/DBdev
class Trip(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    url = db.Column(db.Text, nullable=False)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    description = db.Column(db.String(300))
    destination = db.Column(db.String(300))

    #need to figure out a way to store DateTime properly
    outbound_date = db.Column(db.String(300))
    outbound_time = db.Column(db.String(300))
    inbound_date = db.Column(db.String(300))
    inbound_time = db.Column(db.String(300))


    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    _tags = db.relationship('Tag', secondary=tags, lazy='joined', backref=db.backref('trips', lazy='dynamic'))
    privacy = db.Column(db.Boolean, default=False)

    @staticmethod
    def newest(num):
        return Trip.query.filter(Trip.privacy.is_(False)).order_by(desc(Trip.date)).limit(num)

    @property
    def tags(self):
        return ",".join([t.name for t in self._tags])

    @tags.setter
    def tags(self, string):
        if string:
            self._tags = [Tag.get_or_create(name) for name in string.split(',')]

    def __repr__(self):
        return "<Trip '{}': '{}'>".format(self.description, self.url)
예제 #27
0
파일: models.py 프로젝트: tianyakun/yak
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)
class DepartmentModel(db.Model):
    __tablename__ = 'departments'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), nullable=True, unique=True)
    employee_id = db.relationship('EmployeesModel', backref='department', lazy=True)

    # Create a static method to create the table 'departments'
    def create(self):
        db.session.add(self)
        db.session.commit()

    # Create a class method that can modify the class DepartmentModel
    @classmethod
    def check_department_exists(cls, department_name):
        record = cls.query.filter_by(name=department_name).first()
        if record:
            return True
        else:
            return False
    
    # A class method to fetch all departments
    @classmethod
    def fetch_all_departments(cls):
        return cls.query.all()

    # A class method to fetch departments by id
    @classmethod
    def fetch_department_by_id(cls, id):
        return cls.query.filter_by(id=id).first()
예제 #29
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True)
    name = db.Column(db.String(255), nullable=False)
    phone_number = db.Column(db.String(255))
    photo = db.Column(db.String(255))
    about = db.Column(db.String(1000))
    why = db.Column(db.String(1000))
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean(), default=False)
    approved = db.Column(db.Boolean(), default=False)
    confirmed_at = db.Column(db.DateTime())
    roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))
    registered_at = db.Column(db.DateTime, default=datetime.now)

    @property
    def is_logged_in(self):
        return False if self.is_anonymous() else True

    @property
    def is_admin(self):
        return self.roles and self.roles[0].name == 'admin'

    def __repr__(self):
        return self.name

    @property
    def admin_url(self):
        return "%s/%s/%s" % (app.config['ADMIN_URL'], 'user', self.id)

    @property
    def url(self):
        return "%s/%s/" % ('profiles', self.name)
예제 #30
0
파일: models.py 프로젝트: 3shmawyz/Cantiin
class Product(db.Model, MyModel):
    __tablename__ = "product"
    # Autoincrementing, unique primary key
    id = db.Column(Integer(), primary_key=True)
    # String name
    name = db.Column(String(), unique=False, nullable=False)
    # name could be like "Labtop"
    # name dowsn't have to be unique
    # allowing several users to sell the same product
    price = db.Column(Float(), unique=False, nullable=False)
    # Price is a float
    # Example: 5.0, 6.0 , 50.0, 0.5
    # It should be float, allowing things with low
    # price to be sold
    in_stock = db.Column(Boolean(), unique=False, nullable=False, default=True)
    # in_stock is a boolean
    # Example: True, False
    # it represents whether this product is for sale or not
    # True = For sale, can be displayed to customers
    # False = now for sale, can not be displayed to customers
    seller_id = db.Column(Integer(),
                          ForeignKey("user.id"),
                          unique=False,
                          nullable=False)
    #seller_id = Column(Integer(), unique=False, nullable=False)
    # seller_id
    # This is the id of the seller user
    # The user who sells this product
    # it is an integer
    # Example: 1, 2 or 3
    orders = db.relationship("Order",
                             cascade="all, delete-orphan",
                             passive_deletes=False,
                             backref="product")
    """orders = db.relationship("Order",backref=backref('product',
예제 #31
0
파일: models.py 프로젝트: jrpeden/cs373-idb
            "away_box_ftm": self.away_box_ftm,
            "away_box_fta": self.away_box_fta,
            "away_box_oreb": self.away_box_oreb,
            "away_box_dreb": self.away_box_dreb,
            "away_box_ast": self.away_box_ast,
            "away_box_stl": self.away_box_stl,
            "away_box_blk": self.away_box_blk,
            "away_box_to": self.away_box_to,
            "away_box_pf": self.away_box_pf,
            "away_box_pts": self.away_box_pts,
            "away_box_plus_minus": self.away_box_plus_minus,
            "youtube_link_1": self.youtube_link_1,
            "youtube_link_2": self.youtube_link_2,
            "youtube_link_3": self.youtube_link_3,
        }


# flask.ext.whooshalchemy.whoosh_index(app, Game)

# many to many team game relationship
# team_game = db.relationship('Team', secondary=team_game,
#     backref=db.backref('games', lazy='dynamic'))
team_game_1 = db.relationship("Team", secondary=lambda: team_game)

# many to many player game relationship
# player_game = db.relationship('Player', secondary=player_game,
#     backref=db.backref('games', lazy='dynamic'))
player_game_1 = db.relationship("Player", secondary=lambda: player_game)

db.configure_mappers()