本文整理汇总了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 = "<script>alert(1)</script>"
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"'><iframe onload=alert(3)>"""
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 = "<script>alert(1)</script>"
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 = "<script>alert(1)</script>"
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;未经允许,请勿转载。 |
请发表评论