Javascript python过滤器没有创建结果

Javascript python过滤器没有创建结果,javascript,python-2.7,filter,jinja2,webapp2,Javascript,Python 2.7,Filter,Jinja2,Webapp2,我正在从数据库中筛选数据以进行侧栏搜索 我正在为搜索创建过滤器,但“所有者”过滤器正在工作,其他两个过滤器“良好分类”和“应用程序编号”不工作,并且未显示任何结果。只需检查图像以了解清楚的想法 代码在Python2.7下面,这里使用了webapp2框架 所有者筛选结果 “尼斯分类”和“申请号” sidebar.html <aside class="main-sidebar"> <section class="sidebar"> <form action="#

我正在从数据库中筛选数据以进行侧栏搜索

我正在为搜索创建过滤器,但“所有者”过滤器正在工作,其他两个过滤器“良好分类”和“应用程序编号”不工作,并且未显示任何结果。只需检查图像以了解清楚的想法

代码在Python2.7下面,这里使用了webapp2框架

所有者筛选结果

“尼斯分类”和“申请号”

sidebar.html

<aside class="main-sidebar">
<section class="sidebar">
  <form action="#" method="get" class="sidebar-form">
    <h3 style="color: #ffffff; margin-top: 5px;">Filters</h3>
        <div class="form-group">
            <label>Markname</label>
            <input id="s_query" type="text" class="form-control" placeholder="Enter Text">
        </div>


        <div class="form-group">
        <label>Owners</label>
        <select id="s_assignees" class="form-control select2" multiple="multiple" style="width: 100%;">
        {% for assignee in project.assignees%}
          <option value="{{assignee}}">{{assignee}}</option>
        {% endfor %}
        </select>
        </div>    


     <div class="form-group">
            <label> Nice classification </label>
            <select id="s_classes" class="form-control select2" multiple="multiple" style="width: 100%;">
            {% for cl in project.classes %}
              <option value="{{cl}}">{{cl}}</option>
            {% endfor %}
            </select>
            </div>  

            <div class="form-group">
            <label> Application Number </label>
            <select id="s_applicationNo" class="form-control select2" multiple="multiple" style="width: 100%;">
            {% for ap in project.applicationNo   %}
              <option value="{{ap}}">{{ap}}</option>
            {% endfor %}
            </select>
            </div> 

        <div class="form-group">
        <label>Legal Status</label>
        <select id="s_legalStatus" class="form-control select2" multiple="multiple" style="width: 100%;">
        {% for ls in project.legalStatus%}
          <option value="{{ls}}">{{ls}}</option>
        {% endfor %}
        </select>
        </div>  

    <button type="button" id="s_filter-btn" data-tid="" onclick="filtering_sidebar();" class="btn btn-sm bg-blue">Filter</button>
  </form>
</section>
这是我们的处理程序

类过滤器MReportHandler(UserSessionHandler):
@需要登录
def get(自我,pid):
user=self.user\u session\u info
pid=str(urllib2.unquote(pid))
tid=self.request.get('tid')
owners=self.request.get('owners')
classes=self.request.get('classes')
applicationNo=self.request.get('applicationNo')
legalStatus=self.request.get('legalStatus')
ado=self.request.get('ado')
ad1=self.request.get('ad1')
ad2=self.request.get('ad2')
pdo=self.request.get('pdo')
pd1=self.request.get('pd1')
pd2=self.request.get('pd2')
rdo=self.request.get('rdo')
rd1=self.request.get('rd1')
rd2=self.request.get('rd2')
query=self.request.get('query')
flag=self.request.get('flag')
过滤器\u dict=dict(所有者=所有者,
类=类,
applicationNo=applicationNo,
legalStatus=legalStatus,
ado=ado,ad1=ad1,ad2=ad2,
pdo=pdo,pd1=pd1,pd2=pd2,
rdo=rdo,rd1=rd1,rd2=rd2,
查询=查询,标志=标志)
分类法_项=[]
prj_key=ndb.key('YoProject',long(pid))
project=YoProject.get_by_key_查询(prj_key).get()
文件\u blob\u键='NA'
如果project.file\u blob\u键不是None:
file\u blob\u key=project.file\u blob\u key
project\u dict=dict(name=project.project\u name,
pid=pid,
client=project.client\u name,
client_spoc_name=project.client_spoc_name,
受让人=项目。受让人,
file\u blob\u key=file\u blob\u key,
类型=项目类型,
applicationNo=project.applicationNo,
description=project.description,
分类法(id=project.taxonomy(id)
taxonomy\u key=ndb.key('taxonomy',long(project.taxonomy\u id))
taxonomy=taxonomy.get\u by\u key\u查询(taxonomy\u key.get())
taxonomy_l1s=TaxonomyItem.query(ndb.AND(TaxonomyItem.taxonomy_id==str(project.taxonomy_id),TaxonomyItem.level==1)).fetch()
对于分类法\u l1中的分类法\u l1:
结果=[]
tm_result_query=TrademarkResult.query(ndb.AND(TrademarkResult.project_id==str(pid),
TrademarkResult.taxonomy\u id==str(project.taxonomy\u id),
TrademarkResult.taxonomyItem==taxonomy_l1.name))
如果len(所有者)!=0:
a_list=owners.split(“,”)
tm\u query\u updated=tm\u result\u query.filter(TrademarkResult.ownerNames.IN(列表))
其他:
tm\u query\u updated=tm\u result\u query
如果len(类)!=0:
c_list=classes.split(“,”)
tm_query_updated=tm_query_updated.filter(TrademarkResult.classes.IN(c_列表))
如果len(应用程序编号)!=0:
ap_list=应用程序编号拆分(“,”)
tm\u query\u updated=tm\u query\u updated.filter(TrademarkResult.applicationNo.IN(ap\u列表))
如果len(legalStatus)!=0:
ls_list=legalStatus.split(“,”)
tm_query_updated=tm_query_updated.filter(TrademarkResult.legalStatus.IN(ls_列表))
如果len(ad1)!=0:
如果ado=='after':
tm_query_updated=tm_query_updated.filter(TrademarkResult.applicationDate>=datetime.datetime.strtime(str(ad1),'%m/%d/%Y'))
如果ado=='before':
tm_query_updated=tm_query_updated.filter(TrademarkResult.applicationDate=datetime.datetime.strtime(str(ad1),'%m/%d/%Y'))
tm_query_updated=tm_query_updated.filter(TrademarkResult.applicationDate 0:
markImgURL=tm_结果。markImgURLS[0]
avail_result=dict(order=tm_result.order,
markName=tm_result.markName,
markImgURLS=markImgURL,
trademarkType=tm_result.trademarkType,
所有者=tm_result.ownerNames,
类别=tm_结果类别,
应用日期=tm_结果。应用日期,
注册日期=tm_结果。注册日期,
DesignedContractedStates=tm_结果。DesignedContractedStates,
legalStatus=tm_result.legalStatus,
id_uu=tm_result.key.id(),
applicationNo=tm_result.applicationNo,
registrationno=tm_result.registrationno,
goodsServices=tm_结果。goodsServices[:100]+“…”)
其他:
avail_result=dict(order=tm_result.order,
markName=tm_result.markName,
trademarkType=tm_result.trademarkType,
所有者=tm_result.ownerNames,
应用日期=tm_resu
function filtering_sidebar(){
    var taxonomy_id = '';
    var items = [];
    $('#s_assignees option:selected').each(function(){ items.push($(this).val()); });
    var assignees = items.join(',');


    var items1 = [];
    $('#s_classes option:selected').each(function(){ items1.push($(this).val()); });
    var classes = items1.join(',');

    var items2 = [];
    $('#s_applicationNo option:selected').each(function(){ items2.push($(this).val()); });
    var applicationNo = items2.join(',');


    var items3 = [];
    $('#s_legalStatus option:selected').each(function(){ items3.push($(this).val()); });
    var legalStatus = items3.join(',');
    console.log(legalStatus);

    var ado = $('#s_a_date').val();
    var ad1 = $('#s_a_date_start').val();
    var ad2 = $('#s_a_date_end').val();

    var tiabTxt = $('#s_query').val();
    var flag = $('#s_flag').val();

    var win = window.open('/t/filter-report/{{project.pid}}?tid=' + taxonomy_id + '&owners=' + encodeURIComponent(assignees) +
                            '&classes=' + encodeURIComponent(classes) + '&applicationNo=' + encodeURIComponent(applicationNo)  +
                            '&legalStatus=' + encodeURIComponent(legalStatus) +
                            '&ado=' + ado + '&ad1=' + ad1 + '&ad2=' + ad2 +
                            '&query=' + tiabTxt + '&flag=' + flag, '_blank');
    if (win) {
        win.focus();
    } else {
        alert('Please allow popups for this website');
    }

}
class FilterTMReportHandler(UserSessionHandler):
@login_required
def get(self, pid):
    user = self.user_session_info
    pid = str(urllib2.unquote(pid))
    tid = self.request.get('tid')

    owners = self.request.get('owners')
    classes = self.request.get('classes')
    applicationNo = self.request.get('applicationNo')
    legalStatus = self.request.get('legalStatus')
    ado = self.request.get('ado')
    ad1 = self.request.get('ad1')
    ad2 = self.request.get('ad2')
    pdo = self.request.get('pdo')
    pd1 = self.request.get('pd1')
    pd2 = self.request.get('pd2')
    rdo = self.request.get('rdo')
    rd1 = self.request.get('rd1')
    rd2 = self.request.get('rd2')
    query = self.request.get('query')
    flag = self.request.get('flag')




    filters_dict = dict(owners=owners,
                        classes=classes,
                        applicationNo=applicationNo,
                        legalStatus=legalStatus,
                        ado=ado, ad1=ad1, ad2=ad2,
                        pdo=pdo,pd1=pd1,pd2=pd2,
                        rdo=rdo, rd1=rd1, rd2=rd2,
                        query=query, flag=flag)


    taxonomy_items = []

    prj_key = ndb.Key('YoProject', long(pid))

    project = YoProject.get_by_key_query(prj_key).get()

    file_blob_key = 'NA'
    if project.file_blob_key is not None:
        file_blob_key = project.file_blob_key

    project_dict = dict(name=project.project_name,
                        pid=pid,
                        client=project.client_name,
                        client_spoc_name=project.client_spoc_name,
                        assignees=project.assignees,
                        file_blob_key=file_blob_key,
                        type_=project.type_,
                        applicationNo=project.applicationNo,
                        description=project.description,
                        taxonomy_id=project.taxonomy_id)

    taxonomy_key = ndb.Key('Taxonomy', long(project.taxonomy_id))
    taxonomy = Taxonomy.get_by_key_query(taxonomy_key).get()

    taxonomy_l1s = TaxonomyItem.query(ndb.AND(TaxonomyItem.taxonomy_id == str(project.taxonomy_id), TaxonomyItem.level == 1)).fetch()

    for taxonomy_l1 in taxonomy_l1s:
        results = []

        tm_result_query = TrademarkResult.query(ndb.AND(TrademarkResult.project_id ==str(pid), 
                                                    TrademarkResult.taxonomy_id == str(project.taxonomy_id),
                                                    TrademarkResult.taxonomyItem == taxonomy_l1.name))


        if len(owners) != 0:
            a_list = owners.split(",")
            tm_query_updated = tm_result_query.filter(TrademarkResult.ownerNames.IN(a_list))
        else:
            tm_query_updated = tm_result_query

        if len(classes) != 0:
            c_list = classes.split(",")
            tm_query_updated = tm_query_updated.filter(TrademarkResult.classes.IN(c_list))  

        if len(applicationNo) != 0:
            ap_list = applicationNo.split(",")
            tm_query_updated = tm_query_updated.filter(TrademarkResult.applicationNo.IN(ap_list))


        if len(legalStatus) != 0:
            ls_list = legalStatus.split(",")
            tm_query_updated = tm_query_updated.filter(TrademarkResult.legalStatus.IN(ls_list))

        if len(ad1) != 0:
            if ado == 'after':
                tm_query_updated = tm_query_updated.filter(TrademarkResult.applicationDate >= datetime.datetime.strptime(str(ad1), '%m/%d/%Y'))

            if ado == 'before':
                tm_query_updated = tm_query_updated.filter(TrademarkResult.applicationDate <= datetime.datetime.strptime(str(ad1), '%m/%d/%Y'))

            if ado == 'between' and len(ad2) != 0:
                tm_query_updated = tm_query_updated.filter(TrademarkResult.applicationDate >= datetime.datetime.strptime(str(ad1), '%m/%d/%Y'))
                tm_query_updated = tm_query_updated.filter(TrademarkResult.applicationDate <= datetime.datetime.strptime(str(ad2), '%m/%d/%Y'))

        if len(flag) != 0:
            tm_query_updated = tm_query_updated.filter(TrademarkResult.flag == int(flag))


        tm_result_keys = tm_query_updated.fetch(keys_only=True)


        if len(tm_result_keys) == 0:
            continue
        else:
            tm_results = ndb.get_multi(tm_result_keys)

            for tm_result in tm_results:
                if len(query) != 0:
                    if query.lower() in tm_result.markName.lower():
                        if len(tm_result.markImgURLS) > 0:
                            markImgURL = tm_result.markImgURLS[0]
                            avail_result = dict(order=tm_result.order,
                                                markName=tm_result.markName,
                                                markImgURLS=markImgURL,
                                                trademarkType=tm_result.trademarkType,
                                                owners=tm_result.ownerNames,
                                                classes=tm_result.classes,
                                                applicationDate=tm_result.applicationDate,
                                                registrationDate=tm_result.registrationDate,
                                                designatedContractedStates=tm_result.designatedContractedStates,
                                                legalStatus=tm_result.legalStatus,
                                                id_=tm_result.key.id(),
                                                applicationNo=tm_result.applicationNo,
                                                registrtionNo=tm_result.registrtionNo,
                                                goodsServices=tm_result.goodsServices[:100] + '...')

                        else:
                            avail_result = dict(order=tm_result.order,
                                                markName=tm_result.markName,
                                                trademarkType=tm_result.trademarkType,
                                                owners=tm_result.ownerNames,
                                                applicationDate=tm_result.applicationDate,
                                                registrationDate=tm_result.registrationDate,
                                                applicationNo=tm_result.applicationNo,
                                                legalStatus=tm_result.legalStatus,
                                                id_=tm_result.key.id(),
                                                classes=tm_result.classes,
                                                designatedContractedStates=tm_result.designatedContractedStates,
                                                officeOfOrigin=tm_result.officeOfOrigin,
                                                flag=tm_result.flag,
                                                client_comment=tm_result.client_comment[:50] + '...',
                                                registrtionNo=tm_result.registrtionNo,
                                                goodsServices=tm_result.goodsServices[:100] + '...')
                        results.append(avail_result)
                else:
                    if len(tm_result.markImgURLS) > 0:
                        markImgURL = tm_result.markImgURLS[0]
                        avail_result = dict(order=tm_result.order,
                                            markName=tm_result.markName,
                                            markImgURLS=markImgURL,
                                            trademarkType=tm_result.trademarkType,
                                            owners=tm_result.ownerNames,
                                            classes=tm_result.classes,
                                            applicationDate=tm_result.applicationDate,
                                            registrationDate=tm_result.registrationDate,
                                            designatedContractedStates=tm_result.designatedContractedStates,
                                            legalStatus=tm_result.legalStatus,
                                            id_=tm_result.key.id(),
                                            applicationNo=tm_result.applicationNo,
                                            registrtionNo=tm_result.registrtionNo,
                                            goodsServices=tm_result.goodsServices[:100] + '...')

                    else:
                        avail_result = dict(order=tm_result.order,
                                            markName=tm_result.markName,
                                            trademarkType=tm_result.trademarkType,
                                            owners=tm_result.ownerNames,
                                            applicationDate=tm_result.applicationDate,
                                            registrationDate=tm_result.registrationDate,
                                            applicationNo=tm_result.applicationNo,
                                            legalStatus=tm_result.legalStatus,
                                            id_=tm_result.key.id(),
                                            classes=tm_result.classes,
                                            designatedContractedStates=tm_result.designatedContractedStates,
                                            officeOfOrigin=tm_result.officeOfOrigin,
                                            flag=tm_result.flag,
                                            client_comment=tm_result.client_comment[:50] + '...',
                                            registrtionNo=tm_result.registrtionNo,
                                            goodsServices=tm_result.goodsServices[:100] + '...')
                    results.append(avail_result)

            avail_tax_item = dict(name=taxonomy_l1.name,
                                    results=results, 
                                    count=len(results),
                                    id_=str(taxonomy_l1.key.id()))

            taxonomy_items.append(avail_tax_item)



    template_args = {'user': user, 
                        'project': project_dict, 
                        'taxonomy_items': taxonomy_items, 
                        'filters': filters_dict, 
                        'results': results}

    self.render_template('filteredtmreport.html', template_args)
 tm_result_keys = tm_query_updated.fetch(keys_only=True)
        if ado == 'between' and len(ad2) != 0:
            tm_query_updated = tm_query_updated.filter(TrademarkResult.applicationDate >= datetime.datetime.strptime(str(ad1), '%m/%d/%Y'))
            tm_query_updated = tm_query_updated.filter(TrademarkResult.applicationDate <= datetime.datetime.strptime(str(ad2), '%m/%d/%Y'))