def update(self, request, *args, **kwargs): if not self.parent_resource: return HttpResponse(status=status.HTTP_405_METHOD_NOT_ALLOWED) data = request.DATA.get('data') expressions = data.get('expressions', []) concept_expressions = data.get('concepts', []) mapping_expressions = data.get('mappings', []) cascade_mappings_flag = request.QUERY_PARAMS.get('cascade', 'none') cascade_mappings = self.cascade_mapping_resolver(cascade_mappings_flag) host_url = request.META['wsgi.url_scheme'] + '://' + request.get_host() adding_all = mapping_expressions == '*' or concept_expressions == '*' if adding_all: add_references(self.serializer_class, self.request.user, data, self.parent_resource, host_url, cascade_mappings) return Response([], status=status.HTTP_202_ACCEPTED) (added_references, errors) = add_references(self.serializer_class, self.request.user, data, self.parent_resource, host_url, cascade_mappings) all_expression = expressions + concept_expressions + mapping_expressions added_expression = [ references.expression for references in added_references ] added_original_expression = set([ references.original_expression for references in added_references ] + all_expression) response = [] for expression in added_original_expression: response_item = self.create_response_item(added_expression, errors, expression) if response_item: response.append(response_item) return Response(response, status=status.HTTP_200_OK)
def update(self, request, *args, **kwargs): if not self.parent_resource: return HttpResponse(status=status.HTTP_405_METHOD_NOT_ALLOWED) data = request.DATA.get('data') expressions = data.get('expressions', []) concept_expressions = data.get('concepts', []) mapping_expressions = data.get('mappings', []) cascade_mappings_flag = request.QUERY_PARAMS.get('cascade', 'none') cascade_mappings = self.cascade_mapping_resolver(cascade_mappings_flag) host_url = request.META['wsgi.url_scheme'] + '://' + request.get_host() adding_all = mapping_expressions == '*' or concept_expressions == '*' if adding_all: add_references( self.serializer_class, self.request.user, data, self.parent_resource, host_url, cascade_mappings ) return Response([], status=status.HTTP_202_ACCEPTED) (added_references, errors) = add_references( self.serializer_class, self.request.user, data, self.parent_resource, host_url, cascade_mappings ) all_expression = expressions + concept_expressions + mapping_expressions added_expression = [references.expression for references in added_references] added_original_expression = set([references.original_expression for references in added_references] + all_expression) response = [] for expression in added_original_expression: response_item = self.create_response_item(added_expression, errors, expression) if response_item: response.append(response_item) return Response(response, status=status.HTTP_200_OK)