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, 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 #3
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 #4
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 #5
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 #6
0
def retrieve_the_note_with_note_key(step):
    world.test_note = NoteManager.get_note(world.note._id)
Example #7
0
def checks_that_note_is_deleted(step):
    world.test_note = NoteManager.get_note(world.note._id)
    assert world.test_note is None