""" This module holds the managers and querysets for the ``common`` app. """

from django.db import models

from mtp.apps.sync.managers import SyncableManager


class ReferenceableManager(models.Manager):
    """The Manager for the ``mtp.apps.common.models.Referenceable`` model.

    Notes
    -----
    This manager should not be used as the default (`objects`) one.

    """

    def get_queryset(self):
        """Get only reference instances."""

        return super().get_queryset().filter(is_reference=True)


class ReferenceableSyncableManager(ReferenceableManager, SyncableManager):
    """The Manager for the models that are ``Referenceable`` AND ``Syncable`.

    Notes
    -----
    This manager should not be used as the default (`objects`) one.

    """

    def get_queryset(self):
        """Get only reference instances that are not deleted"""

        return super().get_queryset().non_deleted()
