Commit 6f3696ff authored by Vermaat's avatar Vermaat
Browse files

Proof-of-concept PDF download for namechecker.

git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/branches/namechecker-pdf-branch@302 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1
parent fe3d873b
......@@ -51,7 +51,7 @@
</div> <!-- form area -->
<br>
<div tal:condition = "lastpost">
<h3>Name checker results:</h3>
<h3>Name checker results: <span class="pdf" tal:condition = "not:release">(<a tal:attributes = "href string:?pdf=1&amp;mutationName=${lastpost}">as PDF</a>)</span></h3>
<div class="messages">
<p tal:repeat = "m messages" tal:content = "m/description"
tal:attributes = "class m/class; title string:${m/level} (origin: ${m/origin})"></p>
......
......@@ -618,16 +618,18 @@ class Check:
- mutationName: Variant to check.
"""
interactive = True
i = web.input(mutationName=None)
pdf = False
i = web.input(mutationName=None, pdf=None)
if i.mutationName:
# Run checker non-interactively
interactive = False
pdf = bool(i.pdf)
variant = i.mutationName
else:
# Run checker if cookie variant is not None
variant = web.cookies().get('variant')
web.setcookie('variant', '', 60)
return self.check(variant, interactive=interactive)
return self.check(variant, interactive=interactive, pdf=pdf)
def POST(self):
"""
......@@ -640,7 +642,7 @@ class Check:
return self.check(i.mutationName)
@staticmethod
def check(name=None, interactive=True):
def check(name=None, interactive=True, pdf=False):
"""
Render the variant checker HTML form. If the name argument is given,
run the name checker.
......@@ -715,7 +717,22 @@ class Check:
'reference' : reference
}
return render.check(args, standalone=not interactive)
if pdf:
# Todo: Implement PDF formatting of results. Probably using
# ReportLab Platypus.
# https://github.com/nbv4/flightloggin/blob/master/pdf/pdf.py
from reportlab.platypus import SimpleDocTemplate, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
web.header('Content-Type', 'application/pdf')
web.header('Content-Disposition', 'attachment; filename=mutalyzer.pdf')
io = StringIO()
doc = SimpleDocTemplate(io)
style = getSampleStyleSheet()['Normal']
doc.build([Paragraph('Proof of concept for variant %s.' % name, style)])
return io.getvalue()
else:
return render.check(args, standalone=not interactive)
#Check
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment