@@ -90,7 +90,7 @@ def update(request, ipr_id=None):
9090 }
9191
9292display_relation = {
93- 'updates' : 'that updates ' ,
93+ 'updates' : 'that updated ' ,
9494 'is_updated_by' : 'that was updated by' ,
9595 'obsoletes' : 'that obsoleted' ,
9696 'is_obsoleted_by' : 'that was obsoleted by' ,
@@ -101,7 +101,7 @@ def update(request, ipr_id=None):
101101 }
102102
103103def set_related (obj , rel , target ):
104- print obj , rel , target
104+ # print obj, rel, target
105105 # remember only the first relationship we find.
106106 if not hasattr (obj , "related" ):
107107 obj .related = target
@@ -112,7 +112,7 @@ def set_relation(first, rel, second):
112112 set_related (second , inverse [rel ], first )
113113
114114def related_docs (doc , found = []):
115- print "\n related_docs(%s, %s)" % (doc , found )
115+ # print "\nrelated_docs(%s, %s)" % (doc, found)
116116 found .append (doc )
117117 if isinstance (doc , Rfc ):
118118 try :
@@ -136,9 +136,9 @@ def related_docs(doc, found = []):
136136 found = related_docs (item , found )
137137 if isinstance (doc , InternetDraft ):
138138 if doc .replaced_by_id :
139- item = doc .replaced_by_id
139+ item = doc .replaced_by
140140 if not item in found :
141- set_relation (doc , 'replaced_by ' , item )
141+ set_relation (doc , 'is_replaced_by ' , item )
142142 found = related_docs (item , found )
143143 for item in doc .replaces_set .all ():
144144 if not item in found :
@@ -165,32 +165,46 @@ def search(request, type="", q="", id=""):
165165 if type and q or id :
166166 log ("Got query: type=%s, q=%s, id=%s" % (type , q , id ))
167167 if type == "document_search" :
168- log ("Got document_search" )
169168 if q :
170169 start = InternetDraft .objects .filter (filename__contains = q )
171- log ("Found %s drafts containing %s" % (start .count (), q ))
172170 if id :
173171 start = InternetDraft .objects .filter (id_document_tag = id )
174- log ("Found %s drafts with id %s" % (start .count (), id ))
175- if start .count () == 1 :
176- first = start [0 ]
177- # get all related drafts, then search for IPRs on all
178- docs = related_docs (first , [])
179- iprs = []
180- for doc in docs :
181- if isinstance (doc , InternetDraft ):
182- disclosures = [ item .ipr for item in IprDraft .objects .filter (document = doc ) ]
183- elif isinstance (doc , Rfc ):
184- disclosures = [ item .ipr for item in IprRfc .objects .filter (document = doc ) ]
185- else :
186- raise ValueError ("Neither draft nor rfc: %s" % doc )
187- if disclosures :
188- doc .iprs = disclosures
189- iprs += disclosures
190- iprs = list (set (iprs ))
191- return render ("ipr/search_result.html" , {"first" : first , "iprs" : iprs , "docs" : docs })
192- elif start .count ():
193- return render ("ipr/search_list.html" , {"docs" : start })
172+ elif type == "rfc_search" :
173+ if q :
174+ start = Rfc .objects .filter (rfc_number = q )
175+ elif type == "patent_search" :
176+ pass
177+ elif type == "patent_info_search" :
178+ pass
179+ elif type == "wg_search" :
180+ pass
181+ elif type == "title_search" :
182+ pass
183+ elif type == "ip_title_search" :
184+ pass
185+ else :
186+ raise ValueError ("Unexpected search type in IPR query: %s" % type )
187+ if start .count () == 1 :
188+ first = start [0 ]
189+ # get all related drafts, then search for IPRs on all
190+ docs = related_docs (first , [])
191+ iprs = []
192+ for doc in docs :
193+ if isinstance (doc , InternetDraft ):
194+ disclosures = [ item .ipr for item in IprDraft .objects .filter (document = doc ) ]
195+ elif isinstance (doc , Rfc ):
196+ disclosures = [ item .ipr for item in IprRfc .objects .filter (document = doc ) ]
197+ else :
198+ raise ValueError ("Doc type is neither draft nor rfc: %s" % doc )
199+ if disclosures :
200+ doc .iprs = disclosures
201+ iprs += disclosures
202+ iprs = list (set (iprs ))
203+ return render ("ipr/search_result.html" , {"first" : first , "iprs" : iprs , "docs" : docs })
204+ elif start .count ():
205+ return render ("ipr/search_list.html" , {"docs" : start })
206+ else :
207+ raise ValueError ("Missing or malformed search parameters, or internal error" )
194208 return django .http .HttpResponseRedirect (request .path )
195209 return render ("ipr/search.html" , {"wgs" : wgs })
196210
0 commit comments