本文整理汇总了Python中tower._lazy函数的典型用法代码示例。如果您正苦于以下问题:Python _lazy函数的具体用法?Python _lazy怎么用?Python _lazy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_lazy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
def index(request):
"""
Display search results for Opinions on Firefox. Shows breakdown of
Praise/Issues/Ideas, sites/themes, and search filters.
If no search criteria are explicitly set, the page is considered the
"Dashboard" (i.e. the home page of Firefox Input). Otherwise, the title
of the page is "Search Results".
"""
VERSIONS = VersionCount.objects.filter(active=1)
VERSION_CHOICES = {
FIREFOX: ([('--', _lazy(u'-- all --', 'version_choice'))] +
[(v.version, v.version) for v in VERSIONS
if v.product == FIREFOX.id]),
MOBILE: ([('--', _lazy(u'-- all --', 'version_choice'))] +
[(v.version, v.version) for v in VERSIONS
if v.product == MOBILE.id]),
}
try:
meta = ('type', 'locale', 'platform', 'day_sentiment', 'manufacturer',
'device')
(results, form, product, version, metas, type_filter) = _get_results(
request, meta=meta)
except SearchError, e:
return render(request, 'search/unavailable.html', {'search_error': e},
status=500)
示例2: group_tier_choices
def group_tier_choices(self):
"""Creates tier choices with optgroups based on payment methods"""
price_choices = [("free", _("Free (with in-app payments)"))]
card_billed = []
operator_billed = []
card_and_operator_billed = []
for price in Price.objects.active():
choice = (price.pk, unicode(price))
# Special case price tier 0.
if price.price == Decimal("0.00"):
price_choices.append((price.pk, "%s (%s)" % (unicode(price), _("Promotional Pricing"))))
# Tiers that can only be operator billed.
elif price.method == PAYMENT_METHOD_OPERATOR:
operator_billed.append(choice)
# Tiers that can only be card billed.
elif price.method == PAYMENT_METHOD_CARD:
card_billed.append(choice)
# Tiers that are can generally be billed by either
# operator or card.
elif price.method == PAYMENT_METHOD_ALL:
card_and_operator_billed.append(choice)
if operator_billed:
price_choices.append((_lazy("Only supports carrier billing"), operator_billed))
if card_billed:
price_choices.append((_lazy("Only supports credit-card billing"), card_billed))
if card_and_operator_billed:
price_choices.append((_lazy("Supports all billing methods"), card_and_operator_billed))
return price_choices
示例3: get_actions
def get_actions(self):
actions = SortedDict()
actions['public'] = {'method': self.handler.process_public,
'minimal': False,
'label': _lazy('Push to public'),
'details': _lazy(
'This will approve the sandboxed app so it '
'appears on the public side.')}
actions['reject'] = {'method': self.handler.process_sandbox,
'label': _lazy('Reject'),
'minimal': False,
'details': _lazy(
'This will reject the app and remove it '
'from the review queue.')}
actions['info'] = {'method': self.handler.request_information,
'label': _lazy('Request more information'),
'minimal': True,
'details': _lazy(
'This will send the author(s) an email '
'requesting more information.')}
actions['super'] = {'method': self.handler.process_super_review,
'label': _lazy('Request super-review'),
'minimal': True,
'details': _lazy(
'Flag this app for an admin to review')}
actions['comment'] = {'method': self.handler.process_comment,
'label': _lazy('Comment'),
'minimal': True,
'details': _lazy(
'Make a comment on this app. The '
'author won\'t be able to see this.')}
return actions
示例4: get_actions
def get_actions(self):
labels, details = self._review_actions()
actions = SortedDict()
if self.review_type != "preliminary":
actions["public"] = {
"method": self.handler.process_public,
"minimal": False,
"label": _lazy("Push to public"),
}
actions["prelim"] = {"method": self.handler.process_preliminary, "label": labels["prelim"], "minimal": False}
actions["reject"] = {"method": self.handler.process_sandbox, "label": _lazy("Reject"), "minimal": False}
actions["info"] = {
"method": self.handler.request_information,
"label": _lazy("Request more information"),
"minimal": True,
}
actions["super"] = {
"method": self.handler.process_super_review,
"label": _lazy("Request super-review"),
"minimal": True,
}
for k, v in actions.items():
v["details"] = details.get(k)
return actions
示例5: get_actions
def get_actions(self):
labels, details = self._review_actions()
actions = SortedDict()
if self.review_type != 'preliminary':
actions['public'] = {'method': self.handler.process_public,
'minimal': False,
'label': _lazy('Push to public')}
actions['prelim'] = {'method': self.handler.process_preliminary,
'label': labels['prelim'],
'minimal': False}
actions['reject'] = {'method': self.handler.process_sandbox,
'label': _lazy('Reject'),
'minimal': False}
actions['info'] = {'method': self.handler.request_information,
'label': _lazy('Request more information'),
'minimal': True}
actions['super'] = {'method': self.handler.process_super_review,
'label': _lazy('Request super-review'),
'minimal': True}
actions['comment'] = {'method': self.handler.process_comment,
'label': _lazy('Comment'),
'minimal': True}
for k, v in actions.items():
v['details'] = details.get(k)
return actions
示例6: __init__
def __init__(self, *args, **kwargs):
"""Override the __init__ method to change form labels"""
super(PasswordChangeForm, self).__init__(*args, **kwargs)
self.fields["old_password"].label = _lazy(u"Verify your old password")
self.fields["new_password1"].label = _lazy(u"Enter a new password")
self.fields["new_password2"].label = _lazy(u"Confirm new password")
示例7: render_additional_info
def render_additional_info(self, row):
info = []
if row.is_site_specific:
info.append(_lazy(u'Site Specific'))
if row.external_software:
info.append(_lazy(u'Requires External Software'))
if row.binary or row.binary_components:
info.append(_lazy(u'Binary Components'))
return u', '.join([jinja2.escape(i) for i in info])
示例8: promo_video_noir
def promo_video_noir(request):
"""Film Noir promo video."""
d = dict(video_title=_lazy('Noir'),
video_description=_lazy('The fox meets a damsel in distress, but '
'can he help her? Get inspired for your '
'Firefox Flicks entry by checking out '
'our video.'),
page_type='videos',
video_embed=Markup(embedCode(promo_video_shortlink('noir'),
width=600, height=337)))
return render(request, 'videos/promo.html', d)
示例9: promo_video_twilight
def promo_video_twilight(request):
"""Twilight parody promo video."""
desc = _lazy('A teenage girl learns the truth about the fox. Get inspired '
'for your Firefox Flicks entry by checking out our video.')
d = dict(video_title=_lazy('Twilight'),
video_description=desc,
tweet_text=desc,
page_type='videos',
video_embed=Markup(embedCode(promo_video_shortlink('twilight'),
width=600, height=337)))
return render(request, 'videos/promo.html', d)
示例10: __init__
def __init__(self, *args, **kwargs):
super(UsernameField, self).__init__(
label=_lazy(u'Username'), max_length=30, min_length=3,
regex=r'^[\[email protected]+-]+$',
help_text=_lazy(u'Required. 30 characters or fewer. '
'Letters, digits and @/./+/-/_ only.'),
error_messages={'invalid': USERNAME_INVALID,
'required': USERNAME_REQUIRED,
'min_length': USERNAME_SHORT,
'max_length': USERNAME_LONG},
*args, **kwargs)
示例11: promo_video_dance
def promo_video_dance(request):
"""Dancing promo video."""
d = dict(video_title=_lazy('Dance'),
video_description=_lazy("He's got the moves, he's got ambition. "
"How far can this fox's feet take him? "
"Get inspired for your Firefox Flicks "
"entry by checking out our video."),
page_type='videos',
video_embed=Markup(embedCode(promo_video_shortlink('dance'),
width=600, height=337)))
return render(request, 'videos/promo.html', d)
示例12: __init__
def __init__(self, *args, **kwargs):
super(UsernameField, self).__init__(
label=_lazy(u'Username'), max_length=30, min_length=3,
regex=r'^[\w.-]+$',
help_text=_lazy(u'Required. 30 characters or fewer. '
'Letters, digits and ./-/_ only.'),
widget=forms.TextInput(attrs={'placeholder': USERNAME_PLACEHOLDER}),
error_messages={'invalid': USERNAME_INVALID,
'required': USERNAME_REQUIRED,
'min_length': USERNAME_SHORT,
'max_length': USERNAME_LONG},
*args, **kwargs)
示例13: flags
def flags(self):
props = (
('admin_review', 'admin-review', _lazy('Admin Review')),
('is_jetpack', 'jetpack', _lazy('Jetpack Add-on')),
('is_traditional_restartless', 'restartless',
_lazy('Restartless Add-on')),
('has_info_request', 'info', _lazy('More Information Requested')),
('has_editor_comment', 'editor', _lazy('Contains Editor Comment')),
)
return [(cls, title) for (prop, cls, title) in props
if getattr(self, prop)]
示例14: render_additional_info
def render_additional_info(self, row):
info = []
if row.is_site_specific:
info.append(_lazy(u"Site Specific"))
if len(row.file_platform_ids) == 1 and row.file_platform_ids != [amo.PLATFORM_ALL.id]:
k = row.file_platform_ids[0]
# L10n: first argument is the platform such as Linux, Mac OS X
info.append(_lazy(u"{0} only").format(amo.PLATFORMS[k].name))
if row.external_software:
info.append(_lazy(u"Requires External Software"))
if row.binary:
info.append(_lazy(u"Binary Components"))
return u", ".join([jinja2.escape(i) for i in info])
示例15: data
def data(self):
topics = super(RootTopicSerializer, self).data
return {
'subtopics': topics,
'documents': [],
'title': _lazy('All Topics'),
'slug': '',
'description': _lazy('All Topics'),
'parent': None,
'visible': True,
'product': None,
'path': '/',
}