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

Python tower._lazy函数代码示例

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

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



在下文中一共展示了_lazy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:cturra,项目名称:input.mozilla.org,代码行数:29,代码来源:views.py


示例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
开发者ID:mattbasta,项目名称:zamboni,代码行数:31,代码来源:forms_payments.py


示例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
开发者ID:beenishkhan,项目名称:zamboni,代码行数:32,代码来源:utils.py


示例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
开发者ID:LittleForker,项目名称:zamboni,代码行数:27,代码来源:helpers.py


示例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
开发者ID:aditbiswas1,项目名称:olympia,代码行数:28,代码来源:helpers.py


示例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")
开发者ID:evilpie,项目名称:mozillians,代码行数:7,代码来源:forms.py


示例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])
开发者ID:aditbiswas1,项目名称:olympia,代码行数:9,代码来源:helpers.py


示例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)
开发者ID:fwenzel,项目名称:firefox-flicks,代码行数:11,代码来源:views.py


示例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)
开发者ID:pmclanahan,项目名称:firefox-flicks,代码行数:11,代码来源:views.py


示例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)
开发者ID:kaiquewdev,项目名称:kuma,代码行数:11,代码来源:forms.py


示例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)
开发者ID:fwenzel,项目名称:firefox-flicks,代码行数:11,代码来源:views.py


示例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)
开发者ID:gerv,项目名称:kuma,代码行数:12,代码来源:forms.py


示例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)]
开发者ID:abhiii5459,项目名称:olympia,代码行数:12,代码来源:models.py


示例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])
开发者ID:LittleForker,项目名称:zamboni,代码行数:13,代码来源:helpers.py


示例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': '/',
     }
开发者ID:rbillings,项目名称:kitsune,代码行数:13,代码来源:api.py


示例16: validate_twitter

def validate_twitter(username):
    """Return a twitter username given '@' or http(s) strings."""

    if username:
        username = re.sub('https?://(www\.)?twitter\.com/|@', '', username)

        # Twitter accounts must be alphanumeric ASCII including underscore, and <= 15 chars.
        # https://support.twitter.com/articles/101299-why-can-t-i-register-certain-usernames
        if len(username) > 15:
            raise ValidationError(_lazy('Twitter usernames cannot be longer than 15 characters.'))

        if not re.match('^\w+$', username):
            raise ValidationError(_lazy('Twitter usernames must contain only alphanumeric characters'
                                        ' and the underscore.'))
    return username
开发者ID:Narrator,项目名称:mozillians,代码行数:15,代码来源:validators.py


示例17: search

def search(request):
    to_json = JSONRenderer().render
    context = {}
    form = WikiSearchForm()

    # Get options to fill the various select boxes of the search forms.
    languages = _options_tuple_to_dict(form.fields['language'].choices)
    categories = _options_tuple_to_dict(form.fields['category'].choices)
    products = _options_tuple_to_dict(form.fields['product'].choices)
    topics = _options_tuple_to_dict(form.fields['topics'].choices)

    filters = {
        'language': {
            'meta': {
                'name': 'language',
                'label': _lazy(u'Language'),
                'multi': False,
            },
            'options': languages,
        },
        'category': {
            'meta': {
                'name': 'category',
                'label': _lazy(u'Category'),
                'multi': True,
            },
            'options': categories,
        },
        'product': {
            'meta': {
                'name': 'product',
                'label': _lazy(u'Relevant to'),
                'multi': True,
            },
            'options': products,
        },
        'topics': {
            'meta': {
                'name': 'topics',
                'label': _lazy(u'Topics'),
                'multi': True,
            },
            'options': topics,
        },
    }
    context['filters_json'] = to_json(filters)

    return render(request, 'coolsearch/search.html', context)
开发者ID:rivaxel,项目名称:kitsune,代码行数:48,代码来源:views.py


示例18: reviewers_page_title

def reviewers_page_title(context, title=None, addon=None):
    if addon:
        title = u'%s | %s' % (title, addon.name)
    else:
        section = _lazy('Reviewer Tools')
        title = u'%s | %s' % (title, section) if title else section
    return mkt_page_title(context, title)
开发者ID:albre2252,项目名称:zamboni,代码行数:7,代码来源:helpers.py


示例19: datetimeformat

def datetimeformat(context, value, format='shortdatetime'):
    """
    Returns date/time formatted using babel's locale settings. Uses the
    timezone from settings.py
    """
    if not isinstance(value, datetime.datetime):
        # Expecting date value
        raise ValueError

    tzinfo = timezone(settings.TIME_ZONE)
    tzvalue = tzinfo.localize(value)
    locale = _babel_locale(_contextual_locale(context))

    # If within a day, 24 * 60 * 60 = 86400s
    if format == 'shortdatetime':
        # Check if the date is today
        if value.toordinal() == datetime.date.today().toordinal():
            formatted = _lazy(u'Today at %s') % format_time(
                                    tzvalue, format='short', locale=locale)
        else:
            formatted = format_datetime(tzvalue, format='short', locale=locale)
    elif format == 'longdatetime':
        formatted = format_datetime(tzvalue, format='long', locale=locale)
    elif format == 'date':
        formatted = format_date(tzvalue, locale=locale)
    elif format == 'time':
        formatted = format_time(tzvalue, locale=locale)
    elif format == 'datetime':
        formatted = format_datetime(tzvalue, locale=locale)
    else:
        # Unknown format
        raise DateTimeFormatError

    return jinja2.Markup('<time datetime="%s">%s</time>' % \
                         (tzvalue.isoformat(), formatted))
开发者ID:tantek,项目名称:kuma,代码行数:35,代码来源:helpers.py


示例20: country_name

def country_name(country, native=False, default=_lazy(u'Unknown')):
    """Convert a country code into a human readable country name"""
    if country in CODE_TO_COUNTRY:
        display_locale = 'native' if native else 'English'
        return CODE_TO_COUNTRY[country][display_locale]
    else:
        return default
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:7,代码来源:helpers.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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