示例#1
0
    def note_batch_update(self, request):
        for note_repr in request.items:
            note = ndb.Key(urlsafe=note_repr.key).get()
            note.title = note_repr.title
            note.content = note_repr.content

            checklist_items = []
            for item in note_repr.checklist_items:
                checklist_items.append(
                    models.CheckListItem(title=item.title,
                                         checked=item.checked))
            note.checklist_items = checklist_items

            files = []
            for file_id in note_repr.files:
                try:
                    files.append(ndb.Key(urlsafe=file_id).get())
                except TypeError:
                    continue
            note.files = files
            note.put()

        return message_types.VoidMessage()
示例#2
0
    def note_update(self, request):
        note = ndb.Key(urlsafe=request.key).get()
        note.title = request.title
        note.content = request.content
        checklist_items = []
        for item in request.checklist_items:
            checklist_items.append(
                models.CheckListItem(title=item.title, checked=item.checked))
        note.checklist_items = checklist_items

        files = []
        for file_id in request.files:
            try:
                files.append(ndb.Key(urlsafe=file_id).get())
            except TypeError:
                continue
        note.files = files
        note.put()
        return resources.NoteRepr(key=request.key,
                                  title=request.title,
                                  content=request.content,
                                  date_created=request.date_created,
                                  checklist_items=request.checklist_items,
                                  files=request.files)