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(100), unique=True, nullable=False) profile_image = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) tasks = db.relationship('Task', backref='author', lazy=True) def __repr__(self): return f"(User ('{self.username}', '{self.email}' )" def get_reset_token(self, expires_sec=600): 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)
class Task(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(30), nullable=False) description = db.Column(db.String(120), nullable=False) deadline = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f'<Task({self.title}{self.deadline})>'
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) password = db.Column(db.String(60), nullable=False) todos = db.relationship('Todo', backref='author', lazy=True) def __repr__(self): return f'User("{self.username}", "{self.email}")'
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(30), unique=True, nullable=False) email = db.Column(db.String(30), unique=True, nullable=False) password = db.Column(db.String(120), nullable=False) image = db.Column(db.Text, nullable=True, default="profile.png") tasks = db.relationship('Task', backref='person', lazy=True) def __repr__(self): return f'{self.username}'
class User(db.Model): __tablename__ = 'users' id: int = db.Column(db.Integer, primary_key=True, autoincrement=True) name: str = db.Column(db.String(100), nullable=False) email: str = db.Column(db.String(200), nullable=False) created_at: datetime = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) updated_at: datetime = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) def __repr__(self): return 'User({}, name: {}, email: {}, created: {}, updated: {})'.format(self.id, self.name, self.email, self.created_at, self.updated_at)
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.jpeg') password = db.Column(db.String(60), nullable=False) posts = db.relationship('ToDoList', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Task(db.Model): __tablename__ = 'task' id = db.Column('id', db.Integer, primary_key = True) description = db.Column('description',db.String(140)) category = db.Column('category', db.String(50), db.ForeignKey(Category.name)) priority = db.Column('priority', db.String(50), db.ForeignKey(Priority.name)) priority_r = db.relationship('Priority', foreign_keys=priority) category_r = db.relationship('Category', foreign_keys=category) def __init__(self, desc,cat, pri): self.description = desc self.category = cat self.priority = pri # db.create_all()
class Todo(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(50)) description = db.Column(db.Text, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f'Todo("{self.title}")'
class Task(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(50), nullable=False) content = db.Column(db.Text, nullable=False) done = db.Column(db.Boolean, default=False) created = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"(Task ('{self.title}', '{self.created}' )"
class ToDoList(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), 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) def __repr__(self): return f"List('{self.title}', '{self.date_posted}')"
class TodoList(db.Model): __tablename__ = 'todo_lists' id: int = db.Column(db.Integer, primary_key=True, autoincrement=True) name: str = db.Column(db.String(100), nullable=False) user_id: int = db.Column(db.Integer, db.ForeignKey('users.id')) user: User = db.relationship('User') created_at: datetime = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) updated_at: datetime = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) def __repr__(self): return 'List({}, name: {}, owner: {}, created: {}, updated: {})'.format(self.id, self.name, self.user_id, self.created_at, self.updated_at)
class Task(db.Model): __tablename__ = 'tasks' id: int = db.Column(db.Integer, primary_key=True, autoincrement=True) list_id: int = db.Column(db.Integer, db.ForeignKey('todo_lists.id')) list: TodoList = db.relationship('TodoList', backref='tasks') desc: str = db.Column(db.String(500), nullable=False) status: int = db.Column(db.Integer, default=0, nullable=False) created_at: datetime = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) updated_at: datetime = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) def __repr__(self): return 'Task({}, list: {}, desc: {}, created: {}, updated: {})'.format(self.id, self.list_id, self.desc, self.created_at, self.updated_at)
class Priority(db.Model): __tablename__ = 'priority' name = db.Column('name', db.String(50), primary_key=True) def __init__(self, name): self.name = name