Commit 4a34a407 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

wording

parent 5ce4ec59
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -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.
@@ -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
@@ -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():
@@ -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.
@@ -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
@@ -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:
@@ -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