class Hpicrecordyear(Base): __tablename__ = 'hpicrecordyear' recordId = db.Column(INTEGER(11), primary_key=True) At = db.Column(BIGINT(20)) stationId = db.Column(db.String(50)) Avg = db.Column(db.Float) Max = db.Column(db.Float) Min = db.Column(db.Float)
class Message(db.Model): __tablename__ = 'Message' messageID = db.Column(db.String(100), primary_key=True) foreignID = db.Column(db.String(100)) # merchandiseID = db.Column(db.String(100), db.ForeignKey('PostedMerchandise.merchandiseID')) # replyID = db.Column(db.String(100)) fromUserID = db.Column(db.String(100), db.ForeignKey('UserInfo.userID')) toUserID = db.Column(db.String(100), db.ForeignKey('UserInfo.userID')) description = db.Column(db.Text) createTime = db.Column(db.DateTime) tag = db.Column(db.Integer) state = db.Column(db.Integer) fromUserID_FK = relationship("UserInfo", foreign_keys=[fromUserID]) toUserID_FK = relationship("UserInfo", foreign_keys=[toUserID]) def __init__(self, messageID=None, foreignID=None, fromUserID=None, toUserID=None, description=None, createTime=None, tag=0, state=False): self.messageID = messageID self.foreignID = foreignID self.fromUserID = fromUserID self.toUserID = toUserID self.description = description self.createTime = createTime self.tag = tag self.state = state def __repr__(self): return self.messageID @staticmethod def generate(o): res = {} res['messageID'] = o.messageID res['foreignID'] = o.foreignID res['fromUserID'] = o.fromUserID res['toUserID'] = o.toUserID res['description'] = o.description res['createTime'] = str(o.createTime) return res
class MenuEntry(db.Model): __tablename__ = 'menu_entries' id = db.Column(db.Integer, primary_key=True) time_scraped = db.Column(db.DateTime, nullable=False) date_valid = db.Column(db.Date, nullable=False) mensa = db.Column(db.String(64), nullable=False) category = db.Column(db.String(64), nullable=False) description = db.Column(db.String(500), nullable=False) allergens = db.Column(db.String(64), nullable=True) price = db.Column(db.Integer, nullable=True) __table_args__ = (UniqueConstraint( 'date_valid', 'mensa', 'category', 'description', name="unique_menu_entry_date_mensa_category_description"), ) def __repr__(self): return '<MenuEntry scraped: {0} valid: {1} Mensa: {2} Category: {3} ' \ 'Description: {4} Allergens: {5} ' \ 'Price: {6}'.format(self.time_scraped, self.date_valid, self.mensa, self.category, self.description, self.allergens, locale.currency(self.price/100)) def to_pretty_text(self): return ("{date_valid}\n" "{mensa}: {category}\n" "{description}\n" "Allergens: {allergens}\n" "{price}\n").format( description=self.description.replace("\n", " "), mensa=self.mensa, category=self.category, date_valid=self.date_valid.strftime("%A, %d.%m.%Y"), allergens=self.allergens, price=locale.currency(self.price / 100)) def does_search_match(self, search_terms): def normalize_caseless(text): return unicodedata.normalize("NFKD", text.casefold()) return normalize_caseless(search_terms) in normalize_caseless( self.description)
class Iodinesampler1h(Base): __tablename__ = 'iodinesampler1h' recordId = db.Column(INTEGER(11), primary_key=True) At = db.Column(BIGINT(20)) stationId = db.Column(db.String(50)) Avg = db.Column(db.Float) Max = db.Column(db.Float) Min = db.Column(db.Float)
class Extralargeasmonth(Base): __tablename__ = 'extralargeasmonth' recordId = db.Column(INTEGER(11), primary_key=True) At = db.Column(BIGINT(20)) stationId = db.Column(db.String(50)) Avg = db.Column(db.Float) Max = db.Column(db.Float) Min = db.Column(db.Float)
class Task(db.Model): __tablename__ = "tasks" id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(200), nullable=False) parent_list = Column(Integer, ForeignKey('lists.id'), nullable=False) time_created = db.Column(DateTime(timezone=True), server_default=func.now()) #time_updated = db.Column(DateTime(timezone=True), onupdate=func.now()) current = db.Column(Boolean, unique=False, default=True) important = db.Column(Boolean, unique=False, default=False) deleted = db.Column(Boolean, unique=False, default=False) completed = db.Column(Boolean, unique=False, default=False)
class data_indicator(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) indicator = db.Column(db.String(50), nullable=False) exchange = db.Column(db.String(50), nullable=False) symbol = db.Column(db.String(50), nullable=False) interval = db.Column(db.String(50), nullable=False) period = db.Column(db.Integer, nullable=False) value = db.Column(db.Integer, nullable=False) created_at = sqlalchemy.Column(sqlalchemy.DateTime, default=lambda: datetime.utcnow()) #app.run(debug=True)
class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True, nullable=False) name = db.Column(db.String(255, convert_unicode=True), nullable=False) pwd = db.Column(db.String(255, convert_unicode=True), nullable=False) mail = db.Column(db.String(255, convert_unicode=True), nullable=False) age = db.Column(db.Integer, nullable=False) created_at = db.Column(db.DateTime, nullable=False, default=datetime.now) updated_at = db.Column(db.DateTime, nullable=False, default=datetime.now, onupdate=datetime.now)
class DepartmentRight(db.Model): __tablename__ = 'DepartmentRight' rightID = db.Column(db.String(100), primary_key=True) areaID = db.Column(db.String(100)) userID = db.Column(db.String(100)) tag = db.Column(db.Integer) def __init__(self, rightID=None, areaID=None, userID=None, tag=0): self.rightID = rightID self.areaID = areaID self.userID = userID self.tag = tag def __repr__(self): return self.rightID @staticmethod def generate(o): res = {} res['rightID'] = o.rightID res['areaID'] = o.areaID res['userID'] = o.userID res['tag'] = o.tag return res
class Department(db.Model): __tablename__ = 'Department' departmentID = db.Column(db.String(100), primary_key=True) departmentName = db.Column(db.String(100)) createTime = db.Column(db.DateTime) def __init__(self, departmentID=None, departmentName=None, createTime=None): self.departmentID = departmentID self.departmentName = departmentName self.createTime = createTime def __repr__(self): return self.departmentID @staticmethod def generate(o): res = {} res['departmentID'] = o.departmentID res['departmentName'] = o.departmentName res['createTime'] = str(o.createTime) return res
class ManagerAchievement(db.Model): __tablename__ = 'ManagerAchievement' achievementID = db.Column(db.String(100), primary_key=True) projectName = db.Column(db.String(100)) companyName = db.Column(db.String(100)) winBiddingDate = db.Column(db.Date) price = db.Column(db.Float) projectManagerName = db.Column(db.String(100)) managerID = db.Column(db.String(100), db.ForeignKey('ProjectManager.managerID')) tag = db.Column(db.Integer) def __init__(self, achievementID=None, projectName=None, companyName=None, winBiddingDate=None, price=0, projectManagerName=None, managerID=None, tag=0): self.achievementID = achievementID self.projectName = projectName self.companyName = companyName self.winBiddingDate = winBiddingDate self.price = price self.projectManagerName = projectManagerName self.managerID = managerID self.tag = tag @staticmethod def generate(c): res = {} res['achievementID'] = c.achievementID res['projectName'] = c.projectName res['companyName'] = c.companyName res['winBiddingDate'] = str(c.winBiddingDate) res['price'] = c.price res['projectManagerName'] = c.projectManagerName res['managerID'] = c.managerID res['tag'] = c.tag return res def __repr__(self): return self.achievementID
class UserModel(db.Model): __tablename__ = 'user' user_id = db.Column(db.Integer(), primary_key=True) username = db.Column(db.String(), unique=True, nullable=False) password = db.Column(db.String(), nullable=False) locations = db.relationship('LocationModel', backref='user') def save_to_db(self): db.session.add(self) db.session.commit() @classmethod def find_by_username(cls, username): return cls.query.filter_by(username=username).first() @staticmethod def generate_hash(password): return sha256.hash(password) @staticmethod def verify_hash(password, hash): return sha256.verify(password, hash)
class Operator(db.Model): __tablename__ = 'Operator' operatorID = db.Column(db.String(100), primary_key=True) userID = db.Column(db.String(100)) tenderID = db.Column(db.String(100)) state = db.Column(db.Integer) def __init__(self, operatorID=None, userID=None, tenderID=None, state=0): self.operatorID = operatorID self.userID = userID self.tenderID = tenderID self.state = state @staticmethod def create(info): operator = Operator( operatorID=info['operatorID'], userID=info['userID'], tenderID=info['tenderID'], state=info['state'], ) db.session.add(operator) return (True, info['operatorID']) @staticmethod def generate(c): res = {} res['operatorID'] = c.operatorID res['userID'] = c.userID res['tenderID'] = c.tenderID res['state'] = c.state return res def __repr__(self): return self.operatorID
class Comment(db.Model): id = db.Column(db.Integer, primary_key=True) body = db.Column(db.String(140)) post_id = db.Column(db.Integer, db.ForeignKey('post.id')) timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) language = db.Column(db.String(5)) def __repr__(self): return '<Comment {}>'.format(self.body)
class Customer_Message(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(30), unique=False, nullable=False) email = db.Column(db.String(120), unique=False, nullable=False) phone = db.Column(db.String(12), unique=False, nullable=True) message = db.Column(db.Text, nullable=False) date_sent = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) def __repr__(self): return f"Customer_Message('{self.name}', '{self.email}','{self.phone}',\nUTC-{self.date_sent}\n'{self.message}')"
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(16), unique=True, nullable=False) email = db.Column(db.String(64), unique=True, nullable=False) image_file = db.Column(db.String(128), nullable=False, default='default.jpg') password = db.Column(db.String(64), nullable=False) role = db.Column(db.String(16), nullable=False, default='BASIC') def __repr__(self): return f"User('{self.username}', {self.email}, {self.image_file})"
class DBArticle(db.Model): __tablename__ = 'articles' url = db.Column(db.Text, db.ForeignKey("scores.url"), primary_key=True) scores = db.relationship("DBScore", backref="scores") datetime = db.Column(db.DateTime) title = db.Column(db.Text) news_co = db.Column(db.String(50)) text = db.Column(db.Text) candidate = db.Column(db.String(15))
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(255), nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) content = db.Column(db.Text, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) tags = db.Column(db.Text, default="") def __repr__(self): return self.id
class Portfolio_Post(db.Model): id = db.Column(db.Integer, primary_key=True) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) title = db.Column(db.String(100), nullable=True) portfolio_picture = db.Column(db.String(30), nullable=False, default="default.jpg") content = db.Column(db.Text, nullable=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Portfolio_Post('{self.title}', '{self.portfolio_picture}', '{self.date_posted}')"
class NarrativeInstance(db.Model): #id = db.Column(db.Integer, primary_key=True, autoincrement=True) narrative_id = db.Column(db.String(32), primary_key=True, nullable=False) narrative_label = db.Column(db.String(32)) story_pattern = db.Column(db.String(32)) user_id = db.Column(db.Integer) algorithm = db.Column(db.String(32)) date_created = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) map_label = db.Column(db.String(16), nullable=False) def __repr__(self): return f"NarrativeInstance('{self.narrative_id}', '{self.user_id}' , {self.date_created})"
class Employee(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) emp_id = db.Column(db.String(30), unique=True, nullable=False) name = db.Column(db.String(30), unique=False, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) features = db.relationship('Feature', secondary=feature_assign, lazy=True, backref=db.backref('employees', lazy='joined')) profile_picture = db.Column(db.String(20), nullable=False, default='default.png') admin = db.Column(db.Boolean, unique=False, default=False) verified = db.Column(db.Boolean, unique=False, default=False) def __repr__(self): return f'Employee {self.name}, Emp_id : {self.emp_id} email : {self.email}'
class Home_Post(db.Model): id = db.Column(db.Integer, primary_key=True) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) title = db.Column(db.String(100), nullable=False, default="Home") content = db.Column(db.Text, nullable=False, default="mi bezonas suoj") main_photo = db.Column(db.String(30), nullable=False, default="default.jpg") user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Home_Post('{self.title}', '{self.content}')"
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(64), index=True, unique=True) email = db.Column(db.String(120), index=True, unique=True) password_hash = db.Column(db.String(128)) about_me = db.Column(db.String(140)) last_seen = db.Column(db.DateTime, default=datetime.utcnow()) posts = db.relationship('Post', backref='author', lazy='dynamic') followed = db.relationship('User', secondary=followers, primaryjoin=(followers.columns.follower_id == id), secondaryjoin=(followers.columns.followed_id == id), backref=db.backref('followers', lazy='dynamic'), lazy='dynamic') def __repr__(self): return f"<User {self.username}>" def set_password(self, password): self.password_hash = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password_hash, password) def avatar(self, size): return f"https://www.gravatar.com/avatar/{md5(self.email.lower().encode('utf-8')).hexdigest()}?" \ f"{urlencode({'d': 'retro', 's': size})}" def is_following(self, user): return self.followed.filter(followers.columns.followed_id == user.id).count() > 0 def follow(self, user): if not self.is_following(user): self.followed.append(user) def unfollow(self, user): if self.is_following(user): self.followed.remove(user) def followed_posts(self): followed = Post.query.join(followers, (followers.columns.followed_id == Post.user_id))\ .filter(followers.columns.follower_id == self.id) own = Post.query.filter_by(user_id=self.id) return followed.union(own).order_by(Post.timestamp.desc()) def get_reset_password_token(self, expires_in=600): return jwt.encode({'reset_password': self.id, 'exp': time() + expires_in}, current_app.config['SECRET_KEY'], algorithm='HS256') @staticmethod def verify_reset_password_token(token): try: id = jwt.decode(token, current_app.config['SECRET_KEY'], algorithms=['HS256'])['reset_password'] except: return return User.query.get(id)
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(256), nullable=False) author = db.Column(db.String(256), nullable=False) date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) content = db.Column(db.String(2048), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) comments = db.relationship('Comment', backref='post', lazy=True) def __repr__(self): return '<Post %r>' % self.title
class TimeReport(db.Model): id = db.Column(db.Integer, primary_key=True) report_id = db.Column(db.Integer, nullable=False) employee_id = db.Column(db.Integer, index=True, nullable=False) date = db.Column(db.Date, index=True, nullable=False) hours_worked = db.Column(db.Float, nullable=False) job_group = db.Column(db.Enum(JobGroup), nullable=False) @validates("hours_worked") def validate_hours(self, key, value): assert 24 >= value > 0 return value
class Essay(db.Model): __tablename__ = 'essay' id = db.Column(db.Integer(), primary_key = True, nullable = False) company_name = db.Column(db.Text()) essays = db.Column(db.Text()) url_link = db.Column(db.Text()) grade = db.Column(db.Float()) keyword = db.Column(db.Text()) def __repr__(self): return f"News {self.id}"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80)) subject = db.Column(db.String(50)) imgFile = db.Column(db.String(128)) date = db.Column(db.DateTime, default=datetime.today()) description = db.Column(db.Text,nullable=False) ownerId = db.Column(db.Integer,db.ForeignKey('user.id'),nullable=False) comment = db.relationship('Comment', backref='post', lazy=True) like = db.relationship('User', secondary=like, lazy='subquery', backref=db.backref('posts', lazy=True)) collect = db.relationship('User', secondary=collect, lazy='subquery', backref=db.backref('Post', lazy=True)) def __repr__(self): return '<Post %r>' % self.id
class Alert(db.Model): __tablename__ = 'alerts' id = db.Column(db.Integer, primary_key=True) ticker_name = db.Column(db.String(), unique=False, nullable=False) price_level = db.Column(db.Float(), unique=False, nullable=True) percentage_change = db.Column(db.Float(), unique=False, nullable=True) date_added = db.Column(db.DateTime, nullable=False, default=datetime.utcnow()) email_alert = db.Column(db.Boolean(), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete="CASCADE"), nullable=False) def __repr__(self): return f'Alert({self.ticker_name}, {self.price_level}, {self.percentage_change}, {self.date_added}, {self.user_id})'
class Feature(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(30), unique=True, nullable=False) description = db.Column(db.Text, nullable=False) target_date = db.Column(db.DateTime, nullable=False) project_id = db.Column(db.Integer, db.ForeignKey('project.id')) priority = db.Column(db.Integer, nullable=True) # class Description(db.Model): # id = db.Column(db.Integer,primary_key=True) # priority = db.Column(db.Integer,nullable=False) # description = db.Column(db.Text, nullable=False)
class Position(db.Model): __tablename__ = 'position' id = db.Column(db.Integer, primary_key=True) ticker_name = db.Column(db.String(), unique=True, nullable=False) avg_purchase_price = db.Column(db.String(), unique=False, nullable=False) quantity = db.Column(db.String(), unique=False, nullable=False) currency = db.Column(db.String(), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete="CASCADE"), nullable=False) def __repr__(self): return f"Position('{self.ticker_name}', '{self.avg_purchase_price}', '{self.quantity}', '{self.currency}')"