class Feedback(db.Model): id = db.Column(db.Integer, primary_key=True) 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) def __repr__(self): return f"Feedback('{self.title}', '{self.date_posted}')"
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.png') password = db.Column(db.String(60), nullable=False) user_admin = db.Column(db.Boolean, default=False) bio = db.Column(db.Text(), default='Too lazy to make bio') posts = db.relationship('Post', backref='author', lazy=True) opinion = db.relationship('Feedback', backref='_user', lazy=True) language = db.Column(db.String(3), nullable=False, default='en') theme = db.Column(db.String(5), nullable=False, default='light') def check_for_admin(self): if self.email in os.environ['MY_EMAIL'].split(): self.user_admin = True def get_reset_token(self, expires_sec=1800): 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 f"User('{self.username}', '{self.email}', '{self.image_file}')"
class DataRegistered(db.Model): id = db.Column(db.Integer, unique=True, primary_key=True, autoincrement=True) date_recorded = db.Column(db.DateTime, nullable=False, default=datetime.now) user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False) def __repr__(self): return f"Data({self.date_recorded})"
class Subscriber(db.Model): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(120), unique=True, nullable=False) area = db.Column(db.String(120), nullable=False) topic = db.Column(db.String(120), nullable=False) def __repr__(self): return f"User('{self.email}', '{self.area}', '{self.topic}')" def get_area(self): return self.area def get_topic(self): return self.topic
class User(db.Model): id = db.Column(db.Integer, unique=True, primary_key=True, autoincrement=True) first = db.Column(db.String(120), unique=False, nullable=False) last = db.Column(db.String(120), unique=False, nullable=False) age = db.Column(db.Integer, nullable=False) address = db.Column(db.String(120), unique=False, nullable=False) email = db.Column(db.String(60), unique=True, nullable=False) phone = db.Column(db.Integer, unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default="default.jpg") time_check = db.Column(db.DateTime, nullable=False, default=datetime.now) data = db.relationship("DataRegistered", backref="author", lazy=True) def __repr__(self): return ( f"User({self.first}, {self.last}, {self.age}, {self.phone}, {self.address})" )
class OAuth(OAuthConsumerMixin, db.Model): user_id = db.Column(db.Integer, db.ForeignKey(User.id)) user = db.relationship(User)
class Note(db.Model): id = db.Column(db.Integer, primary_key=True) data = db.Column(db.String(10000)) date = db.Column(db.DateTime(timezone=True), default=func.now()) user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(150), unique=True) password = db.Column(db.String(150)) first_name = db.Column(db.String(150)) notes = db.relationship('Note')
class Agency(db.Model): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(120), unique=True, nullable=False) def __repr__(self): return f"User('{self.id}', '{self.email}')"