예제 #1
0
파일: views.py 프로젝트: ldolberg/udata
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)))
예제 #2
0
파일: views.py 프로젝트: pombredanne/udata
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
예제 #3
0
파일: views.py 프로젝트: pombredanne/udata
    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
예제 #4
0
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)
예제 #5
0
파일: views.py 프로젝트: rossjones/udata
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)
예제 #6
0
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
예제 #7
0
파일: views.py 프로젝트: guillo-w/udata
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))
    )
예제 #8
0
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)))
예제 #9
0
파일: views.py 프로젝트: rossjones/udata
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,
    )
예제 #10
0
파일: views.py 프로젝트: guillo-w/udata
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)
예제 #11
0
파일: views.py 프로젝트: guillo-w/udata
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
    )
예제 #12
0
파일: views.py 프로젝트: rossjones/udata
    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
예제 #13
0
파일: home.py 프로젝트: rossjones/udata
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
    )