77from ietf .utils import log
88
99
10+ def mark_last_doc (iprs ):
11+ for item in iprs :
12+ if item .drafts .count ():
13+ item .last_draft = item .drafts .all ()[int (item .drafts .count ())- 1 ]
14+ if item .rfcs .count ():
15+ item .last_rfc = item .rfcs .all ()[int (item .rfcs .count ())- 1 ]
16+
17+ def mark_related_doc (iprs ):
18+ for item in iprs :
19+ print "*** Item:" , item
20+ for entry in item .drafts .all ():
21+ print " ** Entry:" , entry
22+ print " * Doc:" , entry .document
23+ related_docs (entry .document , [])
24+ print " Doc relation:" , entry .document .relation
25+ print " Doc related :" , entry .document .related
26+ for entry in item .rfcs .all ():
27+ print " ** Entry:" , entry
28+ print " * Doc:" , entry .document
29+ related_docs (entry .document , [])
30+ print " Doc relation:" , entry .document .relation
31+ print " Doc related :" , entry .document .related
32+
33+ def unique_iprs (iprs ):
34+ ids = []
35+ unique = []
36+ for ipr in iprs :
37+ if not ipr .ipr_id in ids :
38+ ids += [ ipr .ipr_id ]
39+ unique += [ ipr ]
40+ return unique
41+
42+ def iprs_from_docs (docs ):
43+ iprs = []
44+ for doc in docs :
45+ if isinstance (doc , InternetDraft ):
46+ disclosures = [ item .ipr for item in IprDraft .objects .filter (document = doc , ipr__status__in = [1 ,3 ]) ]
47+ elif isinstance (doc , Rfc ):
48+ disclosures = [ item .ipr for item in IprRfc .objects .filter (document = doc , ipr__status__in = [1 ,3 ]) ]
49+ else :
50+ raise ValueError ("Doc type is neither draft nor rfc: %s" % doc )
51+ if disclosures :
52+ doc .iprs = disclosures
53+ iprs += disclosures
54+ iprs = list (set (iprs ))
55+ return iprs
56+
1057def search (request , type = "" , q = "" , id = "" ):
1158 wgs = IETFWG .objects .filter (group_type__group_type_id = 1 ).exclude (group_acronym__acronym = '2000' ).select_related ().order_by ('acronym.acronym' )
1259 args = request .REQUEST .items ()
@@ -37,18 +84,7 @@ def search(request, type="", q="", id=""):
3784
3885 docs = related_docs (first , [])
3986 #docs = get_doclist.get_doclist(first)
40- iprs = []
41- for doc in docs :
42- if isinstance (doc , InternetDraft ):
43- disclosures = [ item .ipr for item in IprDraft .objects .filter (document = doc , ipr__status__in = [1 ,3 ]) ]
44- elif isinstance (doc , Rfc ):
45- disclosures = [ item .ipr for item in IprRfc .objects .filter (document = doc , ipr__status__in = [1 ,3 ]) ]
46- else :
47- raise ValueError ("Doc type is neither draft nor rfc: %s" % doc )
48- if disclosures :
49- doc .iprs = disclosures
50- iprs += disclosures
51- iprs = list (set (iprs ))
87+ iprs = iprs_from_docs (docs )
5288 return render ("ipr/search_doc_result.html" , {"q" : q , "first" : first , "iprs" : iprs , "docs" : docs })
5389 elif start .count ():
5490 return render ("ipr/search_doc_list.html" , {"q" : q , "docs" : start })
@@ -62,11 +98,7 @@ def search(request, type="", q="", id=""):
6298 iprs = [ ipr for ipr in iprs if not ipr .updated_by .all () ]
6399 # Some extra information, to help us render 'and' between the
64100 # 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 ]
101+ mark_last_doc (iprs )
70102 return render ("ipr/search_holder_result.html" , {"q" : q , "iprs" : iprs , "count" : count } )
71103
72104 # Search by content of email or pagent_info field
@@ -75,7 +107,18 @@ def search(request, type="", q="", id=""):
75107
76108 # Search by wg acronym
77109 elif type == "wg_search" :
78- pass
110+ try :
111+ docs = list (InternetDraft .objects .filter (group__acronym = q ))
112+ except :
113+ docs = []
114+ docs += [ draft .replaced_by for draft in docs if draft .replaced_by_id ]
115+ docs += list (Rfc .objects .filter (group_acronym = q ))
116+
117+ docs = [ doc for doc in docs if doc .ipr .count () ]
118+ iprs = iprs_from_docs (docs )
119+ count = len (iprs )
120+ #mark_last_doc(iprs)
121+ return render ("ipr/search_wg_result.html" , {"q" : q , "docs" : docs , "iprs" : iprs , "count" : count } )
79122
80123 # Search by rfc and id title
81124 elif type == "title_search" :
0 commit comments