def __init__(self, *args, **kwargs): q = CommonQuey() business = kwargs.pop('business', 1) fromdate = kwargs.pop('fromdate', datetime.datetime.now) todate = kwargs.pop('todate', datetime.datetime.now) #the pop statements should be executed first super(CheatQueryFilterForm, self).__init__(*args, **kwargs) self.fields['business'] = forms.ChoiceField(q.get_business(), initial=business) self.fields['fromdate'] = forms.DateField(initial=fromdate) self.fields['todate'] = forms.DateField(initial=todate)
class HotqueryFilterForm(forms.Form): q = CommonQuey() city_list = forms.ChoiceField(q.get_city_list()) def __init__(self, *args, **kwargs): q = CommonQuey() business = kwargs.pop('business', 1) fromdate = kwargs.pop('fromdate', datetime.datetime.now) todate = kwargs.pop('todate', datetime.datetime.now) #the pop statements should be executed first super(HotqueryFilterForm, self).__init__(*args, **kwargs) self.fields['business'] = forms.ChoiceField(q.get_business(), initial=business) self.fields['fromdate'] = forms.DateField(initial=fromdate) self.fields['todate'] = forms.DateField(initial=todate) self.fields['algo_list'] = SimpleChoiceFeild( q.get_algo_version(business, fromdate, todate))
def test_get_query_process(self): k_list = CommonQuey().get_query_process(3, '2013-09-11', '2013-09-18') #self.assertTrue(len(k_list)>0) pass
def test_get_category(self): c_list = CommonQuey().get_category() self.assertTrue(len(c_list) > 0)
def test_get_query_type(self): query_type = CommonQuey().get_query_type() self.assertTrue(len(query_type) > 0)
def test_get_city_list(self): city_list = CommonQuey().get_city_list() self.assertTrue(len(city_list) > 0)
def test_get_algo_version(self): algo_l = CommonQuey().get_algo_version(3, '2013-09-11', '2013-09-18') self.assertTrue(True)
def test_get_business(self): business_d = CommonQuey().get_business() self.assertTrue('主站商户' in business_d)
def query_category(request, business, fromdate, todate): fromdate = str_to_date(fromdate) todate = str_to_date(todate) query_category_list = CommonQuey().get_query_category(business, fromdate, todate) return HttpResponse(json.dumps(query_category_list), content_type="application/json")
def algo_list(request, business, fromdate, todate): fromdate = str_to_date(fromdate) todate = str_to_date(todate) algo_list = CommonQuey().get_algo_version(business, fromdate, todate) return HttpResponse(json.dumps(algo_list), content_type="application/json")