from datetime import datetime
from ..extensions import db


class List(db.Model):
    __tablename__ = 'lists'
    id = db.Column(db.Integer, primary_key=True)
    created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False
        )
    name = db.Column(db.String(50), nullable=False)
    todos = db.relationship('Todo', backref='list', lazy='joined')

    def to_json(self):
        json = {c.name: getattr(self, c.name) for c in self.__table__.columns}
        json['todos'] = [todo.to_json() for todo in sorted(self.todos, key=
            lambda t: t.created_at)]
        return json

    def from_json(self, json):
        if 'name' in json:
            self.name = json['name']
        return self

    def mark_all_complete(self):
        for todo in self.todos:
            todo.mark_complete()
        return self

981bda4c981af31063ee8ed9e6a08d287b8e3575
<mask token>


class List(db.Model):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def to_json(self):
        json = {c.name: getattr(self, c.name) for c in self.__table__.columns}
        json['todos'] = [todo.to_json() for todo in sorted(self.todos, key=
            lambda t: t.created_at)]
        return json

    def from_json(self, json):
        if 'name' in json:
            self.name = json['name']
        return self
    <mask token>

<mask token>


class List(db.Model):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def to_json(self):
        json = {c.name: getattr(self, c.name) for c in self.__table__.columns}
        json['todos'] = [todo.to_json() for todo in sorted(self.todos, key=
            lambda t: t.created_at)]
        return json

    def from_json(self, json):
        if 'name' in json:
            self.name = json['name']
        return self

    def mark_all_complete(self):
        for todo in self.todos:
            todo.mark_complete()
        return self

<mask token>


class List(db.Model):
    __tablename__ = 'lists'
    id = db.Column(db.Integer, primary_key=True)
    created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False
        )
    name = db.Column(db.String(50), nullable=False)
    todos = db.relationship('Todo', backref='list', lazy='joined')

    def to_json(self):
        json = {c.name: getattr(self, c.name) for c in self.__table__.columns}
        json['todos'] = [todo.to_json() for todo in sorted(self.todos, key=
            lambda t: t.created_at)]
        return json

    def from_json(self, json):
        if 'name' in json:
            self.name = json['name']
        return self

    def mark_all_complete(self):
        for todo in self.todos:
            todo.mark_complete()
        return self

from datetime import datetime
from ..extensions import db


class List(db.Model):
    __tablename__ = 'lists'
    id = db.Column(db.Integer, primary_key=True)
    created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False
        )
    name = db.Column(db.String(50), nullable=False)
    todos = db.relationship('Todo', backref='list', lazy='joined')

    def to_json(self):
        json = {c.name: getattr(self, c.name) for c in self.__table__.columns}
        json['todos'] = [todo.to_json() for todo in sorted(self.todos, key=
            lambda t: t.created_at)]
        return json

    def from_json(self, json):
        if 'name' in json:
            self.name = json['name']
        return self

    def mark_all_complete(self):
        for todo in self.todos:
            todo.mark_complete()
        return self
