当前位置: 首页>>代码示例>>Python>>正文


Python i18n._函数代码示例

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


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_context

    def get_context(self):
        context = super(OrganizationDashboardView, self).get_context()

        context['metrics'] = [{
            # 'title': _('Data'),
            'widgets': [
                {
                    'title': _('Datasets'),
                    'metric': 'datasets',
                    'type': 'line',
                    'endpoint': 'datasets.list',
                    'args': {'org': self.organization}
                },
                {
                    'title': _('Reuses'),
                    'metric': 'reuses',
                    'type': 'line',
                    'endpoint': 'reuses.list',
                    'args': {'org': self.organization}
                },
                {
                    'title': _('Followers'),
                    'metric': 'followers',
                    'type': 'line',
                }
            ]
        }]

        return context
开发者ID:pombredanne,项目名称:udata,代码行数:29,代码来源:views.py

示例2: notify_membership_response

def notify_membership_response(org, request):
    if request.status == "accepted":
        subject = _('You are now a member of the organization "%(org)s"', org=org)
        template = "new_member"
    else:
        subject, template = _("Membership refused"), "membership_refused"
    mail.send(subject, request.user, template, org=org, request=request)
开发者ID:ldolberg,项目名称:udata,代码行数:7,代码来源:tasks.py

示例3: notify_membership_response

def notify_membership_response(org, request):
    if request.status == 'accepted':
        subject, template = _(
            'You are now a member of the organization "%(org)s"', org=org),
        'new_member'
    else:
        subject, template = _('Membership refused'), 'membership_refused'
    mail.send(subject, request.user, template, org=org, request=request)
开发者ID:grouan,项目名称:udata,代码行数:8,代码来源:tasks.py

示例4: pre_validate

 def pre_validate(self, form):
     if self.data:
         if current_user.is_anonymous():
             raise validators.ValidationError(
                 _('You must be authenticated'))
         elif not admin_permission and current_user.id != self.data.id:
             raise validators.ValidationError(
                 _('You can only set yourself as owner'))
     return True
开发者ID:grouan,项目名称:udata,代码行数:9,代码来源:fields.py

示例5: test_labelize

    def test_labelize(self):
        self.assertEqual(self.facet.labelize('label', True),
                         'label: {0}'.format(_('yes')))
        self.assertEqual(self.facet.labelize('label', False),
                         'label: {0}'.format(_('no')))

        self.assertEqual(self.facet.labelize('label', 'true'),
                         'label: {0}'.format(_('yes')))
        self.assertEqual(self.facet.labelize('label', 'false'),
                         'label: {0}'.format(_('no')))
开发者ID:michelbl,项目名称:udata,代码行数:10,代码来源:test_search.py

示例6: pre_validate

 def pre_validate(self, form):
     if not self.data:
         return
     for tag in self.data:
         if not MIN_TAG_LENGTH <= len(tag) <= MAX_TAG_LENGTH:
             message = _('Tag "%(tag)s" must be between %(min)d and %(max)d characters long.',
                 min=MIN_TAG_LENGTH, max=MAX_TAG_LENGTH, tag=tag)
             raise validators.ValidationError(message)
         if not RE_TAG.match(tag):
             message = _('Tag "%(tag)s" must be alphanumeric characters or symbols: -_.', tag=tag)
             raise validators.ValidationError(message)
开发者ID:guillo-w,项目名称:udata,代码行数:11,代码来源:fields.py

示例7: notify_new_follower

def notify_new_follower(follow):
    if isinstance(follow.following, User):
        subject =_('%(user)s followed you', user=follow.follower)
        mail.send(subject, follow.following, 'new_follower', follow=follow)
    elif isinstance(follow.following, Organization):
        subject = _('%(user)s followed your organization', user=follow.follower)
        recipients = [m.user for m in follow.following.members]
        mail.send(subject, recipients, 'new_follower_org', follow=follow)
    elif isinstance(follow.following, Dataset):
        pass
    elif isinstance(follow.following, Reuse):
        pass
开发者ID:guillo-w,项目名称:udata,代码行数:12,代码来源:tasks.py

示例8: pre_validate

 def pre_validate(self, form):
     if self.data:
         try:
             uris.validate(self.data)
         except uris.ValidationError:
             raise validators.ValidationError(_('Invalid URL'))
     return True
开发者ID:opendatateam,项目名称:udata,代码行数:7,代码来源:fields.py

示例9: recent_feed

def recent_feed():
    feed = AtomFeed(_('Last datasets'),
                    feed_url=request.url, url=request.url_root)
    datasets = (Dataset.objects.visible().order_by('-created_at')
                .limit(current_site.feed_size))
    for dataset in datasets:
        author = None
        if dataset.organization:
            author = {
                'name': dataset.organization.name,
                'uri': url_for('organizations.show',
                               org=dataset.organization.id, _external=True),
            }
        elif dataset.owner:
            author = {
                'name': dataset.owner.fullname,
                'uri': url_for('users.show',
                               user=dataset.owner.id, _external=True),
            }
        feed.add(dataset.title,
                 render_template('dataset/feed_item.html', dataset=dataset),
                 content_type='html',
                 author=author,
                 url=url_for('datasets.show',
                             dataset=dataset.id, _external=True),
                 updated=dataset.last_modified,
                 published=dataset.created_at)
    return feed.get_response()
开发者ID:javanna2000,项目名称:udata,代码行数:28,代码来源:views.py

示例10: get

    def get(self, level):
        '''List each zone for a given level with their datasets count'''
        level = GeoLevel.objects.get_or_404(id=level)
        features = []

        for zone in GeoZone.objects(level=level.id):
            # fetch nested levels IDs
            ids = GeoZone.objects(parents=zone.id).only('id').distinct('id')
            ids.append(zone.id)
            # Count datasets in zone
            nb_datasets = Dataset.objects(spatial__zones__in=ids).count()
            features.append({
                'id': zone.id,
                'type': 'Feature',
                'geometry': zone.geom,
                'properties': {
                    'name': _(zone.name),
                    'code': zone.code,
                    'level': zone.level,
                    'datasets': nb_datasets
                }
            })

        return {
            'type': 'FeatureCollection',
            'features': features
        }
开发者ID:odtvince,项目名称:udata,代码行数:27,代码来源:api.py

示例11: notify_new_issue

def notify_new_issue(issue):
    if isinstance(issue.subject, (Dataset, Reuse)):
        recipients = owner_recipients(issue)
        subject = _('Your %(type)s have a new issue', type=issue.subject.verbose_name)
        mail.send(subject, recipients, 'new_issue', issue=issue)
    else:
        log.warning('Unrecognized issue subject type %s', type(issue.subject))
开发者ID:guillo-w,项目名称:udata,代码行数:7,代码来源:tasks.py

示例12: mark_as_deleted

 def mark_as_deleted(self):
     copied_user = copy(self)
     self.email = '{}@deleted'.format(self.id)
     self.password = None
     self.active = False
     self.first_name = 'DELETED'
     self.last_name = 'DELETED'
     self.avatar = None
     self.avatar_url = None
     self.website = None
     self.about = None
     self.extras = None
     self.deleted = datetime.now()
     self.save()
     for organization in self.organizations:
         organization.members = [member
                                 for member in organization.members
                                 if member.user != self]
         organization.save()
     for discussion in Discussion.objects(discussion__posted_by=self):
         for message in discussion.discussion:
             if message.posted_by == self:
                 message.content = 'DELETED'
         discussion.save()
     Follow.objects(follower=self).delete()
     Follow.objects(following=self).delete()
     mail.send(_('Account deletion'), copied_user, 'account_deleted')
开发者ID:odtvince,项目名称:udata,代码行数:27,代码来源:models.py

示例13: recent_feed

def recent_feed():
    feed = AtomFeed(_('Last reuses'),
                    feed_url=request.url, url=request.url_root)
    reuses = Reuse.objects.visible().order_by('-created_at').limit(15)
    for reuse in reuses:
        author = None
        if reuse.organization:
            author = {
                'name': reuse.organization.name,
                'uri': url_for('organizations.show',
                               org=reuse.organization.id, _external=True),
            }
        elif reuse.owner:
            author = {
                'name': reuse.owner.fullname,
                'uri': url_for('users.show',
                               user=reuse.owner.id, _external=True),
            }
        feed.add(reuse.title,
                 render_template('reuse/feed_item.html', reuse=reuse),
                 content_type='html',
                 author=author,
                 url=url_for('reuses.show', reuse=reuse.id, _external=True),
                 updated=reuse.created_at,
                 published=reuse.created_at)
    return feed.get_response()
开发者ID:odtvince,项目名称:udata,代码行数:26,代码来源:views.py

示例14: send_frequency_reminder

def send_frequency_reminder(self):
    # We exclude irrelevant frequencies.
    frequencies = [f for f in UPDATE_FREQUENCIES.keys()
                   if f not in ('unknown', 'realtime', 'punctual')]
    now = datetime.now()
    reminded_orgs = {}
    reminded_people = []
    allowed_delay = current_app.config['DELAY_BEFORE_REMINDER_NOTIFICATION']
    for org in Organization.objects.visible():
        outdated_datasets = []
        for dataset in Dataset.objects.filter(
                frequency__in=frequencies, organization=org).visible():
            if dataset.next_update + timedelta(days=allowed_delay) < now:
                dataset.outdated = now - dataset.next_update
                dataset.frequency_str = UPDATE_FREQUENCIES[dataset.frequency]
                outdated_datasets.append(dataset)
        if outdated_datasets:
            reminded_orgs[org] = outdated_datasets
    for reminded_org, datasets in reminded_orgs.iteritems():
        print(u'{org.name} will be emailed for {datasets_nb} datasets'.format(
              org=reminded_org, datasets_nb=len(datasets)))
        recipients = [m.user for m in reminded_org.members]
        reminded_people.append(recipients)
        subject = _('You need to update some frequency-based datasets')
        mail.send(subject, recipients, 'frequency_reminder',
                  org=reminded_org, datasets=datasets)

    print('{nb_orgs} orgs concerned'.format(nb_orgs=len(reminded_orgs)))
    reminded_people = flatten(reminded_people)
    print('{nb_emails} people contacted ({nb_emails_twice} twice)'.format(
        nb_emails=len(reminded_people),
        nb_emails_twice=len(reminded_people) - len(Set(reminded_people))))
    print('Done')
开发者ID:anukat2015,项目名称:udata,代码行数:33,代码来源:tasks.py

示例15: iter_choices

 def iter_choices(self):
     localized_choices = [
         (value, _(label) if label else '', selected)
         for value, label, selected in super(SelectField, self).iter_choices()
     ]
     for value, label, selected in sorted(localized_choices, key=lambda c: c[1]):
         yield (value, label, selected)
开发者ID:guillo-w,项目名称:udata,代码行数:7,代码来源:fields.py


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