Example #1
0
    def get(self, noteid):
        '''
        Returns all notes at JSON format.
        '''

        note = NoteManager.get_note(noteid)
        self.return_one_document_or_404(note, "No note exist for this id.")
Example #2
0
    def get(self):
        '''
        Returns all notes ordered by date at JSON format.
        '''

        notes = NoteManager.get_all_sorted_by_date()
        self.return_documents(notes)
Example #3
0
    def get(self):
        '''
        Returns all notes ordered by title at JSON format.
        '''

        notes = NoteManager.get_all()
        self.return_documents(notes)
Example #4
0
    def get(self):
        '''
        * GET: Return the HTML representation of all notes.
        '''

        notes = NoteManager.get_all()
        self.render("templates/note_rows.html", notes=notes)
Example #5
0
    def get(self, noteId):
        '''
        Returns for given id the HTML representation of corresponding 
        note.
        '''

        note = NoteManager.get_note(noteId)
        if note:

            if note.content:
                 note.content = markdown.markdown(note.content)

            self.render("templates/note.html", note=note)
        else:
            self.return_failure("Note not found.", 404)
Example #6
0
    def delete(self, noteid):
        '''
        Deletes note that has an ID equal to noteid with received data.
        '''

        logger.info("Note deletion received.")

        note = NoteManager.get_note(noteid)

        if note:
            self.create_owner_deletion_activity(note, "deletes", "note")
            note.delete()
            self.return_success("Note deleted.")

        else:
            self.return_failure("No note to delete.", 404)
Example #7
0
    def convert(self, data):
        '''
        Expect to have an attachments field in given dict. When dict has some
        attachments, it retrieves corresponding docs and convert them in
        attachment dict (same as usual dict with less fields).
        Then attach docs are returned inside an array.
        '''

        docs = []
        self.fileDocs = []
        for doc in data.get("attachments", []):
            if doc["type"] == "Note":
                note = NoteManager.get_note(doc["id"])
                docs.append(note.toDictForAttachment())
            elif doc["type"] == "Picture":
                picture = PictureManager.get_picture(doc["id"])
                docs.append(picture.toDictForAttachment())
                self.fileDocs.append(picture)

        return docs
Example #8
0
    def put(self, noteid):
        '''
        Modifies note that has an ID equal to noteid with received data.
        '''

        logger.info("Note modificiation received.")

        note = NoteManager.get_note(noteid)      
        data = self.get_body_as_dict(expectedFields=["title", "content"]) 

        if data and note:
            note.title = data["title"]
            note.content = data["content"]
            
            note.save()

            self.return_success("Note successfully modified.")

        else:
            self.return_failure("No note exist for this id.", 404)
Example #9
0
def retrieve_all_notes(step):
    world.test_notes = NoteManager.get_all().all()
Example #10
0
def retrieve_the_note_with_note_key(step):
    world.test_note = NoteManager.get_note(world.note._id)
Example #11
0
def delete_all_notes(scenario):
    notes = NoteManager.get_all()
    for note in notes:
        note.delete()
Example #12
0
def checks_that_note_is_deleted(step):
    world.test_note = NoteManager.get_note(world.note._id)
    assert world.test_note is None
Example #13
0
def retrieve_sorted_by_date_all_notes(step):    
    world.test_notes = NoteManager.get_all_sorted_by_date().all()