Loading rpc/methods.py +12 −8 Original line number Diff line number Diff line Loading @@ -1472,7 +1472,7 @@ def set_metas_to_resource(user: User, resource_id: int, metas: List[dict]) -> bo @_log_call @_rpc_groups(["Metadatas", "Collections"]) def set_metas_to_collection( user: User, collection_id: int, metas: List[dict], cascade: bool = False user: User, collection_id: int, metas: List[dict], recursive: bool = False ) -> bool: """ Sets all metas for a unique metadata set. Loading @@ -1481,7 +1481,7 @@ def set_metas_to_collection( All metas must share the same metadata set. If cascade is True, the meta will be added to all descendants, If recursive is True, the meta will be added to all descendants, collections and resources alike. """ # prevent mixing metas from different sets Loading Loading @@ -1513,7 +1513,7 @@ def set_metas_to_collection( for meta_dict in metas: add_meta_to_collection(user, collection_id, meta_dict["id"], meta_dict["value"]) if cascade: if recursive: for descendant_collection in collection_instance.descendants(): set_metas_to_collection(user, descendant_collection.pk, metas, False) for descendant_resource in collection_instance.descendants_resources(): Loading Loading @@ -1569,7 +1569,7 @@ def add_meta_to_resource( @_log_call @_rpc_groups(["Metadatas", "Collections"]) def remove_meta_value_from_collection( user: User, collection_id: int, meta_value_id: int, cascade: bool = False user: User, collection_id: int, meta_value_id: int, recursive: bool = False ) -> bool: """ Remove a meta value from a collection given their ids. Loading @@ -1584,7 +1584,7 @@ def remove_meta_value_from_collection( for meta_value in collection_instance.metadatacollectionvalue_set.all(): if meta_value.id == meta_value_id: meta_value.delete() if cascade: if recursive: for descendant_collection_instance in collection_instance.descendants(): remove_meta_value_from_collection( user, descendant_collection_instance.pk, meta_value_id Loading @@ -1599,12 +1599,16 @@ def remove_meta_value_from_collection( @_log_call @_rpc_groups(["Metadatas", "Collections"]) def add_meta_to_collection( user: User, collection_id: int, meta_id: int, meta_value: str, cascade: bool = False user: User, collection_id: int, meta_id: int, meta_value: str, recursive: bool = False, ) -> int: """ Add a meta value to a collection given their ids. If cascade is True, the meta will be added to all descendants, If recursive is True, the meta will be added to all descendants, collections and resources alike. """ if meta_value == "" or meta_value is None: Loading @@ -1627,7 +1631,7 @@ def add_meta_to_collection( meta_value_instance, created = MetadataCollectionValue.objects.get_or_create( metadata=meta, collection=collection_instance, value=meta_value ) if cascade: if recursive: for descendant_collection in collection_instance.descendants(): add_meta_to_collection( user, descendant_collection.pk, meta_id, meta_value, False Loading Loading
rpc/methods.py +12 −8 Original line number Diff line number Diff line Loading @@ -1472,7 +1472,7 @@ def set_metas_to_resource(user: User, resource_id: int, metas: List[dict]) -> bo @_log_call @_rpc_groups(["Metadatas", "Collections"]) def set_metas_to_collection( user: User, collection_id: int, metas: List[dict], cascade: bool = False user: User, collection_id: int, metas: List[dict], recursive: bool = False ) -> bool: """ Sets all metas for a unique metadata set. Loading @@ -1481,7 +1481,7 @@ def set_metas_to_collection( All metas must share the same metadata set. If cascade is True, the meta will be added to all descendants, If recursive is True, the meta will be added to all descendants, collections and resources alike. """ # prevent mixing metas from different sets Loading Loading @@ -1513,7 +1513,7 @@ def set_metas_to_collection( for meta_dict in metas: add_meta_to_collection(user, collection_id, meta_dict["id"], meta_dict["value"]) if cascade: if recursive: for descendant_collection in collection_instance.descendants(): set_metas_to_collection(user, descendant_collection.pk, metas, False) for descendant_resource in collection_instance.descendants_resources(): Loading Loading @@ -1569,7 +1569,7 @@ def add_meta_to_resource( @_log_call @_rpc_groups(["Metadatas", "Collections"]) def remove_meta_value_from_collection( user: User, collection_id: int, meta_value_id: int, cascade: bool = False user: User, collection_id: int, meta_value_id: int, recursive: bool = False ) -> bool: """ Remove a meta value from a collection given their ids. Loading @@ -1584,7 +1584,7 @@ def remove_meta_value_from_collection( for meta_value in collection_instance.metadatacollectionvalue_set.all(): if meta_value.id == meta_value_id: meta_value.delete() if cascade: if recursive: for descendant_collection_instance in collection_instance.descendants(): remove_meta_value_from_collection( user, descendant_collection_instance.pk, meta_value_id Loading @@ -1599,12 +1599,16 @@ def remove_meta_value_from_collection( @_log_call @_rpc_groups(["Metadatas", "Collections"]) def add_meta_to_collection( user: User, collection_id: int, meta_id: int, meta_value: str, cascade: bool = False user: User, collection_id: int, meta_id: int, meta_value: str, recursive: bool = False, ) -> int: """ Add a meta value to a collection given their ids. If cascade is True, the meta will be added to all descendants, If recursive is True, the meta will be added to all descendants, collections and resources alike. """ if meta_value == "" or meta_value is None: Loading @@ -1627,7 +1631,7 @@ def add_meta_to_collection( meta_value_instance, created = MetadataCollectionValue.objects.get_or_create( metadata=meta, collection=collection_instance, value=meta_value ) if cascade: if recursive: for descendant_collection in collection_instance.descendants(): add_meta_to_collection( user, descendant_collection.pk, meta_id, meta_value, False Loading