예제 #1
0
class Tickers(db.Model):
    id = db.Column(db.Integer, Sequence('tickers_tid_seq', start=1001, increment = 1), primary_key=True)
    # ticker = db.Column(db.String(5), unique=True)
    ticker = db.Column(db.String(5))
    startingPrice = db.Column(db.Float)
    short = db.Column(db.Boolean)
    #transactions = db.relationship('Transactions', backref='tickers')
    #user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    def __repr__(self):
        return "<Ticker '{}'>".format(self.ticker)
예제 #2
0
class Stock(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    ticker = db.Column(db.String(5))
    name = db.Column(db.String(80))
    price = db.Column(db.Float)
    datetime = db.Column(db.String(80))
    change = db.Column(db.Float)
    percentChange = db.Column(db.Float)
예제 #3
0
class Transactions(db.Model, UserMixin):
    id = db.Column(db.Integer, Sequence('transactions_tid_seq', start=1001, increment = 1), primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    ticker = db.Column(db.String(5))
    date = db.Column(db.String)
    end_price = db.Column(db.Integer)
    returns = db.Column(db.Integer)
예제 #4
0
class Member(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    eid = db.Column(db.String(8), unique=True)
    firstName = db.Column(db.String(80))
    lastName = db.Column(db.String(80))
    email = db.Column(db.String(80))
    attendance = db.Column(db.Integer)
    dues = db.Column(db.Integer)
    atLatestMeeting = db.Column(db.Boolean)
    rowOnSheet = db.Column(db.Integer)
    comments = db.Column(db.String(80))
    year = db.Column(db.String(80))

    @staticmethod
    def get_by_eid(eid):
        return Member.query.filter_by(eid=eid).first()

    @staticmethod
    def check_attendance(dues, attendance):
        if dues > 45:
            return True
        elif dues == 45:
            return attendance <= num_gms_semester
        elif dues == 0:
            return attendance <= num_gms_free
        return False
예제 #5
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    eid = db.Column(db.String)
    firstName = db.Column(db.String(80))
    lastName = db.Column(db.String(80))
    email = db.Column(db.String(80))
    attendance = db.Column(db.Integer)
    dues = db.Column(db.Integer)
    atLatestMeeting = db.Column(db.Boolean)
    rowOnSheet = db.Column(db.Integer)
    password_hash = db.Column(db.String)
    ret = db.Column(db.Float)
    score = db.Column(db.Float)
    active = db.Column(db.Boolean)
    analyst = db.Column(db.String)
    fund = db.Column(db.String)
    stocks = db.relationship('Tickers', secondary=ticker_identifier, backref='user')
    transactions = db.relationship('Transactions', backref='user')
    #required for Flask-Security
    roles =  db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))

    @property
    def password(self):
        return self.password_hash

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

    def check_password(self, password):
        # print("HERE IS THE PASSWORD: "******"<User '{}'>".format(self.email)
예제 #6
0
class Vote(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    ticker = db.Column(db.String(5))
    email = db.Column(db.String(80))
    position = db.Column(db.String(80))
예제 #7
0
class RecentVote(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    ticker = db.Column(db.String(5))
    close = db.Column(db.Boolean)
예제 #8
0
class AnalystFile(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    name = db.Column(db.String, unique = True)
    filePath = db.Column(db.String)
    owner = db.Column(db.String)
    analyst = db.Column(db.String)
예제 #9
0
class FundFile(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    name = db.Column(db.String, unique = True)
    filePath = db.Column(db.String)
    owner = db.Column(db.String)
    fund = db.Column(db.String)
예제 #10
0
class Role(db.Model, RoleMixin):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    description = db.Column(db.String(80))
예제 #11
0
from flask_login import UserMixin
from flask_sqlalchemy import SQLAlchemy
from werkzeug.security import check_password_hash, generate_password_hash
import json
import requests
from flask_security import RoleMixin
from sqlalchemy.schema import Sequence

num_gms_semester = 13
num_gms_free = 2
year_dues = 70
semester_dues = 45


ticker_identifier = db.Table('student_identifier',
    db.Column('user_id', db.Integer, db.ForeignKey('user.id')),
    db.Column('ticker_id', db.Integer, db.ForeignKey('tickers.id'))
)
#required for Flask-Security, could be useful later for admin screen
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 FundFile(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    name = db.Column(db.String, unique = True)
    filePath = db.Column(db.String)
    owner = db.Column(db.String)
    fund = db.Column(db.String)