コード例 #1
0
def queue_tabnav(context):
    """Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (tab_code, page_url, tab_text)
    """
    from .views import queue_counts
    counts = queue_counts()
    tabnav = [('nominated', 'queue_nominated',
               (ngettext('Full Review ({0})', 'Full Reviews ({0})',
                         counts['nominated'])
                .format(counts['nominated']))),
              ('pending', 'queue_pending',
               (ngettext('Pending Update ({0})', 'Pending Updates ({0})',
                         counts['pending'])
                .format(counts['pending']))),
              ('prelim', 'queue_prelim',
               (ngettext('Preliminary Review ({0})',
                         'Preliminary Reviews ({0})',
                         counts['prelim'])
                .format(counts['prelim']))),
              ('moderated', 'queue_moderated',
               (ngettext('Moderated Review ({0})', 'Moderated Reviews ({0})',
                         counts['moderated'])
                .format(counts['moderated'])))]

    if waffle.flag_is_active(context['request'], 'accept-webapps'):
        tabnav.append(('apps', 'queue_apps',
                       (ngettext('Apps ({0})', 'Apps ({0})', counts['apps'])
                        .format(counts['apps']))))
    return tabnav
コード例 #2
0
ファイル: helpers.py プロジェクト: aditbiswas1/olympia
def queue_tabnav(context):
    """Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (tab_code, page_url, tab_text)
    """
    from .views import queue_counts

    counts = queue_counts()
    tabnav = [('fast_track', 'queue_fast_track',
               (ngettext('Fast Track ({0})', 'Fast Track ({0})',
                         counts['fast_track'])
                .format(counts['fast_track']))),
              ('nominated', 'queue_nominated',
               (ngettext('Full Review ({0})', 'Full Reviews ({0})',
                         counts['nominated'])
                .format(counts['nominated']))),
              ('pending', 'queue_pending',
               (ngettext('Pending Update ({0})', 'Pending Updates ({0})',
                         counts['pending'])
                .format(counts['pending']))),
              ('prelim', 'queue_prelim',
               (ngettext('Preliminary Review ({0})',
                         'Preliminary Reviews ({0})',
                         counts['prelim'])
                .format(counts['prelim']))),
              ('moderated', 'queue_moderated',
               (ngettext('Moderated Review ({0})', 'Moderated Reviews ({0})',
                         counts['moderated'])
                .format(counts['moderated'])))]

    return tabnav
コード例 #3
0
ファイル: forms.py プロジェクト: exezaid/zamboni
    def clean_tags(self):
        target = [slugify(t, spaces=True)
                  for t in self.cleaned_data['tags'].split(',')]
        target = filter(None, target)

        min_len = amo.MIN_TAG_LENGTH
        max_tags = amo.MAX_TAGS
        total = len(target)

        blacklisted = []
        for tag in Tag.objects.filter(tag_text__in=target):
            if len(tag.tag_text) > 0 and tag.blacklisted:
                blacklisted.append(tag.tag_text)

        if blacklisted:
            # L10n: {0} is a single tag or a comma-separated list of tags.
            msg = ngettext('Invalid tag: {0}', 'Invalid tags: {0}',
                           len(blacklisted)).format(', '.join(blacklisted))
            raise forms.ValidationError(msg)

        if total > max_tags:
            num = total - max_tags
            msg = ngettext('You have {0} too many tags.',
                           'You have {0} too many tags.', num).format(num)
            raise forms.ValidationError(msg)

        if any(t for t in target if len(t) < amo.MIN_TAG_LENGTH):
            msg = ngettext("All tags must be at least {0} character.",
                           "All tags must be at least {0} characters.",
                           min_len).format(min_len)
            raise forms.ValidationError(msg)

        return target
コード例 #4
0
ファイル: helpers.py プロジェクト: vivekkiran/olympia
def queue_tabnav(context):
    """Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (tab_code, page_url, tab_text)
    """
    from .views import queue_counts

    counts = queue_counts()
    tabnav = [('fast_track', 'queue_fast_track',
               (ngettext('Fast Track ({0})', 'Fast Track ({0})',
                         counts['fast_track']).format(counts['fast_track']))),
              ('nominated', 'queue_nominated',
               (ngettext('Full Review ({0})', 'Full Reviews ({0})',
                         counts['nominated']).format(counts['nominated']))),
              ('pending', 'queue_pending',
               (ngettext('Pending Update ({0})', 'Pending Updates ({0})',
                         counts['pending']).format(counts['pending']))),
              ('prelim', 'queue_prelim',
               (ngettext('Preliminary Review ({0})',
                         'Preliminary Reviews ({0})',
                         counts['prelim']).format(counts['prelim']))),
              ('moderated', 'queue_moderated',
               (ngettext('Moderated Review ({0})', 'Moderated Reviews ({0})',
                         counts['moderated']).format(counts['moderated'])))]

    return tabnav
コード例 #5
0
ファイル: helpers.py プロジェクト: chenba/zamboni
def queue_tabnav(context):
    """Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (tab_code, page_url, tab_text)
    """
    from .views import queue_counts
    counts = queue_counts()
    tabnav = [('nominated', 'queue_nominated',
               (ngettext('Full Review ({0})', 'Full Reviews ({0})',
                         counts['nominated'])
                .format(counts['nominated']))),
              ('pending', 'queue_pending',
               (ngettext('Pending Update ({0})', 'Pending Updates ({0})',
                         counts['pending'])
                .format(counts['pending']))),
              ('prelim', 'queue_prelim',
               (ngettext('Preliminary Review ({0})',
                         'Preliminary Reviews ({0})',
                         counts['prelim'])
                .format(counts['prelim']))),
              ('moderated', 'queue_moderated',
               (ngettext('Moderated Review ({0})', 'Moderated Reviews ({0})',
                         counts['moderated'])
                .format(counts['moderated'])))]

    if waffle.flag_is_active(context['request'], 'accept-webapps'):
        tabnav.append(('apps', 'queue_apps',
                       (ngettext('Apps ({0})', 'Apps ({0})', counts['apps'])
                        .format(counts['apps']))))
    return tabnav
コード例 #6
0
ファイル: helpers.py プロジェクト: lauraxt/zamboni
def summarize_validation(validation):
    """Readable summary of add-on validation results."""
    # L10n: first parameter is the number of errors
    errors = ngettext("{0} error", "{0} errors", validation.errors).format(validation.errors)
    # L10n: first parameter is the number of warnings
    warnings = ngettext("{0} warning", "{0} warnings", validation.warnings).format(validation.warnings)
    return "%s, %s" % (errors, warnings)
コード例 #7
0
def summarize_validation(validation):
    """Readable summary of add-on validation results."""
    # L10n: first parameter is the number of errors
    errors = ngettext('{0} error', '{0} errors',
                      validation.errors).format(validation.errors)
    # L10n: first parameter is the number of warnings
    warnings = ngettext('{0} warning', '{0} warnings',
                        validation.warnings).format(validation.warnings)
    return "%s, %s" % (errors, warnings)
コード例 #8
0
ファイル: helpers.py プロジェクト: zuzelvp/zamboni
 def render_days_since_created(self, row):
     if row.days_since_created == 0:
         # L10n: first argument is number of hours
         r = ngettext(u'{0} hour', u'{0} hours',
                         row.hours_since_created).format(
                                             row.hours_since_created)
     else:
         # L10n: first argument is number of days
         r = ngettext(u'{0} day', u'{0} days',
                      row.days_since_created).format(
                                             row.days_since_created)
     return jinja2.escape(r)
コード例 #9
0
def clean_tags(request, tags, max_tags=None):
    """
    Blocked tags are not allowed.
    Restricted tags can only be edited by Reviewers and Curators.
    """
    target = [slugify(t, spaces=True, lower=True) for t in tags.split(',')]
    target = set(filter(None, target))

    min_len = mkt.MIN_TAG_LENGTH
    max_len = Tag._meta.get_field('tag_text').max_length
    max_tags = max_tags or mkt.MAX_TAGS
    total = len(target)

    blocked = (Tag.objects.values_list('tag_text',
                                       flat=True).filter(tag_text__in=target,
                                                         blocked=True))
    if blocked:
        # L10n: {0} is a single tag or a comma-separated list of tags.
        msg = ngettext(u'Invalid tag: {0}', 'Invalid tags: {0}',
                       len(blocked)).format(', '.join(blocked))
        raise forms.ValidationError(msg)

    restricted = (Tag.objects.values_list('tag_text', flat=True).filter(
        tag_text__in=target, restricted=True))
    if restricted and not can_edit_restricted_tags(request):
        # L10n: {0} is a single tag or a comma-separated list of tags.
        msg = ngettext(u'"{0}" is a reserved tag and cannot be used.',
                       u'"{0}" are reserved tags and cannot be used.',
                       len(restricted)).format('", "'.join(restricted))
        raise forms.ValidationError(msg)
    else:
        # Admin's restricted tags don't count towards the limit.
        total = len(target - set(restricted))

    if total > max_tags:
        num = total - max_tags
        msg = ngettext(u'You have {0} too many tags.',
                       u'You have {0} too many tags.', num).format(num)
        raise forms.ValidationError(msg)

    if any(t for t in target if len(t) > max_len):
        raise forms.ValidationError(
            _(u'All tags must be %s characters '
              u'or less after invalid characters are removed.' % max_len))

    if any(t for t in target if len(t) < min_len):
        msg = ngettext(u'All tags must be at least {0} character.',
                       u'All tags must be at least {0} characters.',
                       min_len).format(min_len)
        raise forms.ValidationError(msg)

    return target
コード例 #10
0
 def render_waiting_time_min(self, row):
     if row.waiting_time_min == 0:
         r = _lazy("moments ago")
     elif row.waiting_time_hours == 0:
         # L10n: first argument is number of minutes
         r = ngettext(u"{0} minute", u"{0} minutes", row.waiting_time_min).format(row.waiting_time_min)
     elif row.waiting_time_days == 0:
         # L10n: first argument is number of hours
         r = ngettext(u"{0} hour", u"{0} hours", row.waiting_time_hours).format(row.waiting_time_hours)
     else:
         # L10n: first argument is number of days
         r = ngettext(u"{0} day", u"{0} days", row.waiting_time_days).format(row.waiting_time_days)
     return jinja2.escape(r)
コード例 #11
0
ファイル: utils.py プロジェクト: Witia1/zamboni
def clean_tags(request, tags, max_tags=None):
    """
    Blocked tags are not allowed.
    Restricted tags can only be edited by Reviewers and Curators.
    """
    target = [slugify(t, spaces=True, lower=True) for t in tags.split(',')]
    target = set(filter(None, target))

    min_len = mkt.MIN_TAG_LENGTH
    max_len = Tag._meta.get_field('tag_text').max_length
    max_tags = max_tags or mkt.MAX_TAGS
    total = len(target)

    blocked = (Tag.objects.values_list('tag_text', flat=True)
               .filter(tag_text__in=target, blocked=True))
    if blocked:
        # L10n: {0} is a single tag or a comma-separated list of tags.
        msg = ngettext(u'Invalid tag: {0}', 'Invalid tags: {0}',
                       len(blocked)).format(', '.join(blocked))
        raise forms.ValidationError(msg)

    restricted = (Tag.objects.values_list('tag_text', flat=True)
                     .filter(tag_text__in=target, restricted=True))
    if restricted and not can_edit_restricted_tags(request):
        # L10n: {0} is a single tag or a comma-separated list of tags.
        msg = ngettext(u'"{0}" is a reserved tag and cannot be used.',
                       u'"{0}" are reserved tags and cannot be used.',
                       len(restricted)).format('", "'.join(restricted))
        raise forms.ValidationError(msg)
    else:
        # Admin's restricted tags don't count towards the limit.
        total = len(target - set(restricted))

    if total > max_tags:
        num = total - max_tags
        msg = ngettext(u'You have {0} too many tags.',
                       u'You have {0} too many tags.', num).format(num)
        raise forms.ValidationError(msg)

    if any(t for t in target if len(t) > max_len):
        raise forms.ValidationError(
            _(u'All tags must be %s characters '
              u'or less after invalid characters are removed.' % max_len))

    if any(t for t in target if len(t) < min_len):
        msg = ngettext(u'All tags must be at least {0} character.',
                       u'All tags must be at least {0} characters.',
                       min_len).format(min_len)
        raise forms.ValidationError(msg)

    return target
コード例 #12
0
    def clean_tags(self):
        target = [
            slugify(t, spaces=True, lower=True)
            for t in self.cleaned_data['tags'].split(',')
        ]
        target = set(filter(None, target))

        min_len = amo.MIN_TAG_LENGTH
        max_len = Tag._meta.get_field('tag_text').max_length
        max_tags = amo.MAX_TAGS
        total = len(target)

        blacklisted = (Tag.objects.values_list('tag_text', flat=True).filter(
            tag_text__in=target, blacklisted=True))
        if blacklisted:
            # L10n: {0} is a single tag or a comma-separated list of tags.
            msg = ngettext('Invalid tag: {0}', 'Invalid tags: {0}',
                           len(blacklisted)).format(', '.join(blacklisted))
            raise forms.ValidationError(msg)

        restricted = (Tag.objects.values_list('tag_text', flat=True).filter(
            tag_text__in=target, restricted=True))
        if not acl.action_allowed(self.request, 'Admin', 'EditAnyAddon'):
            if restricted:
                # L10n: {0} is a single tag or a comma-separated list of tags.
                msg = ngettext('"{0}" is a reserved tag and cannot be used.',
                               '"{0}" are reserved tags and cannot be used.',
                               len(restricted)).format('", "'.join(restricted))
                raise forms.ValidationError(msg)
        else:
            # Admin's restricted tags don't count towards the limit.
            total = len(target - set(restricted))

        if total > max_tags:
            num = total - max_tags
            msg = ngettext('You have {0} too many tags.',
                           'You have {0} too many tags.', num).format(num)
            raise forms.ValidationError(msg)

        if any(t for t in target if len(t) > max_len):
            raise forms.ValidationError(
                _('All tags must be %s characters '
                  'or less after invalid characters are removed.' % max_len))

        if any(t for t in target if len(t) < min_len):
            msg = ngettext("All tags must be at least {0} character.",
                           "All tags must be at least {0} characters.",
                           min_len).format(min_len)
            raise forms.ValidationError(msg)

        return target
コード例 #13
0
ファイル: forms.py プロジェクト: magopian/olympia
def clean_tags(request, tags):
    target = [slugify(t, spaces=True, lower=True) for t in tags.split(',')]
    target = set(filter(None, target))

    min_len = amo.MIN_TAG_LENGTH
    max_len = Tag._meta.get_field('tag_text').max_length
    max_tags = amo.MAX_TAGS
    total = len(target)

    blacklisted = (Tag.objects.values_list('tag_text', flat=True)
                      .filter(tag_text__in=target, blacklisted=True))
    if blacklisted:
        # L10n: {0} is a single tag or a comma-separated list of tags.
        msg = ngettext('Invalid tag: {0}', 'Invalid tags: {0}',
                       len(blacklisted)).format(', '.join(blacklisted))
        raise forms.ValidationError(msg)

    restricted = (Tag.objects.values_list('tag_text', flat=True)
                     .filter(tag_text__in=target, restricted=True))
    if not acl.action_allowed(request, 'Addons', 'Edit'):
        if restricted:
            # L10n: {0} is a single tag or a comma-separated list of tags.
            msg = ngettext('"{0}" is a reserved tag and cannot be used.',
                           '"{0}" are reserved tags and cannot be used.',
                           len(restricted)).format('", "'.join(restricted))
            raise forms.ValidationError(msg)
    else:
        # Admin's restricted tags don't count towards the limit.
        total = len(target - set(restricted))

    if total > max_tags:
        num = total - max_tags
        msg = ngettext('You have {0} too many tags.',
                       'You have {0} too many tags.', num).format(num)
        raise forms.ValidationError(msg)

    if any(t for t in target if len(t) > max_len):
        raise forms.ValidationError(
            _('All tags must be %s characters or less after invalid characters'
              ' are removed.' % max_len))

    if any(t for t in target if len(t) < min_len):
        msg = ngettext("All tags must be at least {0} character.",
                       "All tags must be at least {0} characters.",
                       min_len).format(min_len)
        raise forms.ValidationError(msg)

    return target
コード例 #14
0
ファイル: forms.py プロジェクト: beenishkhan/zamboni
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        total = categories.count()
        max_cat = amo.MAX_CATEGORIES

        if getattr(self, 'disabled', False) and total:
            if categories[0].type == amo.ADDON_WEBAPP:
                raise forms.ValidationError(loc('Categories cannot be changed '
                    'while your app is featured for this application.'))
            else:
                raise forms.ValidationError(_('Categories cannot be changed '
                    'while your add-on is featured for this application.'))
        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))

        has_misc = filter(lambda x: x.misc, categories)
        if has_misc and total > 1:
            raise forms.ValidationError(
                _('The miscellaneous category cannot be combined with '
                  'additional categories.'))

        return categories
コード例 #15
0
ファイル: forms.py プロジェクト: lissyx/zamboni
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        total = categories.count()
        max_cat = amo.MAX_CATEGORIES

        if getattr(self, 'disabled', False) and total:
            if categories[0].type == amo.ADDON_WEBAPP:
                raise forms.ValidationError(
                    _('Categories cannot be changed '
                      'while your app is featured for this application.'))
            else:
                raise forms.ValidationError(
                    _('Categories cannot be changed '
                      'while your add-on is featured for this application.'))
        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(
                ngettext('You can have only {0} category.',
                         'You can have only {0} categories.',
                         max_cat).format(max_cat))

        has_misc = filter(lambda x: x.misc, categories)
        if has_misc and total > 1:
            raise forms.ValidationError(
                _('The miscellaneous category cannot be combined with '
                  'additional categories.'))

        return categories
コード例 #16
0
 def render_waiting_time_min(self, row):
     if row.waiting_time_min == 0:
         r = _lazy('moments ago')
     elif row.waiting_time_hours == 0:
         # L10n: first argument is number of minutes
         r = ngettext(u'{0} minute', u'{0} minutes',
                      row.waiting_time_min).format(row.waiting_time_min)
     elif row.waiting_time_days == 0:
         # L10n: first argument is number of hours
         r = ngettext(u'{0} hour', u'{0} hours',
                      row.waiting_time_hours).format(row.waiting_time_hours)
     else:
         # L10n: first argument is number of days
         r = ngettext(u'{0} day', u'{0} days',
                      row.waiting_time_days).format(row.waiting_time_days)
     return jinja2.escape(r)
コード例 #17
0
ファイル: forms.py プロジェクト: chrisdavidmills/zamboni
    def clean_categories(self):
        if self.disabled:
            raise forms.ValidationError(
                _('Categories cannot be changed while your app is featured.'))

        categories = self.cleaned_data['categories']
        set_categories = set(categories.values_list('id', flat=True))

        # Supervisored categories don't count towards the max, so subtract
        # them out if there are any.
        supervisor_of = self.special_cats()
        if supervisor_of.exists():
            set_categories -= set(supervisor_of.values_list('id', flat=True))

        total = len(set_categories)
        max_cat = amo.MAX_CATEGORIES

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))

        return categories
コード例 #18
0
def themes_commit(request):
    reviewer = request.user.get_profile()
    ThemeReviewFormset = formset_factory(forms.ThemeReviewForm)
    formset = ThemeReviewFormset(request.POST)

    scores = []
    for form in formset:
        try:
            lock = ThemeLock.objects.filter(
                theme_id=form.data[form.prefix + '-theme'],
                reviewer=reviewer)
        except MultiValueDictKeyError:
            # Address off-by-one error caused by management form.
            continue
        if lock and form.is_valid():
            scores.append(form.save())

    # Success message.
    points = sum(scores)
    success = ngettext(
        # L10n: {0} is the number of reviews. {1} is the points just earned.
        # L10n: {2} is the total number of points the reviewer has overall.
        '{0} theme review successfully processed (+{1} points, {2} total).',
        '{0} theme reviews successfully processed (+{1} points, {2} total).',
        len(scores)).format(len(scores), points,
                            ReviewerScore.get_total(request.amo_user))
    amo.messages.success(request, success)

    if 'theme_redirect_url' in request.session:
        return redirect(request.session['theme_redirect_url'])
    else:
        return redirect(reverse('editors.themes.queue_themes'))
コード例 #19
0
ファイル: views_themes.py プロジェクト: lmorchard/zamboni
def themes_commit(request):
    reviewer = request.user.get_profile()
    ThemeReviewFormset = formset_factory(forms.ThemeReviewForm)
    formset = ThemeReviewFormset(request.POST)

    scores = []
    for form in formset:
        try:
            lock = ThemeLock.objects.filter(theme_id=form.data[form.prefix +
                                                               '-theme'],
                                            reviewer=reviewer)
        except MultiValueDictKeyError:
            # Address off-by-one error caused by management form.
            continue
        if lock and form.is_valid():
            scores.append(form.save())

    # Success message.
    points = sum(scores)
    success = ngettext(
        # L10n: {0} is the number of reviews. {1} is the points just earned.
        # L10n: {2} is the total number of points the reviewer has overall.
        '{0} theme review successfully processed (+{1} points, {2} total).',
        '{0} theme reviews successfully processed (+{1} points, {2} total).',
        len(scores)).format(len(scores), points,
                            ReviewerScore.get_total(request.amo_user))
    amo.messages.success(request, success)

    if 'theme_redirect_url' in request.session:
        return redirect(request.session['theme_redirect_url'])
    else:
        return redirect(reverse('reviewers.themes.queue_themes'))
コード例 #20
0
ファイル: forms.py プロジェクト: rtilder/zamboni
    def clean_categories(self):
        if self.disabled:
            raise forms.ValidationError(
                _('Categories cannot be changed while your app is featured.'))

        categories = self.cleaned_data['categories']
        set_categories = set(categories.values_list('id', flat=True))

        # Supervisored categories don't count towards the max, so subtract
        # them out if there are any.
        supervisor_of = self.special_cats()
        if supervisor_of.exists():
            set_categories -= set(supervisor_of.values_list('id', flat=True))

        total = len(set_categories)
        max_cat = amo.MAX_CATEGORIES

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))

        return categories
コード例 #21
0
ファイル: helpers.py プロジェクト: abhiii5459/olympia
def queue_tabnav(context):
    """Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (tab_code, page_url, tab_text)
    """
    from .views import queue_counts

    counts = queue_counts()
    tabnav = [
        (
            "fast_track",
            "queue_fast_track",
            (ngettext("Fast Track ({0})", "Fast Track ({0})", counts["fast_track"]).format(counts["fast_track"])),
        ),
        (
            "nominated",
            "queue_nominated",
            (ngettext("Full Review ({0})", "Full Reviews ({0})", counts["nominated"]).format(counts["nominated"])),
        ),
        (
            "pending",
            "queue_pending",
            (ngettext("Pending Update ({0})", "Pending Updates ({0})", counts["pending"]).format(counts["pending"])),
        ),
        (
            "prelim",
            "queue_prelim",
            (
                ngettext("Preliminary Review ({0})", "Preliminary Reviews ({0})", counts["prelim"]).format(
                    counts["prelim"]
                )
            ),
        ),
        (
            "moderated",
            "queue_moderated",
            (
                ngettext("Moderated Review ({0})", "Moderated Reviews ({0})", counts["moderated"]).format(
                    counts["moderated"]
                )
            ),
        ),
    ]

    return tabnav
コード例 #22
0
ファイル: helpers.py プロジェクト: gkoberger/zamboni
def queue_tabnav(context):
    """Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (tab_code, page_url, tab_text)
    """
    counts = queue_counts()
    return [('apps', 'queue_pending',
             ngettext('Apps ({0})', 'Apps ({0})', counts['pending'])
             .format(counts['pending']))]
コード例 #23
0
def queue_tabnav(context):
    """Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (tab_code, page_url, tab_text)
    """
    counts = queue_counts()
    return [('apps', 'queue_pending',
             ngettext('Apps ({0})', 'Apps ({0})',
                      counts['pending']).format(counts['pending']))]
コード例 #24
0
ファイル: helpers.py プロジェクト: Nolski/olympia
def queue_tabnav(context):
    """Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (tab_code, page_url, tab_text)
    """
    counts = context['queue_counts']
    unlisted_counts = context['unlisted_queue_counts']
    listed = not context.get('unlisted')

    if listed:
        tabnav = [('fast_track', 'queue_fast_track',
                   (ngettext('Fast Track ({0})',
                             'Fast Track ({0})',
                             counts['fast_track'])
                    .format(counts['fast_track']))),
                  ('nominated', 'queue_nominated',
                   (ngettext('Full Review ({0})',
                             'Full Reviews ({0})',
                             counts['nominated'])
                    .format(counts['nominated']))),
                  ('pending', 'queue_pending',
                   (ngettext('Pending Update ({0})',
                             'Pending Updates ({0})',
                             counts['pending'])
                    .format(counts['pending']))),
                  ('prelim', 'queue_prelim',
                   (ngettext('Preliminary Review ({0})',
                             'Preliminary Reviews ({0})',
                             counts['prelim'])
                    .format(counts['prelim']))),
                  ('moderated', 'queue_moderated',
                   (ngettext('Moderated Review ({0})',
                             'Moderated Reviews ({0})',
                             counts['moderated'])
                    .format(counts['moderated'])))]
    else:
        tabnav = [('nominated', 'unlisted_queue_nominated',
                   (ngettext('Unlisted Full Review ({0})',
                             'Unlisted Full Reviews ({0})',
                             unlisted_counts['nominated'])
                    .format(unlisted_counts['nominated']))),
                  ('pending', 'unlisted_queue_pending',
                   (ngettext('Unlisted Pending Update ({0})',
                             'Unlisted Pending Updates ({0})',
                             unlisted_counts['pending'])
                    .format(unlisted_counts['pending']))),
                  ('prelim', 'unlisted_queue_prelim',
                   (ngettext('Unlisted Preliminary Review ({0})',
                             'Unlisted Preliminary Reviews ({0})',
                             unlisted_counts['prelim'])
                    .format(unlisted_counts['prelim'])))]

    return tabnav
コード例 #25
0
def timesince(t):
    """Show relative time deltas. > 7 days, fall back to babel_date."""
    diff = (datetime.datetime.now() - t)
    if diff.days > 7:
        return babel_date(t)
    elif diff.days > 0:
        return ngettext('{0} day ago', '{0} days ago',
                        diff.days).format(diff.days)
    else:
        minutes = diff.seconds / 60
        hours = minutes / 60
        if hours > 0:
            return ngettext('{0} hour ago', '{0} hours ago',
                            hours).format(hours)
        elif minutes > 0:
            return ngettext('{0} minute ago', '{0} minutes ago',
                            minutes).format(minutes)
        else:
            # L10n: This means an event that happened only a few seconds ago.
            return _('just now')
コード例 #26
0
ファイル: helpers.py プロジェクト: jlongster/reporter
def timesince(t):
    """Show relative time deltas. > 7 days, fall back to babel_date."""
    diff = (datetime.datetime.now() - t)
    if diff.days > 7:
        return babel_date(t)
    elif diff.days > 0:
        return ngettext('{0} day ago', '{0} days ago',
                        diff.days).format(diff.days)
    else:
        minutes = diff.seconds / 60
        hours = minutes / 60
        if hours > 0:
            return ngettext('{0} hour ago', '{0} hours ago',
                            hours).format(hours)
        elif minutes > 0:
            return ngettext('{0} minute ago', '{0} minutes ago',
                            minutes).format(minutes)
        else:
            # L10n: This means an event that happened only a few seconds ago.
            return _('just now')
コード例 #27
0
ファイル: forms.py プロジェクト: ujdhesa/zamboni
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        max_cat = mkt.MAX_CATEGORIES

        if len(set(categories)) > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))

        return categories
コード例 #28
0
ファイル: forms.py プロジェクト: waseem18/zamboni
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        max_cat = mkt.MAX_CATEGORIES

        if len(set(categories)) > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(
                ngettext('You can have only {0} category.',
                         'You can have only {0} categories.',
                         max_cat).format(max_cat))

        return categories
コード例 #29
0
ファイル: serializers.py プロジェクト: waseem18/zamboni
    def validate_categories(self, categories):
        set_categories = set(categories)
        total = len(set_categories)
        max_cat = mkt.MAX_CATEGORIES

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise serializers.ValidationError(
                ngettext('You can have only {0} category.',
                         'You can have only {0} categories.',
                         max_cat).format(max_cat))

        return categories
コード例 #30
0
ファイル: serializers.py プロジェクト: waseem18/zamboni
    def validate_categories(self, categories):
        set_categories = set(categories)
        total = len(set_categories)
        max_cat = mkt.MAX_CATEGORIES

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise serializers.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))

        return categories
コード例 #31
0
    def validate_categories(self, attrs, source):
        if not attrs.get('categories'):
            raise serializers.ValidationError('This field is required.')
        set_categories = set(attrs[source])
        total = len(set_categories)
        max_cat = amo.MAX_CATEGORIES

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise serializers.ValidationError(
                ngettext('You can have only {0} category.',
                         'You can have only {0} categories.',
                         max_cat).format(max_cat))
        return attrs
コード例 #32
0
ファイル: api.py プロジェクト: aricha/zamboni
    def validate_categories(self, attrs, source):
        if not attrs.get('categories'):
            raise serializers.ValidationError('This field is required.')
        set_categories = set(attrs[source])
        total = len(set_categories)
        max_cat = amo.MAX_CATEGORIES

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise serializers.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))
        return attrs
コード例 #33
0
ファイル: forms.py プロジェクト: Hitechverma/zamboni
    def clean_categories(self):
        categories = self.cleaned_data["categories"]
        set_categories = set(categories)
        total = len(set_categories)
        max_cat = mkt.MAX_CATEGORIES

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(
                ngettext("You can have only {0} category.", "You can have only {0} categories.", max_cat).format(
                    max_cat
                )
            )

        return categories
コード例 #34
0
def queue_tabnav(context):
    """Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (tab_code, page_url, tab_text)
    """
    counts = context['queue_counts']
    unlisted_counts = context['unlisted_queue_counts']
    listed = not context.get('unlisted')

    if listed:
        tabnav = [
            ('fast_track', 'queue_fast_track',
             (ngettext('Fast Track ({0})', 'Fast Track ({0})',
                       counts['fast_track']).format(counts['fast_track']))),
            ('nominated', 'queue_nominated',
             (ngettext('Full Review ({0})', 'Full Reviews ({0})',
                       counts['nominated']).format(counts['nominated']))),
            ('pending', 'queue_pending',
             (ngettext('Pending Update ({0})', 'Pending Updates ({0})',
                       counts['pending']).format(counts['pending']))),
            ('prelim', 'queue_prelim',
             (ngettext('Preliminary Review ({0})', 'Preliminary Reviews ({0})',
                       counts['prelim']).format(counts['prelim']))),
            ('moderated', 'queue_moderated',
             (ngettext('Moderated Review ({0})', 'Moderated Reviews ({0})',
                       counts['moderated']).format(counts['moderated'])))
        ]
    else:
        tabnav = [
            ('nominated', 'unlisted_queue_nominated',
             (ngettext('Unlisted Full Review ({0})',
                       'Unlisted Full Reviews ({0})',
                       unlisted_counts['nominated']).format(
                           unlisted_counts['nominated']))),
            ('pending', 'unlisted_queue_pending',
             (ngettext('Unlisted Pending Update ({0})',
                       'Unlisted Pending Updates ({0})',
                       unlisted_counts['pending']).format(
                           unlisted_counts['pending']))),
            ('prelim', 'unlisted_queue_prelim', (ngettext(
                'Unlisted Preliminary Review ({0})',
                'Unlisted Preliminary Reviews ({0})',
                unlisted_counts['prelim']).format(unlisted_counts['prelim'])))
        ]

    return tabnav
コード例 #35
0
ファイル: forms.py プロジェクト: amitdash/zamboni
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        set_categories = set(categories.values_list('id', flat=True))

        total = len(set_categories)
        max_cat = amo.MAX_CATEGORIES

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))

        return categories
コード例 #36
0
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        set_categories = set(categories.values_list('id', flat=True))

        total = len(set_categories)
        max_cat = amo.MAX_CATEGORIES

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(
                ngettext('You can have only {0} category.',
                         'You can have only {0} categories.',
                         max_cat).format(max_cat))

        return categories
コード例 #37
0
ファイル: forms.py プロジェクト: AutomatedTester/zamboni
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        total = categories.count()
        max_cat = amo.MAX_CATEGORIES
        if total > max_cat:
            raise forms.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))

        has_misc = filter(lambda x: x.misc, categories)
        if has_misc and total > 1:
            raise forms.ValidationError(
                _("The miscellaneous category cannot be combined with "
                  "additional categories."))

        return categories
コード例 #38
0
ファイル: forms.py プロジェクト: superduper/zamboni
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        total = categories.count()
        max_cat = amo.MAX_CATEGORIES

        if self.disabled:
            raise forms.ValidationError(
                _('Categories cannot be changed while your app is featured.'))

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(
                ngettext('You can have only {0} category.',
                         'You can have only {0} categories.',
                         max_cat).format(max_cat))

        return categories
コード例 #39
0
ファイル: forms.py プロジェクト: exezaid/zamboni
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        total = categories.count()
        max_cat = amo.MAX_CATEGORIES
        if total > max_cat:
            raise forms.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))

        has_misc = filter(lambda x: x.misc, categories)
        if has_misc and total > 1:
            raise forms.ValidationError(
                _("The miscellaneous category cannot be combined with "
                  "additional categories."))

        return categories
コード例 #40
0
ファイル: forms.py プロジェクト: lauraxt/zamboni
    def clean_categories(self):
        categories = self.cleaned_data['categories']
        total = categories.count()
        max_cat = amo.MAX_CATEGORIES

        if self.disabled:
            raise forms.ValidationError(
                _('Categories cannot be changed while your app is featured.'))

        if total > max_cat:
            # L10n: {0} is the number of categories.
            raise forms.ValidationError(ngettext(
                'You can have only {0} category.',
                'You can have only {0} categories.',
                max_cat).format(max_cat))

        return categories
コード例 #41
0
ファイル: __init__.py プロジェクト: viczsaurav/olympia
 def count_term(count):
     return ngettext('{0} digg', '{0} diggs', count).format(count)
コード例 #42
0
ファイル: __init__.py プロジェクト: viczsaurav/olympia
 def count_term(count):
     return ngettext('{0} share', '{0} shares', count).format(count)
コード例 #43
0
 def count_term(count):
     """Render this service's share count with the right term."""
     return ngettext('{0} post', '{0} posts', count).format(count)
コード例 #44
0
ファイル: models.py プロジェクト: fligtar/zamboni
 def count_term(count):
     return ngettext('{0} email', '{0} emails', count).format(count)
コード例 #45
0
ファイル: __init__.py プロジェクト: AALEKH/zamboni
 def count_term(count):
     # L10n: Only change if you have reason! wiki.mozilla.org/AMO:Localizers
     return ngettext('{0} post on localservice2',
                     '{0} posts on localservice2', count).format(count)
コード例 #46
0
 def count_term(count):
     # L10n: Only change if you have reason! wiki.mozilla.org/AMO:Localizers
     return ngettext('{0} post on localservice3',
                     '{0} posts on localservice3', count).format(count)
コード例 #47
0
ファイル: helpers.py プロジェクト: MaxMillion/zamboni
def weekly_downloads(product):
    cnt = product.weekly_downloads
    return ngettext('{0} weekly download', '{0} weekly downloads',
                    cnt).format(numberfmt(cnt))
コード例 #48
0
ファイル: models.py プロジェクト: fligtar/zamboni
 def count_term(count):
     return ngettext('{0} digg', '{0} diggs', count).format(count)
コード例 #49
0
ファイル: models.py プロジェクト: fligtar/zamboni
 def count_term(count):
     return ngettext('{0} share', '{0} shares', count).format(count)
コード例 #50
0
ファイル: models.py プロジェクト: fligtar/zamboni
 def count_term(count):
     return ngettext('{0} tweet', '{0} tweets', count).format(count)
コード例 #51
0
def weekly_downloads(product):
    cnt = product.weekly_downloads
    return ngettext('{0} weekly download', '{0} weekly downloads',
                    cnt).format(numberfmt(cnt))
コード例 #52
0
 def count_term(count):
     return ngettext('{0} tweet', '{0} tweets', count).format(count)
コード例 #53
0
 def count_term(count):
     return ngettext('{0} Like', '{0} Likes', count).format(count)
コード例 #54
0
 def count_term(count):
     return ngettext('{0} Like', '{0} Likes', count).format(count)
コード例 #55
0
ファイル: models.py プロジェクト: fligtar/zamboni
 def count_term(count):
     """Render this service's share count with the right term."""
     return ngettext('{0} post', '{0} posts', count).format(count)