def get_context_data(self, **kwargs): form = SearchCaseForm(self.request.GET) if self.request.GET.get('product'): form.populate(product_id=self.request.GET['product']) else: form.populate() return { 'form': form, }
def get_context_data(self, **kwargs): form = SearchCaseForm(self.request.GET) if self.request.GET.get("product"): form.populate(product_id=self.request.GET["product"]) else: form.populate() return { "form": form, }
def search(request): """ Shows the search form which uses JSON RPC to fetch the resuts """ form = SearchCaseForm(request.GET) if request.GET.get('product'): form.populate(product_id=request.GET['product']) else: form.populate() context_data = { 'form': form, } return render(request, 'testcases/search.html', context_data)
def build_cases_search_form(request, populate=None, plan=None): """Build search form preparing for quering TestCases""" # Initial the form and template action = request.POST.get('a') if action in TESTCASE_OPERATION_ACTIONS: search_form = SearchCaseForm(request.POST) request.session['items_per_page'] = \ request.POST.get('items_per_page', settings.DEFAULT_PAGE_SIZE) else: d_status = get_case_status(request.POST.get('template_type')) d_status_ids = d_status.values_list('pk', flat=True) items_per_page = request.session.get('items_per_page', settings.DEFAULT_PAGE_SIZE) search_form = SearchCaseForm(initial={ 'case_status': d_status_ids, 'items_per_page': items_per_page }) if populate: if request.POST.get('product'): search_form.populate(product_id=request.POST['product']) elif plan and plan.product_id: search_form.populate(product_id=plan.product_id) else: search_form.populate() return search_form