Skip to content

Commit 16959bd

Browse files
Merged from trunk until version 2631
- Legacy-Id: 2635
1 parent f7b1047 commit 16959bd

34 files changed

Lines changed: 741 additions & 206 deletions

suresh/ietf/idrfc/idrfc_wrapper.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
from ietf.idtracker.models import InternetDraft, IDInternal, BallotInfo, IESGDiscuss, IESGLogin, DocumentComment, Acronym
3434
from ietf.idrfc.models import RfcEditorQueue
35+
from ietf.ipr.models import IprRfc, IprDraft, IprDetail
36+
3537
import re
3638
from datetime import date
3739
from django.utils import simplejson as json
@@ -498,11 +500,23 @@ def state_change_notice_to(self):
498500
class IdRfcWrapper:
499501
rfc = None
500502
id = None
503+
iprCount = None
504+
iprUrl = None
501505

502506
def __init__(self, id, rfc):
503507
self.id = id
504508
self.rfc = rfc
505-
509+
if id:
510+
iprs = IprDraft.objects.filter(document=self.id.tracker_id)
511+
self.iprUrl = "../../ipr/search?option=document_search&id_document_tag=" + str(self.id.tracker_id)
512+
elif rfc:
513+
iprs = IprRfc.objects.filter(rfc_number=self.rfc.rfc_number)
514+
self.iprUrl = "../../ipr/search?option=rfc_search&rfc_search=" + str(elf.rfc.rfc_number)
515+
else:
516+
raise ValueError("Construction with null id and rfc")
517+
# iprs is a list of docs which contain IPR
518+
self.iprCount = len(iprs)
519+
506520
def title(self):
507521
if self.rfc:
508522
return self.rfc.title

suresh/ietf/idrfc/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
(r'^active/$', views_search.active),
4141
url(r'^ad/(?P<name>[^/]+)/$', views_search.by_ad, name="doc_search_by_ad"),
4242

43-
url(r'^(?P<name>[^/]+)/$', views_doc.document_main, name="doc_view"),
43+
url(r'^(?P<name>[^/]+)/((?P<tab>ballot|writeup|history)/)?$', views_doc.document_main, name="doc_view"),
4444
(r'^(?P<name>[^/]+)/doc.json$', views_doc.document_debug),
4545
(r'^(?P<name>[^/]+)/_ballot.data$', views_doc.document_ballot),
4646
(r'^(?P<name>[^/]+)/ballot.tsv$', views_doc.ballot_tsv),

suresh/ietf/idrfc/views_ballot.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,13 @@ def send_ballot_comment(request, name):
228228
c = comment.text
229229
subj.append("COMMENT")
230230

231-
subject = "%s: %s" % (" and ".join(subj), doc.file_tag())
231+
ad_name = str(ad)
232+
ad_name_genitive = ad_name + "'" if ad_name.endswith('s') else ad_name + "'s"
233+
subject = "%s %s on %s" % (ad_name_genitive, " and ".join(subj), doc.filename + '-' + doc.revision_display())
232234
body = render_to_string("idrfc/ballot_comment_mail.txt",
233-
dict(discuss=d, comment=c))
235+
dict(discuss=d, comment=c, ad=ad, doc=doc))
234236
frm = u"%s <%s>" % ad.person.email()
235-
to = "iesg@ietf.org"
237+
to = "The IESG <iesg@ietf.org>"
236238

237239
if request.method == 'POST':
238240
cc = [x.strip() for x in request.POST.get("cc", "").split(',') if x.strip()]
@@ -632,7 +634,7 @@ def make_last_call(request, name):
632634
announcement += "\n".join(links)
633635
else:
634636
announcement += "\n\n"
635-
announcement += "No IPR declarations were found that appear related to this I-D."
637+
announcement += "No IPR declarations have been submitted directly on this I-D."
636638

637639
if request.method == 'POST':
638640
form = MakeLastCallForm(request.POST)

suresh/ietf/idrfc/views_doc.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _get_html(key, filename):
7474
(c1,c2) = markup_txt.markup(raw_content)
7575
return (c1,c2)
7676

77-
def document_main_rfc(request, rfc_number):
77+
def document_main_rfc(request, rfc_number, tab):
7878
rfci = get_object_or_404(RfcIndex, rfc_number=rfc_number)
7979
doc = RfcWrapper(rfci)
8080

@@ -93,18 +93,24 @@ def document_main_rfc(request, rfc_number):
9393

9494
history = _get_history(doc, None)
9595

96-
return render_to_response('idrfc/doc_main_rfc.html',
96+
template = "idrfc/doc_tab_%s" % tab
97+
if tab == "document":
98+
template += "_rfc"
99+
return render_to_response(template + ".html",
97100
{'content1':content1, 'content2':content2,
98-
'doc':doc, 'info':info,
101+
'doc':doc, 'info':info, 'tab':tab,
102+
'include_text':request.GET.get( 'include_text' ),
99103
'history':history},
100104
context_instance=RequestContext(request));
101105

102106
@decorator_from_middleware(GZipMiddleware)
103-
def document_main(request, name):
107+
def document_main(request, name, tab):
108+
if tab is None:
109+
tab = "document"
104110
r = re.compile("^rfc([1-9][0-9]*)$")
105111
m = r.match(name)
106112
if m:
107-
return document_main_rfc(request, int(m.group(1)))
113+
return document_main_rfc(request, int(m.group(1)), tab)
108114
id = get_object_or_404(InternetDraft, filename=name)
109115
doc = IdWrapper(id)
110116

@@ -138,9 +144,13 @@ def document_main(request, name):
138144
versions = _get_versions(id)
139145
history = _get_history(doc, versions)
140146

141-
return render_to_response('idrfc/doc_main_id.html',
147+
template = "idrfc/doc_tab_%s" % tab
148+
if tab == "document":
149+
template += "_id"
150+
return render_to_response(template + ".html",
142151
{'content1':content1, 'content2':content2,
143-
'doc':doc, 'info':info,
152+
'doc':doc, 'info':info, 'tab':tab,
153+
'include_text':request.GET.get( 'include_text' ),
144154
'versions':versions, 'history':history},
145155
context_instance=RequestContext(request));
146156

suresh/ietf/idtracker/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ def save(self):
178178
def displayname(self):
179179
return self.filename
180180
def file_tag(self):
181-
return "<%s-%s.txt>" % (self.filename, self.revision_display())
181+
return "<%s>" % (self.filename_with_rev())
182+
def filename_with_rev(self):
183+
return "%s-%s.txt" % (self.filename, self.revision_display())
182184
def group_acronym(self):
183185
return self.group.acronym
184186
def group_ml_archive(self):

suresh/ietf/meeting/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
(r'^agenda.txt$', views.text_agenda),
1111
(r'^(?P<num>\d+)/agenda(?:.html)?/?$', views.html_agenda),
1212
(r'^(?P<num>\d+)/agenda.txt$', views.text_agenda),
13+
(r'^(?P<num>\d+)/agenda/(?P<session>[A-Za-z0-9-]+)-drafts.pdf$', views.session_draft_pdf),
14+
(r'^(?P<num>\d+)/agenda/(?P<session>[A-Za-z0-9-]+)-drafts.tgz$', views.session_draft_tarfile),
1315
(r'^(?P<num>\d+)/agenda/(?P<session>[A-Za-z0-9-]+)(?P<ext>\.[A-Za-z0-9]+)?$', views.session_agenda),
1416
(r'^$', views.current_materials),
1517
)

suresh/ietf/meeting/views.py

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#import models
55
import datetime
66
import os
7+
import re
8+
import tarfile
9+
10+
from tempfile import mkstemp
711

812
from django.shortcuts import render_to_response, get_object_or_404
913
from ietf.idtracker.models import IETFWG, IRTF, Area
@@ -17,6 +21,9 @@
1721
from django.utils.decorators import decorator_from_middleware
1822
from django.middleware.gzip import GZipMiddleware
1923
from django.db.models import Count
24+
from ietf.idtracker.models import InternetDraft
25+
from ietf.idrfc.idrfc_wrapper import IdWrapper
26+
from ietf.utils.pipe import pipe
2027

2128
from ietf.proceedings.models import Meeting, MeetingTime, WgMeetingSession, MeetingVenue, IESGHistory, Proceeding, Switches, WgProceedingsActivities
2229

@@ -148,3 +155,154 @@ def session_agenda(request, num, session, ext=None):
148155
raise Http404("No %s agenda for the %s session of IETF %s is available" % (ext, session, num))
149156
else:
150157
raise Http404("No agenda for the %s session of IETF %s is available" % (session, num))
158+
159+
def convert_to_pdf(doc_name):
160+
import subprocess
161+
inpath = os.path.join(settings.INTERNET_DRAFT_PATH, doc_name + ".txt")
162+
outpath = os.path.join(settings.INTERNET_DRAFT_PDF_PATH, doc_name + ".pdf")
163+
164+
try:
165+
infile = open(inpath, "r")
166+
except Exception, e:
167+
return
168+
169+
t,tempname = mkstemp()
170+
tempfile = open(tempname, "w")
171+
172+
pageend = 0;
173+
newpage = 0;
174+
formfeed = 0;
175+
for line in infile:
176+
line = re.sub("\r","",line)
177+
line = re.sub("[ \t]+$","",line)
178+
if re.search("\[?[Pp]age [0-9ivx]+\]?[ \t]*$",line):
179+
pageend=1
180+
tempfile.write(line)
181+
continue
182+
if re.search("^[ \t]*\f",line):
183+
formfeed=1
184+
tempfile.write(line)
185+
continue
186+
if re.search("^ *INTERNET.DRAFT.+[0-9]+ *$",line) or re.search("^ *Internet.Draft.+[0-9]+ *$",line) or re.search("^draft-[-a-z0-9_.]+.*[0-9][0-9][0-9][0-9]$",line) or re.search("^RFC.+[0-9]+$",line):
187+
newpage=1
188+
if re.search("^[ \t]*$",line) and pageend and not newpage:
189+
continue
190+
if pageend and newpage and not formfeed:
191+
tempfile.write("\f")
192+
pageend=0
193+
formfeed=0
194+
newpage=0
195+
tempfile.write(line)
196+
197+
infile.close()
198+
tempfile.close()
199+
t,psname = mkstemp()
200+
pipe("enscript --margins 76::76: -B -q -p "+psname + " " +tempname)
201+
os.unlink(tempname)
202+
pipe("ps2pdf "+psname+" "+outpath)
203+
os.unlink(psname)
204+
205+
206+
def session_draft_list(num, session):
207+
extensions = ["html", "htm", "txt", "HTML", "HTM", "TXT", ]
208+
result = []
209+
found = False
210+
for wg in [session, session.upper(), session.lower()]:
211+
for e in extensions:
212+
path = settings.AGENDA_PATH_PATTERN % {"meeting":num, "wg":wg, "ext":e}
213+
if os.path.exists(path):
214+
file = open(path)
215+
agenda = file.read()
216+
file.close()
217+
found = True
218+
break
219+
if found:
220+
break
221+
else:
222+
raise Http404("No agenda for the %s session of IETF %s is available" % (session, num))
223+
224+
drafts = set(re.findall('(draft-[-a-z0-9]*)',agenda))
225+
226+
for draft in drafts:
227+
if (re.search('-[0-9]{2}$',draft)):
228+
doc_name = draft
229+
else:
230+
id = get_object_or_404(InternetDraft, filename=draft)
231+
doc = IdWrapper(id)
232+
doc_name = draft + "-" + id.revision
233+
result.append(doc_name)
234+
235+
return sorted(list(set(result)))
236+
237+
238+
def session_draft_tarfile(request, num, session):
239+
drafts = session_draft_list(num, session);
240+
241+
response = HttpResponse(mimetype='application/octet-stream')
242+
response['Content-Disposition'] = 'attachment; filename=%s-drafts.tgz'%(session)
243+
tarstream = tarfile.open('','w:gz',response)
244+
mfh, mfn = mkstemp()
245+
manifest = open(mfn, "w")
246+
247+
for doc_name in drafts:
248+
pdf_path = os.path.join(settings.INTERNET_DRAFT_PDF_PATH, doc_name + ".pdf")
249+
250+
if (not os.path.exists(pdf_path)):
251+
convert_to_pdf(doc_name)
252+
253+
if os.path.exists(pdf_path):
254+
try:
255+
tarstream.add(pdf_path, str(doc_name + ".pdf"))
256+
manifest.write("Included: "+pdf_path+"\n")
257+
except Exception, e:
258+
manifest.write(("Failed (%s): "%e)+pdf_path+"\n")
259+
else:
260+
manifest.write("Not found: "+pdf_path+"\n")
261+
262+
manifest.close()
263+
tarstream.add(mfn, "manifest.txt")
264+
tarstream.close()
265+
os.unlink(mfn)
266+
return response
267+
268+
def pdf_pages(file):
269+
try:
270+
infile = open(file, "r")
271+
except Exception, e:
272+
return 0
273+
for line in infile:
274+
m = re.match('\] /Count ([0-9]+)',line)
275+
if m:
276+
return int(m.group(1))
277+
return 0
278+
279+
280+
def session_draft_pdf(request, num, session):
281+
drafts = session_draft_list(num, session);
282+
curr_page = 1
283+
pmh, pmn = mkstemp()
284+
pdfmarks = open(pmn, "w")
285+
pdf_list = ""
286+
287+
for draft in drafts:
288+
pdf_path = os.path.join(settings.INTERNET_DRAFT_PDF_PATH, draft + ".pdf")
289+
if (not os.path.exists(pdf_path)):
290+
convert_to_pdf(draft)
291+
292+
if (os.path.exists(pdf_path)):
293+
pages = pdf_pages(pdf_path)
294+
pdfmarks.write("[/Page "+str(curr_page)+" /View [/XYZ 0 792 1.0] /Title (" + draft + ") /OUT pdfmark\n")
295+
pdf_list = pdf_list + " " + pdf_path
296+
curr_page = curr_page + pages
297+
298+
pdfmarks.close()
299+
pdfh, pdfn = mkstemp()
300+
pipe("gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" + pdfn + " " + pdf_list + " " + pmn)
301+
302+
pdf = open(pdfn,"r")
303+
pdf_contents = pdf.read()
304+
pdf.close()
305+
306+
os.unlink(pmn)
307+
os.unlink(pdfn)
308+
return HttpResponse(pdf_contents, mimetype="application/pdf")

suresh/ietf/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
'django.contrib.sites',
117117
'django.contrib.sitemaps',
118118
'django.contrib.admin',
119+
'django.contrib.admindocs',
119120
'django.contrib.humanize',
120121
'south',
121122
'ietf.announcements',
@@ -157,6 +158,7 @@
157158
# Override this in settings_local.py if needed
158159
# *_PATH variables ends with a slash/ .
159160
INTERNET_DRAFT_PATH = '/a/www/ietf-ftp/internet-drafts/'
161+
INTERNET_DRAFT_PDF_PATH = '/a/www/ietf-datatracker/pdf/'
160162
RFC_PATH = '/a/www/ietf-ftp/rfc/'
161163
AGENDA_PATH = '/a/www/www6s/proceedings/'
162164
AGENDA_PATH_PATTERN = '/a/www/www6s/proceedings/%(meeting)s/agenda/%(wg)s.%(ext)s'

suresh/ietf/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<div id="ietf-login" class="noprint">{% if user.is_authenticated %}
6464
{{ user }}
6565
{% else %}
66-
<a href="/accounts/login/?next={{request.path|urlencode}}" rel="nofollow">Sign In</a>
66+
<a href="/accounts/login/?next={{request.get_full_path|urlencode}}" rel="nofollow">Sign In</a>
6767
{% endif %}</div>
6868

6969
<table style="margin-left:8px;margin-top:8px;" width="98%;">

suresh/ietf/templates/base_leftmenu.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
<li class="sect">Drafts&nbsp;&amp;&nbsp;RFCs</li>
6565
<li><a href="/doc/">Search</a></li>
66-
<li><form action="/doc/search/" method="post" style="padding-bottom:0;margin-bottom:0;"><input type="text" style="margin-left:10px; width:100px; border:1px solid #89d;" name="name" /><input type="hidden" name="activeDrafts" value="on"/><input type="hidden" name="rfcs" value="on"/></form></li>
66+
<li><form action="/doc/search/" method="get" style="padding-bottom:0;margin-bottom:0;"><input type="text" style="margin-left:10px; width:100px; border:1px solid #89d;" name="name" /><input type="hidden" name="activeDrafts" value="on"/><input type="hidden" name="rfcs" value="on"/></form></li>
6767
<li><a href="https://datatracker.ietf.org/idst/upload.cgi">Submit a draft</a></li>
6868

6969

0 commit comments

Comments
 (0)