本文整理汇总了Python中amo.utils.MenuItem.url方法的典型用法代码示例。如果您正苦于以下问题:Python MenuItem.url方法的具体用法?Python MenuItem.url怎么用?Python MenuItem.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amo.utils.MenuItem
的用法示例。
在下文中一共展示了MenuItem.url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_activities
# 需要导入模块: from amo.utils import MenuItem [as 别名]
# 或者: from amo.utils.MenuItem import url [as 别名]
def _get_activities(request, action):
url = request.get_full_path()
choices = (None, 'updates', 'status', 'collections', 'reviews')
text = {None: _('All Activity'),
'updates': _('Add-on Updates'),
'status': _('Add-on Status'),
'collections': _('User Collections'),
'reviews': _('User Reviews'),
}
items = []
for c in choices:
i = MenuItem()
i.text = text[c]
i.url, i.selected = urlparams(url, page=None, action=c), (action == c)
items.append(i)
return items
示例2: _get_versions
# 需要导入模块: from amo.utils import MenuItem [as 别名]
# 或者: from amo.utils.MenuItem import url [as 别名]
def _get_versions(request, versions, version):
compats = []
url = request.get_full_path()
c = MenuItem()
(c.text, c.url) = (_('All Versions'), urlparams(url, lver=None, page=None))
if not version or version == 'any':
c.selected = True
compats.append(c)
seen = {}
exclude = request.APP.__dict__.get('exclude_versions', [])
versions.sort(reverse=True)
for v in versions:
# v is a version_int so we can get the major and minor:
v = dict_from_int(v)
if v['minor1'] == 99:
text = '%s.*' % v['major']
v_float = float('%s.99' % v['major'])
else:
text = '%s.%s' % (v['major'], v['minor1'])
v_float = float(text)
if seen.get(text):
continue
seen[text] = 1
if v_float < request.APP.min_display_version or v_float in exclude:
continue
c = MenuItem()
c.text = text
c.url = urlparams(url, lver=c.text, page=None)
if c.text == version:
c.selected = True
compats.append(c)
return compats