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

Python models.Reuse类代码示例

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

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



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

示例1: get_context

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

        can_edit = EditOrganizationPermission(self.organization)
        can_view = OrganizationPrivatePermission(self.organization)

        if self.organization.deleted and not can_view.can():
            abort(410)

        datasets = Dataset.objects(organization=self.organization).order_by('-temporal_coverage.end', '-metrics.reuses', '-metrics.followers').visible()
        reuses = Reuse.objects(organization=self.organization).order_by('-metrics.reuses', '-metrics.followers').visible()
        followers = (Follow.objects.followers(self.organization)
                                   .order_by('follower.fullname'))
        context.update({
            'reuses': reuses.paginate(1, self.page_size),
            'datasets': datasets.paginate(1, self.page_size),
            'followers': followers,
            'can_edit': can_edit,
            'can_view': can_view,
            'private_reuses': (
                list(Reuse.objects(organization=self.object).hidden())
                if can_view else []),
            'private_datasets': (
                list(Dataset.objects(organization=self.object).hidden())
                if can_view else []),
        })
        return context
开发者ID:odtvince,项目名称:udata,代码行数:27,代码来源:views.py


示例2: aggregate_reuses_daily

def aggregate_reuses_daily(org, day):
    keys = ['reuses_{0}'.format(k) for k in KEYS]
    ids = [r.id for r in Reuse.objects(organization=org).only('id')]
    metrics = Metrics.objects(object_id__in=ids,
                              level='daily', date=day.isoformat())
    values = [int(metrics.sum('values.{0}'.format(k))) for k in KEYS]
    Metrics.objects.update_daily(org, day, **dict(zip(keys, values)))
开发者ID:noirbizarre,项目名称:udata-piwik,代码行数:7,代码来源:metrics.py


示例3: remote_reuses

 def remote_reuses(self):
     # dataset_ids = (d.ext['harvest'].remote_id for d in Dataset.objects(ext__harvest__harvester=self.harvester.id))
     # response = self.get('package_list')
     # for dataset_id in response['result']:
     for dataset in Dataset.objects(ext__harvest__harvester=self.harvester.id).timeout(False):
         try:
             resp = self.get('related_list', {'id': dataset.ext['harvest'].remote_id})
         except:
             log.error('Unable to parse reuse for dataset %s', dataset.id)
             continue
         for details in resp['result']:
             reuse_url = details['url']
             urlhash = Reuse.hash_url(reuse_url)
             reuse, _ = Reuse.objects.get_or_create(urlhash=urlhash, auto_save=False)
             reuse.url = reuse_url
             reuse.title = details['title']
             reuse.description = details['description']
             reuse.type = details['type']
             # reuse.url = details['url']
             reuse.image_url = details.get('image_url')
             reuse.featured = bool(details.get('featured', False))
             reuse.created_at = parse(details['created'])
             if details.get('owner_id'):
                 reuse.owner = self.get_harvested(User, details['owner_id'])
             if not dataset in reuse.datasets:
                 reuse.datasets.append(dataset)
                 for tag in dataset.tags:
                     if not tag in reuse.tags:
                         reuse.tags.append(tag)
             yield reuse
开发者ID:remilejeune,项目名称:udata-harvest,代码行数:30,代码来源:ckan.py


示例4: get_context

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

        org_id = str(self.organization.id)
        datasets, supplied_datasets, reuses = search.multiquery(
            search.SearchQuery(Dataset, sort='-created', organization=org_id, page_size=9),
            search.SearchQuery(Dataset, sort='-created', supplier=org_id, page_size=9),
            search.SearchQuery(Reuse, sort='-created', organization=org_id, page_size=9),

        )
        followers = FollowOrg.objects.followers(self.organization).order_by('follower.fullname')

        can_edit = EditOrganizationPermission(self.organization.id)
        context.update({
            'reuses': reuses,
            'datasets': datasets,
            'supplied_datasets': supplied_datasets,
            'followers': followers[:self.nb_followers],
            'can_edit': can_edit
        })
        if can_edit:
            context.update({
                'private_reuses': list(Reuse.objects(organization=self.object, private=True)),
                'private_datasets': list(Dataset.objects(organization=self.object, private=True)),
            })

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


示例5: get_context

 def get_context(self):
     context = super(OrganizationIssuesView, self).get_context()
     datasets = Dataset.objects(organization=self.organization)
     reuses = Reuse.objects(organization=self.organization)
     ids = [o.id for o in list(datasets) + list(reuses)]
     context['issues'] = Issue.objects(subject__in=ids)
     return context
开发者ID:grouan,项目名称:udata,代码行数:7,代码来源:views.py


示例6: home

def home():
    context = {
        'recent_datasets': Dataset.objects.visible(),
        'recent_reuses': Reuse.objects(featured=True).visible(),
        'last_post': Post.objects(private=False).first(),
    }
    processor = theme.current.get_processor('home')
    context = processor(context)
    return theme.render('home.html', **context)
开发者ID:anukat2015,项目名称:udata,代码行数:9,代码来源:views.py


示例7: dataconnexions5

def dataconnexions5():
    reuses = Reuse.objects(badges__kind=DATACONNEXIONS_5_CANDIDATE).visible()

    categories = [{
        'tag': tag,
        'label': label,
        'description': description,
        'reuses': reuses(tags=tag),
    } for tag, label, description in DATACONNEXIONS_5_CATEGORIES]
    return theme.render('dataconnexions-5.html', categories=categories)
开发者ID:opendatalu,项目名称:udata-gouvlu,代码行数:10,代码来源:views.py


示例8: dataconnexions6

def dataconnexions6():
    # Use tags until we are sure all reuse are correctly labeled
    # reuses = Reuse.objects(badges__kind=DATACONNEXIONS_6_CANDIDATE)
    reuses = Reuse.objects(tags='dataconnexions-6').visible()

    categories = [{
        'tag': tag,
        'label': label,
        'description': description,
        'reuses': reuses(tags=tag),
    } for tag, label, description in DATACONNEXIONS_6_CATEGORIES]
    return theme.render('dataconnexions-6.html', categories=categories)
开发者ID:opendatalu,项目名称:udata-gouvlu,代码行数:12,代码来源:views.py


示例9: explore

def explore():
    recent_datasets = list(Dataset.objects.visible().order_by('-date').limit(9))
    recent_reuses = list(Reuse.objects.order_by('-date').limit(9))
    featured_datasets = list(Dataset.objects(featured=True).visible().order_by('-date').limit(15))
    featured_reuses = list(Reuse.objects(featured=True).order_by('-date').limit(15))

    return render('explore.html',
        recent_datasets=recent_datasets,
        recent_reuses=recent_reuses,
        featured_datasets=featured_datasets,
        featured_reuses=featured_reuses,
    )
开发者ID:rossjones,项目名称:udata,代码行数:12,代码来源:explore.py


示例10: get_context

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

        datasets = Dataset.objects(organization=self.organization).visible().order_by('-created')
        supplied_datasets = Dataset.objects(supplier=self.organization).visible().order_by('-created')
        reuses = Reuse.objects(organization=self.organization).visible().order_by('-created')
        followers = FollowOrg.objects.followers(self.organization).order_by('follower.fullname')

        can_edit = EditOrganizationPermission(self.organization)
        can_view = OrganizationPrivatePermission(self.organization)
        context.update({
            'reuses': reuses.paginate(1, self.page_size),
            'datasets': datasets.paginate(1, self.page_size),
            'supplied_datasets': supplied_datasets[:self.page_size],
            'followers': followers[:self.nb_followers],
            'can_edit': can_edit,
            'can_view': can_view,
            'private_reuses': list(Reuse.objects(organization=self.object).hidden()) if can_view else [],
            'private_datasets': list(Dataset.objects(organization=self.object).hidden()) if can_view else [],
        })

        return context
开发者ID:guillo-w,项目名称:udata,代码行数:22,代码来源:views.py


示例11: get_context

 def get_context(self):
     context = super(DatasetDetailView, self).get_context()
     if not DatasetEditPermission(self.dataset).can():
         if self.dataset.private:
             abort(404)
         elif self.dataset.deleted:
             abort(410)
     context['reuses'] = Reuse.objects(datasets=self.dataset).visible()
     context['can_edit'] = DatasetEditPermission(self.dataset)
     context['can_edit_resource'] = ResourceEditPermission
     context['discussions'] = DatasetDiscussion.objects(
         subject=self.dataset)
     return context
开发者ID:javanna2000,项目名称:udata,代码行数:13,代码来源:views.py


示例12: get_context

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

        can_edit = EditOrganizationPermission(self.organization)
        can_view = OrganizationPrivatePermission(self.organization)

        if self.organization.deleted and not can_view.can():
            abort(410)

        datasets = Dataset.objects(organization=self.organization).visible()
        reuses = Reuse.objects(organization=self.organization).visible()
        followers = FollowOrg.objects.followers(self.organization).order_by("follower.fullname")
        context.update(
            {
                "reuses": reuses.paginate(1, self.page_size),
                "datasets": datasets.paginate(1, self.page_size),
                "followers": followers,
                "can_edit": can_edit,
                "can_view": can_view,
                "private_reuses": (list(Reuse.objects(organization=self.object).hidden()) if can_view else []),
                "private_datasets": (list(Dataset.objects(organization=self.object).hidden()) if can_view else []),
            }
        )
        return context
开发者ID:opendatalu,项目名称:udata,代码行数:24,代码来源:views.py


示例13: get_context

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

        org_id = str(self.organization.id)
        datasets, supplied_datasets, reuses = multiquery(
            SearchQuery(DatasetSearch, sort='-created', organization=org_id, page_size=9),
            SearchQuery(DatasetSearch, sort='-created', supplier=org_id, page_size=9),
            SearchQuery(ReuseSearch, sort='-created', organization=org_id, page_size=9),
        )

        context.update({
            'reuses': reuses,
            'datasets': datasets,
            'supplied_datasets': supplied_datasets,
            'private_reuses': list(Reuse.objects(organization=self.object, private=True)),
            'private_datasets': list(Dataset.objects(organization=self.object, private=True)),
            'can_edit': EditOrganizationPermission(self.organization.id)
        })

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


示例14: get_value

 def get_value(self):
     return Reuse.objects(owner=self.user).count()
开发者ID:odtvince,项目名称:udata,代码行数:2,代码来源:metrics.py


示例15: get_value

 def get_value(self):
     return Reuse.objects(organization=self.target).count()
开发者ID:grouan,项目名称:udata,代码行数:2,代码来源:metrics.py


示例16: get_value

 def get_value(self):
     reuse = (Reuse.objects(metrics__followers__gt=0).visible()
              .order_by('-metrics.followers').first())
     return reuse.metrics['followers'] if reuse else 0
开发者ID:opendatateam,项目名称:udata,代码行数:4,代码来源:metrics.py


示例17: get_value

 def get_value(self):
     ids = [d.id for d in
            (Reuse.objects(organization=self.target).only('id') or [])]
     return int(Metrics.objects(object_id__in=ids, level='daily')
                       .sum('values.nb_uniq_visitors'))
开发者ID:noirbizarre,项目名称:udata-piwik,代码行数:5,代码来源:metrics.py


示例18: get_value

 def get_value(self):
     reuse = Reuse.objects(metrics__datasets__gt=0).visible().order_by('-metrics.datasets').first()
     return reuse.metrics.get('datasets', 0)
开发者ID:guillo-w,项目名称:udata,代码行数:3,代码来源:metrics.py


示例19: check_url_does_not_exists

def check_url_does_not_exists(form, field):
    '''Ensure a reuse URL is not yet registered'''
    if field.data != field.object_data and Reuse.url_exists(field.data):
        raise validators.ValidationError(_('This URL is already registered'))
开发者ID:opendatateam,项目名称:udata,代码行数:4,代码来源:forms.py


示例20: get

 def get(self):
     '''List all my reuses (including private ones)'''
     if not current_user.is_authenticated():
         api.abort(401)
     return list(Reuse.objects(owner=current_user.id))
开发者ID:pombredanne,项目名称:udata,代码行数:5,代码来源:api.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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