Exemple #1
0
    def create(user, name, color):
        """ Create a new notebook """

        if len(name) > 24:
            raise UnprocessableEntity(description="NOTEBOOK_NAME_MAX_LENGTH")

        current_time = int(time.time())
        notebook = Notebook(name=name,
                            color=color,
                            user=user.id,
                            created_at=current_time,
                            updated_at=current_time)

        notebook.save()

        return notebook.transform()
Exemple #2
0
from models import Notebook, TextNote, VideoNote

bio = Notebook("Bio 201 Notes")

bio.notes.append(TextNote("This is the first day of Bio 201"))
bio.notes.append(TextNote("Final exam is 95%."))
bio.notes.append(VideoNote("https://www.youtube.com/watch?v=PKffm2uI4dk"))

bio.display()
bio.save("bio201.txt")
bio.load("bio201.txt")

print(bio.to_json())