openslides_backend/action/relations/single_relation_handler.py
def relation_diffs(
        self, rel_fqids: List[FullQualifiedId]
    ) -> Tuple[Set[FullQualifiedId], Set[FullQualifiedId]]:
        """
        Returns two sets of relation object ids. One with relation objects
        where object should be added and one with relation objects where it
        should be removed.
        """
        add: Set[FullQualifiedId]
        remove: Set[FullQualifiedId]
        # We have to compare with the current datastore state.
        # Retrieve current object from datastore
        current_obj = self.datastore.fetch_model(
            FullQualifiedId(self.model.collection, self.id),
            [self.field_name],
            db_additional_relevance=InstanceAdditionalBehaviour.ONLY_DBINST,
            exception=False,
        )

        # Get current ids from relation field
        current_value = current_obj.get(self.field_name)
        current_fqids = set(
            transform_to_fqids(current_value, self.field.get_target_collection())
        )

        # Calculate add set and remove set
        new_fqids = set(rel_fqids)
        add = new_fqids - current_fqids
        # filter out deleted models, so that in case of cascade deletion no data is lost
        remove = {
            fqid
            for fqid in current_fqids - new_fqids
            if not self.datastore.is_deleted(fqid)
        }

        return add, remove

        Returns two sets of relation object ids. One with relation objects
        where object should be added and one with relation objects where it
        should be removed.
        
Returns two sets of relation object ids. One with relation objects
where object should be added and one with relation objects where it
should be removed.
Returns two sets of relation object ids . One with relation objects where object should be added and one with relation objects where it should be removed .
def relation_diffs(
        self, rel_fqids: List[FullQualifiedId]
    ) -> Tuple[Set[FullQualifiedId], Set[FullQualifiedId]]:
        add: Set[FullQualifiedId]
        remove: Set[FullQualifiedId]
        current_obj = self.datastore.fetch_model(
            FullQualifiedId(self.model.collection, self.id),
            [self.field_name],
            db_additional_relevance=InstanceAdditionalBehaviour.ONLY_DBINST,
            exception=False,
        )
        current_value = current_obj.get(self.field_name)
        current_fqids = set(
            transform_to_fqids(current_value, self.field.get_target_collection())
        )
        new_fqids = set(rel_fqids)
        add = new_fqids - current_fqids
        remove = {
            fqid
            for fqid in current_fqids - new_fqids
            if not self.datastore.is_deleted(fqid)
        }
        return add, remove
def relation_diffs ( self , rel_fqids : List [ FullQualifiedId ] ) -> Tuple [ Set [ FullQualifiedId ] , Set [ FullQualifiedId ] ] : add : Set [ FullQualifiedId ] remove : Set [ FullQualifiedId ] current_obj = self . datastore . fetch_model ( FullQualifiedId ( self . model . collection , self . id ) , [ self . field_name ] , db_additional_relevance = InstanceAdditionalBehaviour . ONLY_DBINST , exception = False , ) current_value = current_obj . get ( self . field_name ) current_fqids = set ( transform_to_fqids ( current_value , self . field . get_target_collection ( ) ) ) new_fqids = set ( rel_fqids ) add = new_fqids - current_fqids remove = { fqid for fqid in current_fqids - new_fqids if not self . datastore . is_deleted ( fqid ) } return add , remove
Returns two sets of relation object ids.
Returns two sets of relation object ids .
"""
        Returns two sets of relation object ids. One with relation objects
        where object should be added and one with relation objects where it
        should be removed.
        """ # We have to compare with the current datastore state. # Retrieve current object from datastore # Get current ids from relation field # Calculate add set and remove set # filter out deleted models, so that in case of cascade deletion no data is lost
self
rel_fqids
List[FullQualifiedId]