"""This module holds the ``LiveDependencyDuplicator`` for the ``trainings`` app"""


from mtp.discrete_apps.duplicable.duplicators import InstanceDuplicator


class LiveDependencyDuplicator(InstanceDuplicator):
    """Duplicator class used for the ``LiveDependencyMixin``

    For the parameters, see ``InstanceDuplicator``

    """

    def duplicate(self, refs=None, detach=False, **values):
        """Don't duplicate this instance if it's linked to a ``TrainingSession``

        For the parameters, see ``InstanceDuplicator``

        """

        if self.instance.session:
            return None
        else:
            return super().duplicate(refs, detach, **values)
