# Path: account/conf.py
# def load_path_attr(path):
#     def configure_hookset(self, value):
# class AccountAppConf(AppConf):
#     OPEN_SIGNUP = True
#     LOGIN_URL = "account_login"
#     LOGOUT_URL = "account_logout"
#     SIGNUP_REDIRECT_URL = "/"
#     LOGIN_REDIRECT_URL = "/"
#     LOGOUT_REDIRECT_URL = "/"
#     PASSWORD_CHANGE_REDIRECT_URL = "account_password"
#     PASSWORD_RESET_REDIRECT_URL = "account_login"
#     PASSWORD_RESET_TOKEN_URL = "account_password_reset_token"
#     PASSWORD_EXPIRY = 0
#     PASSWORD_USE_HISTORY = False
#     PASSWORD_STRIP = True
#     REMEMBER_ME_EXPIRY = 60 * 60 * 24 * 365 * 10
#     USER_DISPLAY = lambda user: user.username  # noqa
#     CREATE_ON_SAVE = True
#     EMAIL_UNIQUE = True
#     EMAIL_CONFIRMATION_REQUIRED = False
#     EMAIL_CONFIRMATION_EMAIL = True
#     EMAIL_CONFIRMATION_EXPIRE_DAYS = 3
#     EMAIL_CONFIRMATION_AUTO_LOGIN = False
#     EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = "account_login"
#     EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL = None
#     EMAIL_CONFIRMATION_URL = "account_confirm_email"
#     SETTINGS_REDIRECT_URL = "account_settings"
#     NOTIFY_ON_PASSWORD_CHANGE = True
#     DELETION_EXPUNGE_HOURS = 48
#     DEFAULT_HTTP_PROTOCOL = "https"
#     HOOKSET = "account.hooks.AccountDefaultHookSet"
#     TIMEZONES = TIMEZONES
#     LANGUAGES = LANGUAGES
# 
# Path: account/utils.py
# def handle_redirect_to_login(request, **kwargs):
#     login_url = kwargs.get("login_url")
#     redirect_field_name = kwargs.get("redirect_field_name")
#     next_url = kwargs.get("next_url")
#     if login_url is None:
#         login_url = settings.ACCOUNT_LOGIN_URL
#     if next_url is None:
#         next_url = request.get_full_path()
#     try:
#         login_url = reverse(login_url)
#     except NoReverseMatch:
#         if callable(login_url):
#             raise
#         if "/" not in login_url and "." not in login_url:
#             raise
#     url_bits = list(urlparse(force_str(login_url)))
#     if redirect_field_name:
#         querystring = QueryDict(url_bits[4], mutable=True)
#         querystring[redirect_field_name] = next_url
#         url_bits[4] = querystring.urlencode(safe="/")
#     return HttpResponseRedirect(urlunparse(url_bits))


from django.contrib.auth import REDIRECT_FIELD_NAME
from account.conf import settings
from account.utils import handle_redirect_to_login



class LoginRequiredMixin(object):

    redirect_field_name = REDIRECT_FIELD_NAME
    login_url = None

    def dispatch(self, request, *args, **kwargs):
        self.request = request
        self.args = args
        self.kwargs = kwargs
        if request.user.is_authenticated:
            return super(LoginRequiredMixin, self).dispatch(request, *args, **kwargs)
        return self.redirect_to_login()

    def get_login_url(self):
        return self.login_url or settings.ACCOUNT_LOGIN_URL

    def get_next_url(self):
        return self.request.get_full_path()


# Path: account/conf.py
# def load_path_attr(path):
#     def configure_hookset(self, value):
# class AccountAppConf(AppConf):
#     OPEN_SIGNUP = True
#     LOGIN_URL = "account_login"
#     LOGOUT_URL = "account_logout"
#     SIGNUP_REDIRECT_URL = "/"
#     LOGIN_REDIRECT_URL = "/"
#     LOGOUT_REDIRECT_URL = "/"
#     PASSWORD_CHANGE_REDIRECT_URL = "account_password"
#     PASSWORD_RESET_REDIRECT_URL = "account_login"
#     PASSWORD_RESET_TOKEN_URL = "account_password_reset_token"
#     PASSWORD_EXPIRY = 0
#     PASSWORD_USE_HISTORY = False
#     PASSWORD_STRIP = True
#     REMEMBER_ME_EXPIRY = 60 * 60 * 24 * 365 * 10
#     USER_DISPLAY = lambda user: user.username  # noqa
#     CREATE_ON_SAVE = True
#     EMAIL_UNIQUE = True
#     EMAIL_CONFIRMATION_REQUIRED = False
#     EMAIL_CONFIRMATION_EMAIL = True
#     EMAIL_CONFIRMATION_EXPIRE_DAYS = 3
#     EMAIL_CONFIRMATION_AUTO_LOGIN = False
#     EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = "account_login"
#     EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL = None
#     EMAIL_CONFIRMATION_URL = "account_confirm_email"
#     SETTINGS_REDIRECT_URL = "account_settings"
#     NOTIFY_ON_PASSWORD_CHANGE = True
#     DELETION_EXPUNGE_HOURS = 48
#     DEFAULT_HTTP_PROTOCOL = "https"
#     HOOKSET = "account.hooks.AccountDefaultHookSet"
#     TIMEZONES = TIMEZONES
#     LANGUAGES = LANGUAGES
# 
# Path: account/utils.py
# def handle_redirect_to_login(request, **kwargs):
#     login_url = kwargs.get("login_url")
#     redirect_field_name = kwargs.get("redirect_field_name")
#     next_url = kwargs.get("next_url")
#     if login_url is None:
#         login_url = settings.ACCOUNT_LOGIN_URL
#     if next_url is None:
#         next_url = request.get_full_path()
#     try:
#         login_url = reverse(login_url)
#     except NoReverseMatch:
#         if callable(login_url):
#             raise
#         if "/" not in login_url and "." not in login_url:
#             raise
#     url_bits = list(urlparse(force_str(login_url)))
#     if redirect_field_name:
#         querystring = QueryDict(url_bits[4], mutable=True)
#         querystring[redirect_field_name] = next_url
#         url_bits[4] = querystring.urlencode(safe="/")
#     return HttpResponseRedirect(urlunparse(url_bits))


# Path: account/mixins.py
from django.contrib.auth import REDIRECT_FIELD_NAME
from account.conf import settings
from account.utils import handle_redirect_to_login




class LoginRequiredMixin(object):

    redirect_field_name = REDIRECT_FIELD_NAME
    login_url = None

    def dispatch(self, request, *args, **kwargs):
        self.request = request
        self.args = args
        self.kwargs = kwargs
        if request.user.is_authenticated:
            return super(LoginRequiredMixin, self).dispatch(request, *args, **kwargs)
        return self.redirect_to_login()

    def get_login_url(self):
        return self.login_url or settings.ACCOUNT_LOGIN_URL

    def get_next_url(self):
        return self.request.get_full_path()


    def redirect_to_login(self):