-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
59 lines (48 loc) · 1.86 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from app import db
from flask_wtf import FlaskForm
from wtforms.validators import DataRequired
from sqlalchemy import Column, Integer, String
from wtforms import StringField, PasswordField, SubmitField
from sqlalchemy import Column, Integer, String, Boolean, PickleType
from werkzeug.security import generate_password_hash, check_password_hash
class Audite(db.Model):
__tablename__ = "audites"
TrackingNo = Column(Integer, primary_key=True)
Url = Column(String)
Title = Column(String)
Symbol = Column(String)
PdfUrl = Column(String)
CompanyName = Column(String)
SentDateTime = Column(String)
AttachmentUrl = Column(String)
PublishDateTime = Column(String)
send = Column(Boolean, default=False)
class User(db.Model):
__tablename__ = 'user'
id = Column(Integer(), primary_key=True)
username = Column(String(32), nullable=False, unique=True)
password = Column(String(128), nullable=False, unique=False)
role = Column(Integer(), default=0)
name = Column(String(32), nullable=True, unique=False)
authenticated = Column(Boolean, default=False)
symbols = Column(PickleType, default=[])
phone = Column(String(10), nullable=True, unique=False)
def get_id(self):
return(self.id)
def is_active(self):
return(True)
def is_authenticated(self):
return self.authenticated
def check_password(self, password):
if not password:
return False
return check_password_hash(self.password, password)
def set_password(self, password):
if not password:
return False
self.password = generate_password_hash(password)
class LoginForm(FlaskForm):
"""User Log-in Form."""
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
submit = SubmitField('Log In')