本文整理汇总了Python中udata.models.Reuse类的典型用法代码示例。如果您正苦于以下问题:Python Reuse类的具体用法?Python Reuse怎么用?Python Reuse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reuse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)))
示例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
示例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
示例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
示例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)
示例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)
示例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)
示例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,
)
示例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
示例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
示例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
示例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
示例14: get_value
def get_value(self):
return Reuse.objects(owner=self.user).count()
示例15: get_value
def get_value(self):
return Reuse.objects(organization=self.target).count()