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

Python helpers.user_link函数代码示例

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

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



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

示例1: test_user_link

def test_user_link():
    u = UserProfile(username='jconnor', display_name='John Connor', pk=1)
    eq_(user_link(u), '<a href="%s">John Connor</a>' %
        reverse('users.profile', args=[1]))

    # handle None gracefully
    eq_(user_link(None), '')
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:7,代码来源:test_helpers.py


示例2: test_users_list

def test_users_list():
    u1 = UserProfile(username="jconnor", display_name="John Connor", pk=1)
    u2 = UserProfile(username="sconnor", display_name="Sarah Connor", pk=2)
    eq_(users_list([u1, u2]), ", ".join((user_link(u1), user_link(u2))))

    # handle None gracefully
    eq_(user_link(None), "")
开发者ID:beenishkhan,项目名称:zamboni,代码行数:7,代码来源:test_helpers.py


示例3: test_users_list

def test_users_list():
    u1 = UserProfile(username='jconnor', display_name='John Connor', pk=1)
    u2 = UserProfile(username='sconnor', display_name='Sarah Connor', pk=2)
    eq_(users_list([u1, u2]), ', '.join((user_link(u1), user_link(u2))))

    # handle None gracefully
    eq_(user_link(None), '')
开发者ID:psyko0815,项目名称:olympia,代码行数:7,代码来源:test_helpers.py


示例4: test_users_list

def test_users_list():
    u1 = UserProfile(firstname='John', lastname='Connor', pk=1)
    u2 = UserProfile(firstname='Sarah', lastname='Connor', pk=2)
    eq_(users_list([u1, u2]), ', '.join((user_link(u1), user_link(u2))))

    # handle None gracefully
    eq_(user_link(None), '')
开发者ID:chowse,项目名称:zamboni,代码行数:7,代码来源:test_helpers.py


示例5: test_user_link

def test_user_link():
    u = UserProfile(username='jconnor', display_name='John Connor', pk=1)
    eq_(user_link(u),
        '<a href="%s" title="%s">John Connor</a>' % (u.get_url_path(),
                                                     u.name))

    # handle None gracefully
    eq_(user_link(None), '')
开发者ID:psyko0815,项目名称:olympia,代码行数:8,代码来源:test_helpers.py


示例6: test_user_link_unicode

def test_user_link_unicode():
    """make sure helper won't choke on unicode input"""
    u = UserProfile(username=u'jmüller', display_name=u'Jürgen Müller', pk=1)
    eq_(user_link(u), u'<a href="%s">Jürgen Müller</a>' % u.get_url_path())

    u = UserProfile(username='\xe5\xaf\x92\xe6\x98\x9f', pk=1)
    eq_(user_link(u),
        u'<a href="%s">%s</a>' % (u.get_url_path(), u.username))
开发者ID:Dreadchild,项目名称:zamboni,代码行数:8,代码来源:test_helpers.py


示例7: test_short_users_list

def test_short_users_list():
    """Test the option to shortened the users list to a certain size."""
    # short list with 'others'
    u1 = UserProfile(username='oscar', display_name='Oscar the Grouch', pk=1)
    u2 = UserProfile(username='grover', display_name='Grover', pk=2)
    u3 = UserProfile(username='cookies!', display_name='Cookie Monster', pk=3)
    shortlist = users_list([u1, u2, u3], size=2)
    eq_(shortlist, ', '.join((user_link(u1), user_link(u2))) + ', others')
开发者ID:psyko0815,项目名称:olympia,代码行数:8,代码来源:test_helpers.py


示例8: test_user_link_unicode

def test_user_link_unicode():
    """make sure helper won't choke on unicode input"""
    u = UserProfile(username=u"jmüller", display_name=u"Jürgen Müller", pk=1)
    eq_(user_link(u), u'<a href="%s">Jürgen Müller</a>' % reverse("users.profile", args=[1]))

    u = UserProfile(username="\xe5\xaf\x92\xe6\x98\x9f", pk=1)
    url = reverse("users.profile", args=[1])
    eq_(user_link(u), u'<a href="%s">%s</a>' % (url, u.username))
开发者ID:beenishkhan,项目名称:zamboni,代码行数:8,代码来源:test_helpers.py


示例9: test_user_link_unicode

def test_user_link_unicode():
    """make sure helper won't choke on unicode input"""
    u = UserProfile(username=u'jmüller', display_name=u'Jürgen Müller', pk=1)
    eq_(user_link(u), u'<a href="%s">Jürgen Müller</a>' %
        reverse('users.profile', args=[1]))

    u = UserProfile(username='\xe5\xaf\x92\xe6\x98\x9f', pk=1)
    url = reverse('users.profile', args=[1])
    eq_(user_link(u),
        u'<a href="%s">%s</a>' % (url, u.username.decode('utf-8')))
开发者ID:MechanisM,项目名称:zamboni,代码行数:10,代码来源:test_helpers.py


示例10: test_user_link_xss

def test_user_link_xss():
    u = UserProfile(username='jconnor',
                    display_name='<script>alert(1)</script>', pk=1)
    html = "&lt;script&gt;alert(1)&lt;/script&gt;"
    eq_(user_link(u), '<a href="%s" title="%s">%s</a>' % (u.get_url_path(),
                                                          html, html))

    u = UserProfile(username='jconnor',
                    display_name="""xss"'><iframe onload=alert(3)>""", pk=1)
    html = """xss&#34;&#39;&gt;&lt;iframe onload=alert(3)&gt;"""
    eq_(user_link(u), '<a href="%s" title="%s">%s</a>' % (u.get_url_path(),
                                                          html, html))
开发者ID:psyko0815,项目名称:olympia,代码行数:12,代码来源:test_helpers.py


示例11: to_string

    def to_string(self, type_=None):
        log_type = amo.LOG_BY_ID[self.action]
        if type_ and hasattr(log_type, '%s_format' % type_):
            format = getattr(log_type, '%s_format' % type_)
        else:
            format = log_type.format

        # We need to copy arguments so we can remove elements from it
        # while we loop over self.arguments.
        arguments = copy(self.arguments)
        addon = None
        review = None
        version = None
        collection = None
        tag = None
        group = None

        for arg in self.arguments:
            if isinstance(arg, Addon) and not addon:
                if arg.is_listed:
                    addon = self.f(u'<a href="{0}">{1}</a>',
                                   arg.get_url_path(), arg.name)
                else:
                    addon = self.f(u'{0}', arg.name)
                arguments.remove(arg)
            if isinstance(arg, Review) and not review:
                review = self.f(u'<a href="{0}">{1}</a>',
                                arg.get_url_path(), _('Review'))
                arguments.remove(arg)
            if isinstance(arg, Version) and not version:
                text = _('Version {0}')
                if arg.is_listed:
                    version = self.f(u'<a href="{1}">%s</a>' % text,
                                     arg.version, arg.get_url_path())
                else:
                    version = self.f(text, arg.version)
                arguments.remove(arg)
            if isinstance(arg, Collection) and not collection:
                collection = self.f(u'<a href="{0}">{1}</a>',
                                    arg.get_url_path(), arg.name)
                arguments.remove(arg)
            if isinstance(arg, Tag) and not tag:
                if arg.can_reverse():
                    tag = self.f(u'<a href="{0}">{1}</a>',
                                 arg.get_url_path(), arg.tag_text)
                else:
                    tag = self.f('{0}', arg.tag_text)
            if isinstance(arg, Group) and not group:
                group = arg.name
                arguments.remove(arg)

        user = user_link(self.user)

        try:
            kw = dict(addon=addon, review=review, version=version,
                      collection=collection, tag=tag, user=user, group=group)
            return self.f(format, *arguments, **kw)
        except (AttributeError, KeyError, IndexError):
            log.warning('%d contains garbage data' % (self.id or 0))
            return 'Something magical happened.'
开发者ID:chetanmelkani,项目名称:olympia,代码行数:60,代码来源:models.py


示例12: to_string

    def to_string(self, type=None):
        log_type = amo.LOG_BY_ID[self.action]
        if type and hasattr(log_type, "%s_format" % type):
            format = getattr(log_type, "%s_format" % type)
        else:
            format = log_type.format

        # We need to copy arguments so we can remove elements from it
        # while we loop over self.arguments.
        arguments = copy(self.arguments)
        addon = None
        review = None
        version = None
        collection = None
        tag = None

        for arg in self.arguments:
            if isinstance(arg, Addon) and not addon:
                addon = self.f(u'<a href="{0}">{1}</a>', arg.get_url_path(), arg.name)
                arguments.remove(arg)
            if isinstance(arg, Review) and not review:
                review = self.f(u'<a href="{0}">{1}</a>', arg.get_url_path(), _("Review"))
                arguments.remove(arg)
            if isinstance(arg, Version) and not version:
                text = _("Version %s") % arg.version
                version = self.f(u'<a href="{0}">{1}</a>', arg.get_url_path(), text)
                arguments.remove(arg)
            if isinstance(arg, Collection) and not collection:
                collection = self.f(u'<a href="{0}">{1}</a>', arg.get_url_path(), arg.name)
                arguments.remove(arg)
            if isinstance(arg, Tag) and not tag:
                if arg.can_reverse():
                    tag = self.f(u'<a href="{0}">{1}</a>', arg.get_url_path(), arg.tag_text)
                else:
                    tag = self.f("{0}", arg.tag_text)

        user = user_link(self.user)

        try:
            kw = dict(addon=addon, review=review, version=version, collection=collection, tag=tag, user=user)
            return self.f(format, *arguments, **kw)
        except (AttributeError, KeyError, IndexError):
            log.warning("%d contains garbage data" % (self.id or 0))
            return "Something magical happened."
开发者ID:frankk00,项目名称:zamboni,代码行数:44,代码来源:models.py


示例13: test_user_link_xss

def test_user_link_xss():
    u = UserProfile(username='jconnor',
                    display_name='<script>alert(1)</script>', pk=1)
    html = "&lt;script&gt;alert(1)&lt;/script&gt;"
    eq_(user_link(u), '<a href="%s">%s</a>' % (u.get_url_path(), html))
开发者ID:Dreadchild,项目名称:zamboni,代码行数:5,代码来源:test_helpers.py


示例14: test_user_link

def test_user_link():
    u = UserProfile(username="jconnor", display_name="John Connor", pk=1)
    eq_(user_link(u), '<a href="%s">John Connor</a>' % reverse("users.profile", args=[1]))

    # handle None gracefully
    eq_(user_link(None), "")
开发者ID:beenishkhan,项目名称:zamboni,代码行数:6,代码来源:test_helpers.py


示例15: test_user_link_xss

def test_user_link_xss():
    u = UserProfile(username="jconnor", display_name="<script>alert(1)</script>", pk=1)
    url = reverse("users.profile", args=[1])
    html = "&lt;script&gt;alert(1)&lt;/script&gt;"
    eq_(user_link(u), '<a href="%s">%s</a>' % (url, html))
开发者ID:beenishkhan,项目名称:zamboni,代码行数:5,代码来源:test_helpers.py


示例16: test_user_link_unicode

def test_user_link_unicode():
    """make sure helper won't choke on unicode input"""
    u = UserProfile(firstname=u'Jürgen', lastname=u'Müller', pk=1)
    eq_(user_link(u), u'<a href="%s">Jürgen Müller</a>' %
        reverse('users.profile', args=[1]))
开发者ID:mccammos,项目名称:zamboni,代码行数:5,代码来源:test_helpers.py


示例17: test_user_link

def test_user_link():
    u = UserProfile(firstname='John', lastname='Connor', pk=1)
    eq_(user_link(u), '<a href="%s">John Connor</a>' %
        reverse('users.profile', args=[1]))
开发者ID:mccammos,项目名称:zamboni,代码行数:4,代码来源:test_helpers.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.create_profile函数代码示例发布时间:2022-05-27
下一篇:
Python forms.UserForm类代码示例发布时间: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