@define_check
def check_copy_relations(output):
    from cms.plugin_pool import plugin_pool
    from cms.extensions import extension_pool
    from cms.extensions.models import BaseExtension
    from cms.models.pluginmodel import CMSPlugin

    c_to_s = lambda klass: (klass.__module__, klass.__name__) % '%s.%s'

    def get_class(method_name, model):
        for cls in inspect.getmro(model):
            if method_name in cls.__dict__:
                return cls
        return None

    with output.section('Presence of "copy_relations"') as section:
        plugin_pool.discover_plugins()
        for plugin in plugin_pool.plugins.values():
            plugin_class = plugin.model
            if get_class('copy_relations', plugin_class) is not CMSPlugin or plugin_class is CMSPlugin:
                # this class defines a ``copy_relations`` method, nothing more
                # to do
                continue
            for rel in plugin_class._meta.many_to_many:
                section.warn('%s has a many-to-many relation to %s,\n    but no "copy_relations" method defined.' % (
                    c_to_s(plugin_class),
                    c_to_s(rel.model),
                ))
            for rel in plugin_class._get_related_objects():
                if rel.model != CMSPlugin and not issubclass(rel.model, plugin.model) and rel.model != AliasPluginModel:
                    section.warn('%s has a foreign key from %s,\n    but no "copy_relations" method defined.' % (
                        c_to_s(plugin_class),
                        c_to_s(rel.model),
                    ))

        for extension in chain(extension_pool.page_extensions, extension_pool.title_extensions):
            if get_class('copy_relations', extension) is not BaseExtension:
                # OK, looks like there is a 'copy_relations' defined in the
                # extension... move along...
                continue
            for rel in extension._meta.many_to_many:
                if DJANGO_1_8:
                    section.warn('%s has a many-to-many relation to %s,\n    but no "copy_relations" method defined.' % (
                        c_to_s(extension),
                        c_to_s(rel.related.model),
                    ))
                else:
                    section.warn('%s has a many-to-many relation to %s,\n    but no "copy_relations" method defined.' % (
                        c_to_s(extension),
                        c_to_s(rel.remote_field.model),
                    ))
            for rel in extension._get_related_objects():
                if rel.model != extension:
                    section.warn('%s has a foreign key from %s,\n    but no "copy_relations" method defined.' % (
                        c_to_s(extension),
                        c_to_s(rel.model),
                    ))

        if not section.warnings:
            section.finish_success('All plugins and page/title extensions have "copy_relations" method if needed.')
        else:
            section.finish_success('Some plugins or page/title extensions do not define a "copy_relations" method.\nThis might lead to data loss when publishing or copying plugins/extensions.\nSee https://django-cms.readthedocs.org/en/latest/extending_cms/custom_plugins.html#handling-relations or https://django-cms.readthedocs.org/en/latest/extending_cms/extending_page_title.html#handling-relations.')
dataset/ETHPy150Open divio/django-cms/cms/utils/check.py/check_copy_relations/swapped operands of `%`