def render_search(): params = multi_to_dict(request.args) params['facets'] = True # We only fetch relevant data for the given filter. if 'tag' in params: search_queries = [ search.SearchQuery(Dataset, **params), search.SearchQuery(Reuse, **params) ] results_labels = ['datasets', 'reuses'] elif 'badge' in params: search_queries = [ search.SearchQuery(Dataset, **params), search.SearchQuery(Organization, **params) ] results_labels = ['datasets', 'organizations'] else: search_queries = [ search.SearchQuery(Dataset, **params), search.SearchQuery(Reuse, **params), search.SearchQuery(Organization, **params), search.SearchQuery(User, **params) ] results_labels = ['datasets', 'reuses', 'organizations', 'users'] results = search.multiquery(*search_queries) return theme.render('search.html', **dict(zip(results_labels, results)))
def default_home_context_processor(context): recent_datasets, recent_reuses = search.multiquery( search.SearchQuery(Dataset, sort='-created', page_size=12), search.SearchQuery(Reuse, sort='-created', page_size=12), ) context.update(recent_datasets=recent_datasets, recent_reuses=recent_reuses) return 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
def render_search(): params = multi_to_dict(request.args) params['facets'] = True # We only fetch relevant data for the given filter. if 'tag' in params: search_queries = [ search.SearchQuery(Dataset, **params), search.SearchQuery(Reuse, **params) ] results_labels = ['datasets', 'reuses'] elif 'badge' in params: search_queries = [ search.SearchQuery(Dataset, **params), search.SearchQuery(Organization, **params) ] results_labels = ['datasets', 'organizations'] else: search_queries = [ search.SearchQuery(Dataset, **params), search.SearchQuery(Reuse, **params), search.SearchQuery(Organization, **params), search.SearchQuery(User, **params) ] results_labels = ['datasets', 'reuses', 'organizations', 'users'] results = search.multiquery(*search_queries) context = dict(zip(results_labels, results)) context['territories'] = check_for_territories(params.get('q')) return theme.render('search.html', **context)
def search(): datasets, organizations, reuses = multiquery( SearchQuery(DatasetSearch, **multi_to_dict(request.args)), SearchQuery(OrganizationSearch, **multi_to_dict(request.args)), SearchQuery(ReuseSearch, **multi_to_dict(request.args)), ) return render("search.html", datasets=datasets, organizations=organizations, reuses=reuses)
def display(topic): specs = { 'recent_datasets': TopicSearchQuery(Dataset, sort='-created', page_size=9, topic=topic), 'featured_reuses': TopicSearchQuery(Reuse, featured=True, page_size=6, topic=topic), } keys, queries = zip(*specs.items()) results = search.multiquery(*queries) return theme.render('topic/display.html', topic=topic, **dict(zip(keys, results)) )
def display(topic): specs = { 'recent_datasets': TopicSearchQuery(Dataset, sort='-created', page_size=9, topic=topic), 'featured_reuses': TopicSearchQuery(Reuse, featured=True, page_size=6, topic=topic), } keys, queries = zip(*specs.items()) results = search.multiquery(*queries) return theme.render('topic/display.html', topic=topic, **dict(zip(keys, results)))
def display(topic): kwargs = multi_to_dict(request.args) kwargs.update(topic=topic) datasets, reuses = multiquery( TopicSearchQuery(DatasetSearch, **kwargs), TopicSearchQuery(ReuseSearch, **kwargs), ) return render('topic/display.html', topic=topic, datasets=datasets, reuses=reuses, )
def render_search(): params = multi_to_dict(request.args) params['facets'] = True datasets, organizations, reuses, users = search.multiquery( search.SearchQuery(Dataset, **params), search.SearchQuery(Organization, **params), search.SearchQuery(Reuse, **params), search.SearchQuery(User, **params), ) return theme.render('search.html', datasets=datasets, organizations=organizations, reuses=reuses, users=users)
def render_search(): params = multi_to_dict(request.args) params['facets'] = True datasets, organizations, reuses, users = search.multiquery( search.SearchQuery(Dataset, **params), search.SearchQuery(Organization, **params), search.SearchQuery(Reuse, **params), search.SearchQuery(User, **params), ) return theme.render('search.html', datasets=datasets, organizations=organizations, reuses=reuses, users=users )
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
def home(): # TODO:allow customization recent_datasets, recent_reuses, featured_datasets, featured_reuses, popular_datasets, popular_reuses = multiquery( SearchQuery(DatasetSearch, sort="-created", page_size=TAB_SIZE), SearchQuery(ReuseSearch, sort="-created", page_size=TAB_SIZE), SearchQuery(DatasetSearch, featured=True, page_size=3), SearchQuery(ReuseSearch, featured=True, page_size=3), SearchQuery(DatasetSearch, page_size=TAB_SIZE), SearchQuery(ReuseSearch, page_size=TAB_SIZE), ) return render( "home.html", recent_datasets=recent_datasets, recent_reuses=recent_reuses, featured_datasets=featured_datasets, featured_reuses=featured_reuses, popular_datasets=popular_datasets, popular_reuses=popular_reuses, last_post=Post.objects(private=False).order_by("-created_at").first(), # TODO extract into extension )