def compare(request,p1): compare_form = CompareForm(request.GET if request.GET.get('submit',None) else None) context = {'compare_form':compare_form,'person1':p1} if compare_form.is_valid(): p2 = compare_form.cleaned_data['compare_to'] p1oked, p1vetoed = utils.get_data(p1) p2oked, p2vetoed = utils.get_data(p2) context['person2'] = p2 context['p1oked'] = utils.sort_nameset(p1oked-p2oked) context['p2oked'] = utils.sort_nameset(p2oked-p1oked) context['intersection'] = utils.sort_nameset(p2oked.intersection(p1oked)) return HttpResponse(loader.get_template("names/compare.html").render(RequestContext(request,context)))
def _get_form(request): """ Creates unbounded or bonded search and compare form. Depending on whether request object has data or not. :param request: HttpRequest object with data if user has submitted the form. :return: forms created """ if 'player1' and 'player2' in request.GET: search_form, compare_form, rank_form = SearchForm(), CompareForm(request.GET), SearchRankForm() elif 'search' in request.GET: search_form, compare_form, rank_form = SearchForm(request.GET), CompareForm(), SearchRankForm() elif 'search_rank' in request.GET: search_form, compare_form, rank_form = SearchForm(), CompareForm(), SearchRankForm(request.GET) else: search_form, compare_form, rank_form = SearchForm(), CompareForm(), SearchRankForm() return search_form, compare_form, rank_form
def script(): form = CompareForm() client1 = form.client1.data client2 = form.client2.data legal1 = form.Legal1.data legal2 = form.Legal2.data from_d = request.form['from'] plot_com(client1, client2, legal1, legal2, from_d) return render_template('output.html')
def compare(): form = CompareForm() return render_template('compare.html', form=form)