def MergeFromMessage(self, message): if message.status is not None: self.status = message.status if message.category is not None: self.category = Category.get_by_id(message.category).key if message.title is not None: self.title = message.title if message.description is not None: self.description = message.description
def UpdateCategoryName(self, request): result = CategoryResponse() category = Category.get_by_id(request.id) if category != None: if category.last_updated <= request.client_copy_timestamp and category.user == self.GetUserId(): category.name = request.new_name category.put() result = category.ConvertToResponse() else: raise endpoints.NotFoundException("The item was updated on the outside") else: raise endpoints.NotFoundException('No category entity with the id "%s" exists.' % request.id) return result
def DeleteCategory(self, request): result = CategoryResponse() category = Category.get_by_id(request.id) if category != None: if Task.query(Task.category == category.key).get() == None: if category.last_updated <= request.client_copy_timestamp and category.user == self.GetUserId(): category.key.delete() result = category.ConvertToResponse() else: raise endpoints.NotFoundException("The item was updated on the outside") else: raise endpoints.NotFoundException("This item has child elements") else: raise endpoints.NotFoundException('No category entity with the id "%s" exists.' % request.id) return result