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


Python views.logout方法代码示例

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


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

示例1: get

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def get(self, request, *args, **kwargs):
        context = self.get_context()
        defaults = {
            'extra_context': context,
            'current_app': self.admin_site.name,
            'template_name': self.logout_template or 'xadmin/views/logged_out.html',
        }
        if self.logout_template is not None:
            defaults['template_name'] = self.logout_template

        self.update_params(defaults)
        return logout(request, **defaults) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:14,代码来源:website.py

示例2: process_view

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def process_view(self, request, view_func, view_args, view_kwargs):
        """ Forwards unauthenticated requests to the admin page to the CAS
            login URL, as well as calls to django.contrib.auth.views.login and
            logout.
        """
        if view_func == login:
            return cas_login(request, *view_args, **view_kwargs)
        if view_func == logout:
            return cas_logout(request, *view_args, **view_kwargs)
        
        # The rest of this method amends the Django admin authorization wich
        # will post a username/password dialog to authenticate to django admin.
        if not view_func.__module__.startswith('django.contrib.admin.'):
            return None

        if request.user.is_authenticated():
            if request.user.is_staff:
                return None
            else:
                raise PermissionDenied("No staff priviliges")
        params = urlencode({auth.REDIRECT_FIELD_NAME: request.get_full_path()})        
        return HttpResponseRedirect(settings.LOGIN_URL + '?' + params) 
开发者ID:childe,项目名称:esproxy,代码行数:24,代码来源:middleware.py

示例3: logout

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def logout(self, request, extra_context=None):
        """
        Logs out the user for the given HttpRequest.

        This should *not* assume the user is already logged in.
        """
        from django.contrib.auth.views import logout
        defaults = {
            'extra_context': dict(self.each_context(request), **(extra_context or {})),
        }
        if self.logout_template is not None:
            defaults['template_name'] = self.logout_template
        request.current_app = self.name
        return logout(request, **defaults) 
开发者ID:drexly,项目名称:openhgsenti,代码行数:16,代码来源:sites.py

示例4: logout

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def logout(self, request, extra_context=None):
        """
        Logs out the user for the given HttpRequest.

        This should *not* assume the user is already logged in.
        """
        from django.contrib.auth.views import logout
        defaults = {
            'current_app': self.name,
            'extra_context': dict(self.each_context(request), **(extra_context or {})),
        }
        if self.logout_template is not None:
            defaults['template_name'] = self.logout_template
        return logout(request, **defaults) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:16,代码来源:sites.py

示例5: test_resolve_url__view_function

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def test_resolve_url__view_function(self):
        """
        Tests that passing a view name to ``resolve_url`` will result in the
        URL path mapping to that view name.
        """
        resolved_url = resolve_url(logout)
        self.assertEqual('/accounts/logout/', resolved_url) 
开发者ID:arteria,项目名称:django-compat,代码行数:9,代码来源:test_compat.py

示例6: test_resolve_url__valid_view_name

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def test_resolve_url__valid_view_name(self):
            """
            Tests that passing a view function to ``resolve_url`` will result in
            the URL path mapping to that view.
            """
            resolved_url = resolve_url('django.contrib.auth.views.logout')
            self.assertEqual('/accounts/logout/', resolved_url) 
开发者ID:arteria,项目名称:django-compat,代码行数:9,代码来源:test_compat.py

示例7: test_url_template_tag

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def test_url_template_tag(self):
        template = Template(
            '{% load url from compat %}'
            '<a href="{% url "logout" %}">Log out</a>'
        )
        html = template.render(Context({}))
        self.assertEqual(
            html,
            '<a href="/accounts/logout/">Log out</a>'
        ) 
开发者ID:arteria,项目名称:django-compat,代码行数:12,代码来源:test_compat.py

示例8: get

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def get(self, request, *args, **kwargs):
        context = self.get_context()
        defaults = {
            'extra_context': context,
            # 'current_app': self.admin_site.name,
            'template_name': self.logout_template or 'xadmin/views/logged_out.html',
        }
        if self.logout_template is not None:
            defaults['template_name'] = self.logout_template

        self.update_params(defaults)
        return logout(request, **defaults) 
开发者ID:myminwang,项目名称:myblog,代码行数:14,代码来源:website.py

示例9: get

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def get(self,request):
        check = self.request.GET.get('check',False)
        if check in ['true','false',False]:#solve ast malformed string exception
            check = {'true':True,'false':False}[str(check).lower()]
        else:
            check = ast.literal_eval(check)
        if self.request.user == 'AnonymousUser':
            user = {'upn': 'ANONYMOUS'}
        else:
            user = {'upn': str(self.request.user)}
        if check and self.request.user.is_authenticated():
            response = HttpResponse(u'authenticated')
            response["Access-Control-Allow-Origin"] = "*"
            response["Server"] = "GateOne"
            return response
        logout_get = self.request.GET.get("logout", None)
        if logout_get:
            logout(request)
            response = HttpResponse('/')
            response.delete_cookie('gateone_user')            
            self.user_logout(request)
            return response
        next_url = self.request.GET.get("next", None)
        if next_url:
            return redirect(next_url)
        return redirect(getsettings('url_prefix','/')) 
开发者ID:jimmy201602,项目名称:django-gateone,代码行数:28,代码来源:views.py

示例10: process_exception

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def process_exception(self, request, exception):
        """ When we get a CasTicketException it is probably caused by the ticket timing out.
            So logout and get the same page again."""
        if isinstance(exception, CasTicketException):
            auth.logout(request)
            return HttpResponseRedirect(request.path)
        else:
            return None 
开发者ID:childe,项目名称:esproxy,代码行数:10,代码来源:middleware.py

示例11: test_logout_url

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def test_logout_url(self):
        self.check_url('/accounts/logout/', auth_views.logout) 
开发者ID:nlhkabu,项目名称:connect,代码行数:4,代码来源:test_views.py

示例12: logout

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def logout(*args, **kwargs):
    auth_views.logout(*args, **kwargs)
    return redirect('login') 
开发者ID:arecker,项目名称:moolah,代码行数:5,代码来源:urls.py

示例13: logout

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def logout(request, next_page=None, template_name='registration/logged_out.html',
           redirect_field_name=REDIRECT_FIELD_NAME, extra_context=None):
    """
    This can replace your default logout view. In you settings, do:

    from django.core.urlresolvers import reverse_lazy
    LOGOUT_URL = reverse_lazy('logout')
    """
    original_session = request.session.get(la_settings.USER_SESSION_FLAG)

    if original_session:
        restore_original_login(request)
        return redirect(la_settings.LOGOUT_REDIRECT)
    else:
        return original_logout(request, next_page, template_name, redirect_field_name, extra_context) 
开发者ID:CroceRossaItaliana,项目名称:jorvik,代码行数:17,代码来源:viste.py

示例14: get

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def get(self, request):
        template_response = views.logout(request)
        messages.success(request, 'You have been logged out')
        return redirect(reverse('chatdemo:login')) 
开发者ID:ploggingdev,项目名称:djangochat,代码行数:6,代码来源:views.py

示例15: admin_view

# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import logout [as 别名]
def admin_view(self, view, cacheable=False):
        """
        Decorator to create an admin view attached to this ``AdminSite``. This
        wraps the view and provides permission checking by calling
        ``self.has_permission``.

        You'll want to use this from within ``AdminSite.get_urls()``:

            class MyAdminSite(AdminSite):

                def get_urls(self):
                    from django.conf.urls import url

                    urls = super(MyAdminSite, self).get_urls()
                    urls += [
                        url(r'^my_view/$', self.admin_view(some_view))
                    ]
                    return urls

        By default, admin_views are marked non-cacheable using the
        ``never_cache`` decorator. If the view can be safely cached, set
        cacheable=True.
        """
        def inner(request, *args, **kwargs):
            if not self.has_permission(request):
                if request.path == reverse('admin:logout', current_app=self.name):
                    index_path = reverse('admin:index', current_app=self.name)
                    return HttpResponseRedirect(index_path)
                # Inner import to prevent django.contrib.admin (app) from
                # importing django.contrib.auth.models.User (unrelated model).
                from django.contrib.auth.views import redirect_to_login
                return redirect_to_login(
                    request.get_full_path(),
                    reverse('admin:login', current_app=self.name)
                )
            return view(request, *args, **kwargs)
        if not cacheable:
            inner = never_cache(inner)
        # We add csrf_protect here so this function can be used as a utility
        # function for any view, without having to repeat 'csrf_protect'.
        if not getattr(view, 'csrf_exempt', False):
            inner = csrf_protect(inner)
        return update_wrapper(inner, view) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:45,代码来源:sites.py


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