当前位置: 首页>>代码示例>>Python>>正文


Python settings.LOGOUT_URL属性代码示例

本文整理汇总了Python中django.conf.settings.LOGOUT_URL属性的典型用法代码示例。如果您正苦于以下问题:Python settings.LOGOUT_URL属性的具体用法?Python settings.LOGOUT_URL怎么用?Python settings.LOGOUT_URL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.conf.settings的用法示例。


在下文中一共展示了settings.LOGOUT_URL属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: media

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def media(request):
    """
    Add context things that we need
    """
    # A/B testing: half of instructors and TAs see a different search box
    instr_ta = is_instr_ta(request.user.username)
    instr_ta_ab = instr_ta and request.user.is_authenticated and request.user.id % 2 == 0
    # GRAD_DATE(TIME?)_FORMAT for the grad/ra/ta apps
    return {'GRAD_DATE_FORMAT': settings.GRAD_DATE_FORMAT,
            'GRAD_DATETIME_FORMAT': settings.GRAD_DATETIME_FORMAT,
            'LOGOUT_URL': settings.LOGOUT_URL,
            'LOGIN_URL': settings.LOGIN_URL,
            'STATIC_URL': settings.STATIC_URL,
            'is_instr_ta': instr_ta,
            'instr_ta_ab': instr_ta_ab,
            'request_path': request.path,
            'CourSys': product_name(request),
            'help_email': help_email(request),
            } 
开发者ID:sfu-fas,项目名称:coursys,代码行数:21,代码来源:context.py

示例2: test_change_password_sets_logout_reason

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def test_change_password_sets_logout_reason(self):
        api.keystone.user_update_own_password(IsA(http.HttpRequest),
                                              'oldpwd',
                                              'normalpwd').AndReturn(None)
        self.mox.ReplayAll()

        formData = {'method': 'PasswordForm',
                    'current_password': 'oldpwd',
                    'new_password': 'normalpwd',
                    'confirm_password': 'normalpwd'}
        res = self.client.post(INDEX_URL, formData, follow=False)

        self.assertRedirectsNoFollow(res, settings.LOGOUT_URL)
        self.assertIn('logout_reason', res.cookies)
        self.assertEqual(res.cookies['logout_reason'].value,
                         "Password changed. Please log in again to continue.")
        scheme, netloc, path, query, fragment = urlsplit(res.url)
        redirect_response = res.client.get(path, http.QueryDict(query))
        self.assertRedirectsNoFollow(redirect_response, settings.LOGIN_URL) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:21,代码来源:tests.py

示例3: handle

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def handle(self, request, data):
        user_is_editable = api.keystone.keystone_can_edit_user()

        if user_is_editable:
            try:
                api.keystone.user_update_own_password(request,
                                                      data['current_password'],
                                                      data['new_password'])
                response = http.HttpResponseRedirect(settings.LOGOUT_URL)
                msg = _("Password changed. Please log in again to continue.")
                utils.add_logout_reason(request, response, msg)
                return response
            except Exception:
                exceptions.handle(request,
                                  _('Unable to change password.'))
                return False
        else:
            messages.error(request, _('Changing password is not supported.'))
            return False 
开发者ID:CiscoSystems,项目名称:avos,代码行数:21,代码来源:forms.py

示例4: get_redirect_url

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def get_redirect_url(self):
        ret = self.request.GET.get(
            self.redirect_field_name, settings.LOGOUT_URL)
        return ret 
开发者ID:django-leonardo,项目名称:django-leonardo,代码行数:6,代码来源:views.py

示例5: _configure_settings

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def _configure_settings(self):
        # Setup the configuration as described in the documentation
        bossoidc.settings.configure_oidc('https://auth',
                                         'client_id',
                                         'https://localhost')

        # Copy the values into the active settings
        settings.LOGIN_URL = bossoidc.settings.LOGIN_URL
        settings.LOGOUT_URL = bossoidc.settings.LOGOUT_URL
        settings.OIDC_PROVIDERS = bossoidc.settings.OIDC_PROVIDERS
        settings.OIDC_AUTH = bossoidc.settings.OIDC_AUTH 
开发者ID:jhuapl-boss,项目名称:boss-oidc,代码行数:13,代码来源:test_views.py

示例6: get_context_data

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)
        context.update({
            "logout_url": settings.LOGOUT_URL,
            "login_url": settings.LOGIN_URL,
        })
        if self.request.user.is_authenticated:
            context.update({
                "user_attrs": sorted([(field.name, getattr(self.request.user, field.name)) for field in self.request.user._meta.get_fields() if field.concrete]),
                "known_sp_ids": [sp for sp in ServiceProvider.objects.filter(active=True)],
            })
        return context 
开发者ID:OTA-Insight,项目名称:djangosaml2idp,代码行数:14,代码来源:views.py

示例7: get_context_data

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)
        context.update({
            "logout_url": settings.LOGOUT_URL,
            "login_url": settings.LOGIN_URL,
        })
        if self.request.user.is_authenticated:
            context.update({
                "user_attrs": sorted([(field.name, getattr(self.request.user, field.name)) for field in self.request.user._meta.get_fields() if field.concrete]),
            })
        return context


# TODO fix this in IdP side? 
开发者ID:OTA-Insight,项目名称:djangosaml2idp,代码行数:16,代码来源:views.py

示例8: test_logout_message

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def test_logout_message(self):
        login = self.client.login(username=self.user.username, password="123456", request=MockRequest(self.user))
        self.assertEqual(login, True)

        response = self.client.get(dj_settings.LOGOUT_URL, follow=True)
        self.assertIn("You are now logged out. Have a nice day!", str(response.content)) 
开发者ID:Inboxen,项目名称:Inboxen,代码行数:8,代码来源:test_misc.py

示例9: test_anonymous

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def test_anonymous(self):
        response = self.client.get(settings.LOGOUT_URL, follow=True)
        url = urls.reverse("download-email-view", kwargs={"email": self.email.eid,
                                                          "inbox": self.email.inbox.inbox,
                                                          "domain": self.email.inbox.domain.domain})
        response = self.client.get(url)
        self.assertRedirects(response,
                             "{}?next={}".format(settings.LOGIN_URL, url),
                             fetch_redirect_response=False) 
开发者ID:Inboxen,项目名称:Inboxen,代码行数:11,代码来源:test_email.py

示例10: logout_with_message

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def logout_with_message(request, msg):
    """Send HttpResponseRedirect to LOGOUT_URL.

    `msg` is a message displayed on the login page after the logout, to explain
    the logout reason.
    """
    logout(request)
    response = http.HttpResponseRedirect(
        '%s?next=%s' % (settings.LOGOUT_URL, request.path))
    add_logout_reason(request, response, msg)
    return response 
开发者ID:CiscoSystems,项目名称:avos,代码行数:13,代码来源:functions.py

示例11: process_response

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def process_response(self, request, response):
        """Convert HttpResponseRedirect to HttpResponse if request is via ajax
        to allow ajax request to redirect url
        """

        if request.is_ajax() and hasattr(request, 'horizon'):
            queued_msgs = request.horizon['async_messages']
            if type(response) == http.HttpResponseRedirect:
                # Drop our messages back into the session as per usual so they
                # don't disappear during the redirect. Not that we explicitly
                # use django's messages methods here.
                for tag, message, extra_tags in queued_msgs:
                    getattr(django_messages, tag)(request, message, extra_tags)
                # if response['location'].startswith(settings.LOGOUT_URL):
                #     redirect_response = http.HttpResponse(status=401)
                #     # This header is used for handling the logout in JS
                #     redirect_response['logout'] = True
                #     if self.logout_reason is not None:
                #         utils.add_logout_reason(
                #             request, redirect_response, self.logout_reason)
                # else:
                redirect_response = http.HttpResponse()
                # Use a set while checking if we want a cookie's attributes
                # copied
                cookie_keys = set(('max_age', 'expires', 'path', 'domain',
                                   'secure', 'httponly', 'logout_reason'))
                # Copy cookies from HttpResponseRedirect towards HttpResponse
                for cookie_name, cookie in six.iteritems(response.cookies):
                    cookie_kwargs = dict((
                        (key, value) for key, value in six.iteritems(cookie)
                        if key in cookie_keys and value
                    ))
                    redirect_response.set_cookie(
                        cookie_name, cookie.value, **cookie_kwargs)
                redirect_response['X-Horizon-Location'] = response['location']
                upload_url_key = 'X-File-Upload-URL'
                if upload_url_key in response:
                    self.copy_headers(response, redirect_response,
                                      (upload_url_key, 'X-Auth-Token'))
                return redirect_response
            if queued_msgs:
                # TODO(gabriel): When we have an async connection to the
                # client (e.g. websockets) this should be pushed to the
                # socket queue rather than being sent via a header.
                # The header method has notable drawbacks (length limits,
                # etc.) and is not meant as a long-term solution.
                response['X-Horizon-Messages'] = json.dumps(queued_msgs)
        return response 
开发者ID:django-leonardo,项目名称:django-leonardo,代码行数:50,代码来源:horizon.py

示例12: process_response

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import LOGOUT_URL [as 别名]
def process_response(self, request, response):
        """Convert HttpResponseRedirect to HttpResponse if request is via ajax
        to allow ajax request to redirect url
        """
        if request.is_ajax() and hasattr(request, 'horizon'):
            queued_msgs = request.horizon['async_messages']
            if type(response) == http.HttpResponseRedirect:
                # Drop our messages back into the session as per usual so they
                # don't disappear during the redirect. Not that we explicitly
                # use django's messages methods here.
                for tag, message, extra_tags in queued_msgs:
                    getattr(django_messages, tag)(request, message, extra_tags)
                if response['location'].startswith(settings.LOGOUT_URL):
                    redirect_response = http.HttpResponse(status=401)
                    # This header is used for handling the logout in JS
                    redirect_response['logout'] = True
                    if self.logout_reason is not None:
                        utils.add_logout_reason(
                            request, redirect_response, self.logout_reason)
                else:
                    redirect_response = http.HttpResponse()
                # Use a set while checking if we want a cookie's attributes
                # copied
                cookie_keys = set(('max_age', 'expires', 'path', 'domain',
                                   'secure', 'httponly', 'logout_reason'))
                # Copy cookies from HttpResponseRedirect towards HttpResponse
                for cookie_name, cookie in six.iteritems(response.cookies):
                    cookie_kwargs = dict((
                        (key, value) for key, value in six.iteritems(cookie)
                        if key in cookie_keys and value
                    ))
                    redirect_response.set_cookie(
                        cookie_name, cookie.value, **cookie_kwargs)
                redirect_response['X-Horizon-Location'] = response['location']
                return redirect_response
            if queued_msgs:
                # TODO(gabriel): When we have an async connection to the
                # client (e.g. websockets) this should be pushed to the
                # socket queue rather than being sent via a header.
                # The header method has notable drawbacks (length limits,
                # etc.) and is not meant as a long-term solution.
                response['X-Horizon-Messages'] = json.dumps(queued_msgs)
        return response 
开发者ID:CiscoSystems,项目名称:avos,代码行数:45,代码来源:middleware.py


注:本文中的django.conf.settings.LOGOUT_URL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。