22import django .utils .html
33from django .shortcuts import render_to_response as render
44from ietf .idtracker .models import IETFWG , InternetDraft , Rfc
5- from ietf .ipr .models import IprRfc , IprDraft
5+ from ietf .ipr .models import IprRfc , IprDraft , IprDetail
66from ietf .ipr .related import related_docs
77from ietf .utils import log
88
@@ -20,6 +20,8 @@ def search(request, type="", q="", id=""):
2020 id = value
2121 if type and q or id :
2222 log ("Got query: type=%s, q=%s, id=%s" % (type , q , id ))
23+
24+ # Search by RFC number or draft-identifier
2325 if type in ["document_search" , "rfc_search" ]:
2426 if type == "document_search" :
2527 if q :
@@ -47,20 +49,40 @@ def search(request, type="", q="", id=""):
4749 doc .iprs = disclosures
4850 iprs += disclosures
4951 iprs = list (set (iprs ))
50- return render ("ipr/search_doc_result.html" , {"first" : first , "iprs" : iprs , "docs" : docs })
52+ return render ("ipr/search_doc_result.html" , {"q" : q , " first" : first , "iprs" : iprs , "docs" : docs })
5153 elif start .count ():
52- return render ("ipr/search_doc_list.html" , {"docs" : start })
54+ return render ("ipr/search_doc_list.html" , {"q" : q , " docs" : start })
5355 else :
5456 raise ValueError ("Missing or malformed search parameters, or internal error" )
57+
58+ # Search by legal name
5559 elif type == "patent_search" :
56- pass
60+ iprs = IprDetail .objects .filter (legal_name__icontains = q , status__in = [1 ,3 ]).order_by ("-submitted_date" , "-ipr_id" )
61+ count = iprs .count ()
62+ iprs = [ ipr for ipr in iprs if not ipr .updated_by .all () ]
63+ # Some extra information, to help us render 'and' between the
64+ # last two documents in a sequence
65+ for ipr in iprs :
66+ if ipr .drafts .count ():
67+ ipr .last_draft = ipr .drafts .all ()[int (ipr .drafts .count ())- 1 ]
68+ if ipr .rfcs .count ():
69+ ipr .last_rfc = ipr .rfcs .all ()[int (ipr .rfcs .count ())- 1 ]
70+ return render ("ipr/search_holder_result.html" , {"q" : q , "iprs" : iprs , "count" : count } )
71+
72+ # Search by content of email or pagent_info field
5773 elif type == "patent_info_search" :
5874 pass
75+
76+ # Search by wg acronym
5977 elif type == "wg_search" :
6078 pass
79+
80+ # Search by rfc and id title
6181 elif type == "title_search" :
6282 pass
63- elif type == "ip_title_search" :
83+
84+ # Search by title of IPR disclosure
85+ elif type == "ipr_title_search" :
6486 pass
6587 else :
6688 raise ValueError ("Unexpected search type in IPR query: %s" % type )
0 commit comments