3535from django .http import HttpResponse , HttpResponsePermanentRedirect
3636from django .template import loader
3737from django .shortcuts import get_object_or_404
38- from ietf .idtracker .models import Acronym , IETFWG , InternetDraft , IDInternal
38+ from ietf .idtracker .models import Acronym , IETFWG , InternetDraft , IDInternal ,PersonOrOrgInfo
39+ from ietf .idtracker .templatetags .ietf_filters import clean_whitespace
40+ import re
3941
4042def all_id_txt ():
4143 all_ids = InternetDraft .objects .order_by ('filename' )
@@ -58,6 +60,81 @@ def all_id_txt():
5860 'withdrawn_ietf' :withdrawn_ietf ,
5961 'replaced' :replaced })
6062
63+ def all_id2_entry (id ):
64+ fields = []
65+ # 0
66+ fields .append (id .filename + "-" + id .revision_display ())
67+ # 1
68+ fields .append (id .id_document_tag )
69+ # 2
70+ status = id .status .status
71+ fields .append (status )
72+ # 3
73+ iesgstate = id .idstate () if status == "Active" else ""
74+ fields .append (iesgstate )
75+ # 4
76+ fields .append (id .rfc_number if status == "RFC" else "" )
77+ # 5
78+ if status == "Replaced" :
79+ try :
80+ fields .append (id .replaced_by .filename )
81+ except InternetDraft .DoesNotExist :
82+ fields .append ("" )
83+ else :
84+ fields .append ("" )
85+ # 6
86+ fields .append (id .revision_date )
87+ # 7
88+ group_acronym = id .group .acronym
89+ if group_acronym == "none" :
90+ group_acronym = ""
91+ fields .append (group_acronym )
92+
93+ # 8
94+ area = ""
95+ if id .idinternal :
96+ area = id .idinternal .area_acronym
97+ elif not group_acronym :
98+ pass
99+ else :
100+ wgs = id .group .ietfwg_set .all ()
101+ if len (wgs ) > 0 :
102+ area = wgs [0 ].area_acronym () or ""
103+ fields .append (area )
104+ # 9
105+ fields .append (id .idinternal .job_owner if id .idinternal else "" )
106+ # 10
107+ if id .intended_status and id .intended_status .intended_status not in ("None" ,"Request" ):
108+ fields .append (id .intended_status .intended_status )
109+ else :
110+ fields .append ("" )
111+ # 11
112+ if (iesgstate == "In Last Call" ) or iesgstate .startswith ("In Last Call::" ):
113+ fields .append (id .lc_expiration_date )
114+ else :
115+ fields .append ("" )
116+ # 12
117+ fields .append (id .file_type if status == "Active" else "" )
118+ # 13
119+ fields .append (clean_whitespace (id .title ))
120+ # 14
121+ authors = []
122+ for author in sorted (id .authors .all (), key = lambda x : x .final_author_order ()):
123+ try :
124+ realname = unicode (author .person )
125+ email = author .email () or ""
126+ name = re .sub (u"[<>@,]" , u"" , realname ) + u" <" + re .sub (u"[<>,]" , u"" , email ).strip ()+ u">"
127+ authors .append (clean_whitespace (name ))
128+ except PersonOrOrgInfo .DoesNotExist :
129+ pass
130+ fields .append (u", " .join (authors ))
131+ return "\t " .join ([unicode (x ) for x in fields ])
132+
133+ def all_id2_txt ():
134+ all_ids = InternetDraft .objects .order_by ('filename' ).select_related ('status__status' ,'group__acronym' ,'intended_status__intended_status' )
135+ data = "\n " .join ([all_id2_entry (id ) for id in all_ids ])
136+ return loader .render_to_string ("idindex/all_id2.txt" ,{'data' :data })
137+
61138def id_index_txt ():
62139 groups = IETFWG .objects .all ()
63140 return loader .render_to_string ("idindex/id_index.txt" , {'groups' :groups })
@@ -68,6 +145,8 @@ def id_abstracts_txt():
68145
69146def test_all_id_txt (request ):
70147 return HttpResponse (all_id_txt (), mimetype = 'text/plain' )
148+ def test_all_id2_txt (request ):
149+ return HttpResponse (all_id2_txt (), mimetype = 'text/plain' )
71150def test_id_index_txt (request ):
72151 return HttpResponse (id_index_txt (), mimetype = 'text/plain' )
73152def test_id_abstracts_txt (request ):
0 commit comments