# Path: lazysignup/constants.py
# USER_AGENT_BLACKLIST = []
# 
# Path: lazysignup/utils.py
# def is_lazy_user(user):
#     """ Return True if the passed user is a lazy user. """
#     # Anonymous users are not lazy.
# 
#     if user.is_anonymous:
#         return False
# 
#     # Check the user backend. If the lazy signup backend
#     # authenticated them, then the user is lazy.
#     backend = getattr(user, 'backend', None)
#     if backend == 'lazysignup.backends.LazySignupBackend':
#         return True
# 
#     # Otherwise, we have to fall back to checking the database.
#     from lazysignup.models import LazyUser
#     return bool(LazyUser.objects.filter(user=user).count() > 0)


from functools import wraps
from django.conf import settings
from django.contrib.auth import SESSION_KEY
from django.contrib.auth import authenticate
from django.contrib.auth import get_user
from django.contrib.auth import login
from django.shortcuts import redirect
from functools import WRAPPER_ASSIGNMENTS
from lazysignup.constants import USER_AGENT_BLACKLIST
from lazysignup.utils import is_lazy_user
                from lazysignup.models import LazyUser



ALLOW_LAZY_REGISTRY = {}


def allow_lazy_user(func):
    def wrapped(request, *args, **kwargs):
        assert hasattr(request, 'session'), ("You need to have the session "
                                             "app installed")
        if getattr(settings, 'LAZYSIGNUP_ENABLE', True):
            # If the user agent is one we ignore, bail early
            ignore = False
            request_user_agent = request.META.get('HTTP_USER_AGENT', '')

# Path: lazysignup/constants.py
# USER_AGENT_BLACKLIST = []
# 
# Path: lazysignup/utils.py
# def is_lazy_user(user):
#     """ Return True if the passed user is a lazy user. """
#     # Anonymous users are not lazy.
# 
#     if user.is_anonymous:
#         return False
# 
#     # Check the user backend. If the lazy signup backend
#     # authenticated them, then the user is lazy.
#     backend = getattr(user, 'backend', None)
#     if backend == 'lazysignup.backends.LazySignupBackend':
#         return True
# 
#     # Otherwise, we have to fall back to checking the database.
#     from lazysignup.models import LazyUser
#     return bool(LazyUser.objects.filter(user=user).count() > 0)


# Path: lazysignup/decorators.py
from functools import wraps
from django.conf import settings
from django.contrib.auth import SESSION_KEY
from django.contrib.auth import authenticate
from django.contrib.auth import get_user
from django.contrib.auth import login
from django.shortcuts import redirect
from functools import WRAPPER_ASSIGNMENTS
from lazysignup.constants import USER_AGENT_BLACKLIST
from lazysignup.utils import is_lazy_user
                from lazysignup.models import LazyUser




ALLOW_LAZY_REGISTRY = {}


def allow_lazy_user(func):
    def wrapped(request, *args, **kwargs):
        assert hasattr(request, 'session'), ("You need to have the session "
                                             "app installed")
        if getattr(settings, 'LAZYSIGNUP_ENABLE', True):
            # If the user agent is one we ignore, bail early
            ignore = False
            request_user_agent = request.META.get('HTTP_USER_AGENT', '')

            for user_agent in USER_AGENT_BLACKLIST: