parameters: (self, request, pk=None, project_pk=None)
return_statement: return Response({'success': True}, status=status.HTTP_200_OK)
docstring: Add images to a task
docstring_summary: Add images to a task
docstring_tokens: Add images to a task
function: def upload(self, request, pk=None, project_pk=None):
          """
          Add images to a task
          """
          get_and_check_project(request, project_pk, ('change_project', ))
          try:
              task = self.queryset.get(pk=pk, project=project_pk)
          except (ObjectDoesNotExist, ValidationError):
              raise exceptions.NotFound()
  
          files = flatten_files(request.FILES)
  
          if len(files) == 0:
              raise exceptions.ValidationError(detail=_("No files uploaded"))
  
          with transaction.atomic():
              for image in files:
                  models.ImageUpload.objects.create(task=task, image=image)
  
          task.images_count = models.ImageUpload.objects.filter(task=task).count()
          # Update other parameters such as processing node, task name, etc.
          serializer = TaskSerializer(task, data=request.data, partial=True)
          serializer.is_valid(raise_exception=True)
          serializer.save()
          
          return Response({'success': True}, status=status.HTTP_200_OK)
function_tokens: def upload ( self , request , pk = None , project_pk = None ) : get_and_check_project ( request , project_pk , ( 'change_project' , ) ) try : task = self . queryset . get ( pk = pk , project = project_pk ) except ( ObjectDoesNotExist , ValidationError ) : raise exceptions . NotFound ( ) files = flatten_files ( request . FILES ) if len ( files ) == 0 : raise exceptions . ValidationError ( detail = _ ( "No files uploaded" ) ) with transaction . atomic ( ) : for image in files : models . ImageUpload . objects . create ( task = task , image = image ) task . images_count = models . ImageUpload . objects . filter ( task = task ) . count ( ) # Update other parameters such as processing node, task name, etc. serializer = TaskSerializer ( task , data = request . data , partial = True ) serializer . is_valid ( raise_exception = True ) serializer . save ( ) return Response ( { 'success' : True } , status = status . HTTP_200_OK )