def post(self, *args, **kwargs): action_list = self.get_angular_argument('action_list') if not action_list: return ActionType.update_position(action_list)
def post(self, *args, **kwargs): """新建""" action_name = self.get_angular_argument('name') if not action_name: self.on_error(**ErrorCodeMessage.action_name_illegal) return action = ActionType.add(action_name) if not action: self.on_error(**ErrorCodeMessage.database_error) return self.on_success(action.to_dict())
def delete(self, action_id, *args, **kwargs): """删除""" if not action_id: self.on_error(**ErrorCodeMessage.action_not_exists) return action = ActionType.init_from_action_id(action_id) if not action: self.on_error(**ErrorCodeMessage.action_not_exists) return if action.delete(): self.on_success() else: self.on_error(**ErrorCodeMessage.database_error)
def post(self, *args, **kwargs): action_id = self.get_angular_argument('id') if not action_id: self.on_error(**ErrorCodeMessage.action_not_exists) return action = ActionType.init_from_action_id(action_id) if not action: self.on_error(**ErrorCodeMessage.action_not_exists) return if action.recover(): self.on_success() return else: self.on_error(**ErrorCodeMessage.database_error)
def put(self, *args, **kwargs): """改名""" action_name = self.get_angular_argument('name') action_id = self.get_angular_argument('id') if not action_id: self.on_error(**ErrorCodeMessage.action_not_exists) return action = ActionType.init_from_action_id(action_id) if not action: self.on_error(**ErrorCodeMessage.action_not_exists) return if not action_name: self.on_error(**ErrorCodeMessage.action_name_illegal) return if action.edit_name(action_name): self.on_success() else: self.on_error(**ErrorCodeMessage.database_error)
def get(self, *args, **kwargs): action_instance_list = ActionType.get_all_action() self.on_success([i.to_dict() for i in action_instance_list])