@@ -321,37 +321,31 @@ def _validate_limitations(self, items_count):
321321 if items_count > response .data .project_limit .remaining_image_count :
322322 raise AppValidationException (constances .COPY_PROJECT_LIMIT_ERROR_MESSAGE )
323323
324- def validate_project_type (self ):
325- if self ._project .project_type in constances .LIMITED_FUNCTIONS :
326- raise AppValidationException (
327- constances .LIMITED_FUNCTIONS [self ._project .project_type ]
328- )
329-
330324 def validate_item_names (self ):
331325 if self ._item_names :
332326 self ._item_names = list (set (self ._item_names ))
333327
334328 def execute (self ):
335329 if self .is_valid ():
336- skipped_images , duplications = [], []
337- if not self ._item_names :
330+ if self ._item_names :
331+ items = self ._items
332+ else :
338333 condition = (
339334 Condition ("team_id" , self ._project .team_id , EQ )
340335 & Condition ("project_id" , self ._project .uuid , EQ )
341336 & Condition ("folder_id" , self ._from_folder .uuid , EQ )
342337 )
343- items = self ._items .get_all (condition )
344- items_to_copy = [item .name for item in items ]
345- else :
346- items = self ._backend_service .get_bulk_images (
347- project_id = self ._project .uuid ,
348- team_id = self ._project .team_id ,
349- folder_id = self ._to_folder .uuid ,
350- images = self ._item_names ,
351- )
352- duplications = [item ["name" ] for item in items ]
353- items_to_copy = set (self ._item_names ) - set (duplications )
354- skipped_images = duplications
338+ items = [item .name for item in self ._items .get_all (condition )]
339+
340+ existing_items = self ._backend_service .get_bulk_images (
341+ project_id = self ._project .uuid ,
342+ team_id = self ._project .team_id ,
343+ folder_id = self ._to_folder .uuid ,
344+ images = items ,
345+ )
346+ duplications = [item ["name" ] for item in existing_items ]
347+ items_to_copy = list (set (items ) - set (duplications ))
348+ skipped_images = duplications
355349 try :
356350 self ._validate_limitations (len (items_to_copy ))
357351 except AppValidationException as e :
@@ -382,7 +376,7 @@ def execute(self):
382376 self ._response .errors = AppException (e )
383377 return self ._response
384378 self .reporter .log_info (
385- f"Copied { len (items_to_copy )} /{ len (items )} items (s) from "
379+ f"Copied { len (items_to_copy )} /{ len (items )} item (s) from "
386380 f"{ self ._project .name } { '' if self ._from_folder .is_root else f'/{ self ._from_folder .name } ' } to "
387381 f"{ self ._project .name } { '' if self ._to_folder .is_root else f'/{ self ._to_folder .name } ' } "
388382 )
@@ -394,14 +388,14 @@ class MoveItems(BaseReportableUseCae):
394388 CHUNK_SIZE = 1000
395389
396390 def __init__ (
397- self ,
398- reporter : Reporter ,
399- project : ProjectEntity ,
400- from_folder : FolderEntity ,
401- to_folder : FolderEntity ,
402- item_names : List [str ],
403- items : BaseReadOnlyRepository ,
404- backend_service_provider : SuperannotateServiceProvider ,
391+ self ,
392+ reporter : Reporter ,
393+ project : ProjectEntity ,
394+ from_folder : FolderEntity ,
395+ to_folder : FolderEntity ,
396+ item_names : List [str ],
397+ items : BaseReadOnlyRepository ,
398+ backend_service_provider : SuperannotateServiceProvider ,
405399 ):
406400 super ().__init__ (reporter )
407401 self ._project = project
@@ -452,11 +446,11 @@ def execute(self):
452446 project_id = self ._project .uuid ,
453447 from_folder_id = self ._from_folder .uuid ,
454448 to_folder_id = self ._to_folder .uuid ,
455- images = items [i : i + self .CHUNK_SIZE ], # noqa: E203
449+ images = items [i : i + self .CHUNK_SIZE ], # noqa: E203
456450 )
457451 )
458452 self .reporter .log_info (
459- f"Moved { len (moved_images )} /{ len (items )} items (s) from "
453+ f"Moved { len (moved_images )} /{ len (items )} item (s) from "
460454 f"{ self ._project .name } { '' if self ._from_folder .is_root else f'/{ self ._from_folder .name } ' } to "
461455 f"{ self ._project .name } { '' if self ._to_folder .is_root else f'/{ self ._to_folder .name } ' } "
462456 )
0 commit comments