@classmethod
def can_view(cls, user):
    """
        Check that the given a user instance has access to the metric.

        This requires the user instance to have the
        :attr:`~django.contrib.auth.models.PermissionsMixin.is_superuser` and
        :attr:`~django.contrib.auth.models.PermissionsMixin.is_staff` flags as
        well as the
        :meth:`~django.contrib.auth.models.PermissionsMixin.has_perm` method.

        Users with ``is_superuser=True`` will always have access to a metric.
        Users with ``is_staff=True`` will have access if and only if the user
        has the permission :attr:`permission_name`.
        """
    return user.is_superuser or user.is_staff and user.has_perm(cls.
        permission_key)
