class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) full_name = db.Column(db.String(20), nullable=False) email = db.Column(db.String(30), unique=True, nullable=False) password = db.Column(db.String(100), nullable=False) def get_reset_token(self, expires_sec=1800): """Gets token for confirming email input: arg1:optional expires sec(default is 1800 ) output: a serializer token.""" s = Serializer(current_app.config["SECRET_KEY"], expires_sec) return s.dumps({"user_id": self.id}).decode("utf-8") @staticmethod def verify_reset_token(token): s = Serializer(current_app.config["SECRET_KEY"]) try: user_id = s.loads(token)["user_id"] except: return None return User.query.get(user_id) def __repr__(self): return "user({0}, {1})".format(self.full_name, self.email)
class EngInternationalNews(db.Model): ''' Provides date(model created), id atrribute by default Initialize with compulsory source : news source like 'the-washington-post' raw_date: date provided by the website itself summary : news summary title : title of the news Optional initialization image_link news_link ''' __tablename__ = 'ENG_INTERNATIONAL' id = db.Column(db.Integer, primary_key=True) source = db.Column( db.String(20), nullable=False, ) raw_date = db.Column(db.Text, nullable=False) date = db.Column(db.DateTime, nullable=True, default=datetime.utcnow) summary = db.Column(db.Text, ) title = db.Column(db.Text, nullable=False) image_link = db.Column(db.Text) news_link = db.Column(db.Text, ) def __repr__(self): return 'news({0}, {1}, {2})'.format(self.id, self.source, self.date)
class EngNationalNews(db.Model): """ Provides date(model created), id atrribute by default Initialize with compulsory source : news source like 'ekantipur' raw_date: date provided by the website itself summary : news summary title : title of the news Optional initialization image_link news_link """ __tablename__ = "ENG_NATIONAL" id = db.Column(db.Integer, primary_key=True) source = db.Column(db.String(20), nullable=False) date = db.Column(db.DateTime, nullable=True, default=datetime.utcnow) raw_date = db.Column(db.Text, nullable=False) summary = db.Column(db.Text) title = db.Column(db.Text, nullable=False) image_link = db.Column(db.Text) news_link = db.Column(db.Text) def __repr__(self): return "news({0}, {1}, {2})".format(self.id, self.source, self.date)