• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_next_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sumo.utils.get_next_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_next_url函数的具体用法?Python get_next_url怎么用?Python get_next_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: login

def login(request, template):
    """Try to log the user in."""
    if request.method == 'GET' and not request.MOBILE:
        url = reverse('users.auth') + '?' + request.GET.urlencode()
        return HttpResponsePermanentRedirect(url)

    next_url = get_next_url(request) or reverse('home')
    form = handle_login(request)

    if request.user.is_authenticated():
        # Add a parameter so we know the user just logged in.
        # fpa =  "first page authed" or something.
        next_url = urlparams(next_url, fpa=1)
        res = HttpResponseRedirect(next_url)
        max_age = (None if settings.SESSION_EXPIRE_AT_BROWSER_CLOSE
                        else settings.SESSION_COOKIE_AGE)
        res.set_cookie(settings.SESSION_EXISTS_COOKIE,
                       '1',
                       secure=False,
                       max_age=max_age)
        return res

    if request.MOBILE:
        return jingo.render(request, template, {
            'form': form,
        })

    return user_auth(request, login_form=form)
开发者ID:lonnen,项目名称:kitsune,代码行数:28,代码来源:views.py


示例2: join_contributors

def join_contributors(request):
    """Join the Contributors group."""
    next = get_next_url(request) or reverse('home')
    group = Group.objects.get(name='Contributors')
    request.user.groups.add(group)
    messages.add_message(request, messages.SUCCESS,
                         _('You are now part of the Contributors group!'))
    return HttpResponseRedirect(next)
开发者ID:bajubullet,项目名称:kitsune,代码行数:8,代码来源:views.py


示例3: logout

def logout(request):
    """Log the user out."""
    auth.logout(request)
    statsd.incr('user.logout')

    res = HttpResponseRedirect(get_next_url(request) or reverse('home'))
    res.delete_cookie(settings.SESSION_EXISTS_COOKIE)
    return res
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:8,代码来源:views.py


示例4: logout

def logout(request):
    """Log the user out."""
    auth.logout(request)
    next_url = get_next_url(request) if 'next' in request.GET else ''

    res = HttpResponseRedirect(next_url or reverse('home'))
    res.delete_cookie(settings.SESSION_EXISTS_COOKIE)
    return res
开发者ID:lmorchard,项目名称:kitsune,代码行数:8,代码来源:views.py


示例5: login

def login(request):
    """Try to log the user in."""
    next_url = get_next_url(request) or reverse('home')
    form = handle_login(request)

    if request.user.is_authenticated():
        return HttpResponseRedirect(next_url)

    return jingo.render(request, 'users/login.html',
                        {'form': form, 'next_url': next_url})
开发者ID:Akamad007,项目名称:kitsune,代码行数:10,代码来源:views.py


示例6: watch_locale

def watch_locale(request):
    """Watch/unwatch a locale."""
    locale = request.locale
    if request.POST.get('watch') == 'yes':
        NewPostInLocaleEvent.notify(request.user, locale=locale)
        NewThreadInLocaleEvent.notify(request.user, locale=locale)
    else:
        NewPostInLocaleEvent.stop_notifying(request.user, locale=locale)
        NewThreadInLocaleEvent.stop_notifying(request.user, locale=locale)

    return HttpResponseRedirect(get_next_url(request))
开发者ID:Akamad007,项目名称:kitsune,代码行数:11,代码来源:views.py


示例7: login

def login(request):
    """Try to log the user in."""
    next_url = get_next_url(request) or reverse('home')
    form = handle_login(request)

    if request.user.is_authenticated():
        res = HttpResponseRedirect(next_url)
        res.set_cookie(settings.SESSION_EXISTS_COOKIE, '1', secure=False)
        return res

    return jingo.render(request, 'users/login.html',
                        {'form': form, 'next_url': next_url})
开发者ID:lmorchard,项目名称:kitsune,代码行数:12,代码来源:views.py


示例8: watch_locale

def watch_locale(request):
    """Watch/unwatch a locale."""
    locale = request.LANGUAGE_CODE
    if request.POST.get('watch') == 'yes':
        NewPostInLocaleEvent.notify(request.user, locale=locale)
        NewThreadInLocaleEvent.notify(request.user, locale=locale)
        statsd.incr('kbforums.watches.locale')
    else:
        NewPostInLocaleEvent.stop_notifying(request.user, locale=locale)
        NewThreadInLocaleEvent.stop_notifying(request.user, locale=locale)

    # If there is no next url, send the user to the home page.
    return HttpResponseRedirect(get_next_url(request) or reverse('home'))
开发者ID:LASarkar,项目名称:kitsune,代码行数:13,代码来源:views.py


示例9: watch_locale

def watch_locale(request):
    """Watch/unwatch a locale."""
    locale = request.locale
    if request.POST.get("watch") == "yes":
        NewPostInLocaleEvent.notify(request.user, locale=locale)
        NewThreadInLocaleEvent.notify(request.user, locale=locale)
        statsd.incr("kbforums.watches.locale")
    else:
        NewPostInLocaleEvent.stop_notifying(request.user, locale=locale)
        NewThreadInLocaleEvent.stop_notifying(request.user, locale=locale)

    # If there is no next url, send the user to the home page.
    return HttpResponseRedirect(get_next_url(request) or reverse("home"))
开发者ID:georgedorn,项目名称:kitsune,代码行数:13,代码来源:views.py


示例10: user_auth

def user_auth(request, contributor=False, register_form=None,
        login_form=None):
    """Try to log the user in, or register a user.

    POSTs from these forms do not come back to this view, but instead go to the
    login and register views, which may redirect back to this in case of error.
    """
    next_url = get_next_url(request) or reverse('home')

    if login_form is None:
        login_form = AuthenticationForm()
    if register_form is None:
        register_form = RegisterForm()

    return render(request, 'users/auth.html', {
        'login_form': login_form,
        'register_form': register_form,
        'contributor': contributor,
        'next_url': next_url})
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:19,代码来源:views.py


示例11: login

def login(request, template):
    """Try to log the user in."""
    if request.method == 'GET' and not request.MOBILE:
        url = reverse('users.auth') + '?' + request.GET.urlencode()
        return HttpResponsePermanentRedirect(url)

    next_url = get_next_url(request) or reverse('home')
    form = handle_login(request)

    if request.user.is_authenticated():
        res = HttpResponseRedirect(next_url)
        max_age = (None if settings.SESSION_EXPIRE_AT_BROWSER_CLOSE
                        else settings.SESSION_COOKIE_AGE)
        res.set_cookie(settings.SESSION_EXISTS_COOKIE,
                       '1',
                       secure=False,
                       max_age=max_age)
        return res

    return user_auth(request, login_form=form)
开发者ID:victorneo,项目名称:kitsune,代码行数:20,代码来源:views.py


示例12: test_get

 def test_get(self):
     """'next' can be a query-string parameter."""
     r = self.r.get('/users/login', {'next': '/kb/new'})
     eq_('/kb/new', get_next_url(r))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:4,代码来源:test__utils.py


示例13: logout

def logout(request):
    """Log the user out."""
    auth.logout(request)
    next_url = get_next_url(request) if 'next' in request.GET else ''

    return HttpResponseRedirect(next_url or reverse('home'))
开发者ID:Akamad007,项目名称:kitsune,代码行数:6,代码来源:views.py


示例14: locales

def locales(request):
    """The locale switcher page."""

    return jingo.render(request, 'sumo/locales.html', dict(
        next_url=get_next_url(request) or reverse('home')))
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:5,代码来源:views.py


示例15: test_bad_host_protocol_relative

 def test_bad_host_protocol_relative(self):
     """Protocol-relative URLs do not let bad hosts through."""
     r = self.r.get('/', {'next': '//example.com'})
     eq_(None, get_next_url(r))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:4,代码来源:test__utils.py


示例16: test_http

 def test_http(self):
     """Verify that protocol and domain get removed for http."""
     r = self.r.post('/users/login',
                     {'next': 'http://su.mo.com/kb/new'})
     eq_('/kb/new', get_next_url(r))
开发者ID:AutomatedTester,项目名称:kitsune,代码行数:5,代码来源:test__utils.py


示例17: test_post

 def test_post(self):
     """'next' in POST overrides GET."""
     r = self.r.post('/?next=/foo', {'next': '/bar'})
     eq_('/bar', get_next_url(r))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:4,代码来源:test__utils.py


示例18: test_good_host_https

 def test_good_host_https(self):
     """Full URLs work with valid hosts."""
     r = self.r.post('/users/login',
                     {'next': 'https://su.mo.com/kb/new'})
     eq_('https://su.mo.com/kb/new', get_next_url(r))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:5,代码来源:test__utils.py


示例19: test_query_string

 def test_query_string(self):
     """Query-strings remain intact."""
     r = self.r.get('/', {'next': '/new?f=b'})
     eq_('/new?f=b', get_next_url(r))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:4,代码来源:test__utils.py


示例20: _get_next_url_fallback_localization

def _get_next_url_fallback_localization(request):
    return get_next_url(request) or reverse('dashboards.localization')
开发者ID:fox2mike,项目名称:kitsune,代码行数:2,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.paginate函数代码示例发布时间:2022-05-27
下一篇:
Python urlresolvers.split_path函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap