'If settings.REGISTRATION_MODE does not exist, such as during a test, return True
Return `True` if permission is granted, `False` otherwise.'

def has_permission(self, request, view):

    try:
        if (settings.REGISTRATION_MODE == 'disabled'):
            raise exceptions.PermissionDenied('Registration    is    disabled')
        if (settings.REGISTRATION_MODE == 'enabled'):
            return True
        elif (settings.REGISTRATION_MODE == 'admin_only'):
            return request.user.is_superuser
        else:
            raise Exception('{}    is    not    a    valid    registation    mode'.format(settings.REGISTRATION_MODE))
    except AttributeError:
        return True
