コード例 #1
0
ファイル: views.py プロジェクト: backmeup/backmeup-frontend
def search_result(request, search_id):
    if not 'search_results' in request.session:
        request.session['search_results'] = {}

    # cache search result
    try:
        result = request.session['search_results'][search_id]
    except Exception:
        rest_search = RestSearch(username=request.user.username)
        result = rest_search.get(search_id)
        request.session['search_results'][search_id] = result
        request.session.modified = True

    form = SearchFilterForm(request.POST or None, search_result=result)

    if form.is_valid():
        new_result = form.rest_save(search_id=search_id, username=request.user.username)
        result = new_result

    result = processSearchResult(result)

    return render_to_response('www/search_result.html', {
        'result': result,
        'search_id': search_id,
        'form': form,
    }, context_instance=RequestContext(request))
コード例 #2
0
ファイル: forms.py プロジェクト: backmeup/backmeup-frontend
    def rest_save(self, search_id, username):
        rest_search = RestSearch(username=username)
        data = {}
        if self.cleaned_data['datasource_filter']:
            data['source'] = self.cleaned_data['datasource_filter']
        if self.cleaned_data['type_filter']:
            data['type'] = self.cleaned_data['type_filter']
	if self.cleaned_data['job_filter']:
	    data['job'] = self.cleaned_data['job_filter']
        result = rest_search.get(search_id=search_id, data=data)
        return result