Example #1
0
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)
Example #2
0
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}")'
Example #3
0
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})>'
Example #4
0
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}")'
Example #5
0
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}'
Example #6
0
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}')"
Example #7
0
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)
Example #8
0
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}')"
Example #9
0
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)
Example #10
0
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()
Example #11
0
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}' )"
Example #12
0
class Todo(db.Model):
    __tablename__ = "todo"
    id = db.Column('id', db.Integer, primary_key=True)
    category_id = db.Column('category_id', db.Integer,
                            db.ForeignKey('category.id'))
    priority_id = db.Column('priority_id', db.Integer,
                            db.ForeignKey('priority.id'))
    description = db.Column('description', db.Unicode)
    creation_date = db.Column('creation_date', db.Date)
    is_done = db.Column('is_done', db.Boolean)

    priority = db.relationship('Priority', foreign_keys=priority_id)
    category = db.relationship('Category', foreign_keys=category_id)
Example #13
0
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)
Example #14
0
class Category(db.Model):
    __tablename__ = "category"
    id = db.Column('id', db.Integer, primary_key=True)
    name = db.Column('name', db.Unicode)
Example #15
0
class Priority(db.Model):
    __tablename__ = "priority"
    id = db.Column('id', db.Integer, primary_key=True)
    name = db.Column('name', db.Unicode)
    value = db.Column('value', db.Integer)
Example #16
0
class Priority(db.Model):
	__tablename__ = 'priority'
	name = db.Column('name', db.String(50), primary_key=True)

	def __init__(self, name):
		self.name = name