Skip to content

Commit 216ed80

Browse files
committed
Merged in code from rcross@amsl.com to bring back the automatic conversion of slides from powerpoint to pdf.
- Legacy-Id: 12379
1 parent 4d59b4d commit 216ed80

3 files changed

Lines changed: 36 additions & 36 deletions

File tree

ietf/meeting/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
from ietf.meeting.helpers import send_interim_announcement_request
5959
from ietf.meeting.utils import finalize
6060
from ietf.secr.proceedings.utils import handle_upload_file
61-
from ietf.secr.proceedings.proc_utils import get_progress_stats
61+
from ietf.secr.proceedings.proc_utils import get_progress_stats, post_process
6262
from ietf.utils.mail import send_mail_message
6363
from ietf.utils.pipe import pipe
6464
from ietf.utils.pdf import pdf_pages
@@ -1499,6 +1499,7 @@ def upload_session_slides(request, session_id, num, name):
14991499
doc.save_with_history([e])
15001500
# The way this function builds the filename it will never trigger the file delete in handle_file_upload.
15011501
handle_upload_file(file, filename, session.meeting, 'slides')
1502+
post_process(doc)
15021503
return redirect('ietf.meeting.views.session_details',num=num,acronym=session.group.acronym)
15031504
else:
15041505
initial = {}

ietf/secr/proceedings/proc_utils.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import glob
99
import os
1010
import shutil
11+
import subprocess
1112

1213
import debug # pyflakes:ignore
1314

@@ -27,7 +28,7 @@
2728
from ietf.secr.utils.document import get_rfc_num
2829
from ietf.secr.utils.group import groups_by_session
2930
from ietf.secr.utils.meeting import get_proceedings_path, get_materials, get_session
30-
31+
from ietf.utils.log import log
3132

3233
# -------------------------------------------------
3334
# Helper Functions
@@ -574,3 +575,34 @@ def gen_training(context):
574575
path = os.path.join(settings.SECR_PROCEEDINGS_DIR,meeting.number,'train-%s.html' % counter )
575576
write_html(path,html.content)
576577

578+
def is_powerpoint(doc):
579+
'''
580+
Returns true if document is a Powerpoint presentation
581+
'''
582+
return doc.file_extension() in ('ppt','pptx')
583+
584+
def post_process(doc):
585+
'''
586+
Does post processing on uploaded file.
587+
- Convert PPT to PDF
588+
'''
589+
if is_powerpoint(doc) and hasattr(settings,'SECR_PPT2PDF_COMMAND'):
590+
try:
591+
cmd = settings.SECR_PPT2PDF_COMMAND
592+
cmd.append(doc.get_file_path()) # outdir
593+
cmd.append(os.path.join(doc.get_file_path(),doc.external_url)) # filename
594+
subprocess.check_call(cmd)
595+
except (subprocess.CalledProcessError, OSError) as error:
596+
log("Error converting PPT: %s" % (error))
597+
return
598+
# change extension
599+
base,ext = os.path.splitext(doc.external_url)
600+
doc.external_url = base + '.pdf'
601+
602+
e = DocEvent.objects.create(
603+
type='changed_document',
604+
by=Person.objects.get(name="(System)"),
605+
doc=doc,
606+
desc='Converted document to PDF',
607+
)
608+
doc.save_with_history([e])

ietf/secr/proceedings/views.py

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import glob
33
import itertools
44
import os
5-
import subprocess
65

76
import debug # pyflakes:ignore
87

@@ -27,7 +26,6 @@
2726
from ietf.secr.proceedings.proc_utils import ( gen_acknowledgement, gen_agenda, gen_areas,
2827
gen_attendees, gen_group_pages, gen_index, gen_irtf, gen_overview, gen_plenaries,
2928
gen_progress, gen_research, gen_training, create_proceedings, create_recording )
30-
from ietf.utils.log import log
3129

3230
# -------------------------------------------------
3331
# Globals
@@ -139,39 +137,8 @@ def parsedate(d):
139137
This function takes a date object and returns a tuple of year,month,day
140138
'''
141139
return (d.strftime('%Y'),d.strftime('%m'),d.strftime('%d'))
142-
143-
def is_powerpoint(doc):
144-
'''
145-
Returns true if document is a Powerpoint presentation
146-
'''
147-
return doc.file_extension() in ('ppt','pptx')
148-
149-
def post_process(doc):
150-
'''
151-
Does post processing on uploaded file.
152-
- Convert PPT to PDF
153-
'''
154-
if is_powerpoint(doc) and hasattr(settings,'SECR_PPT2PDF_COMMAND'):
155-
try:
156-
cmd = settings.SECR_PPT2PDF_COMMAND
157-
cmd.append(doc.get_file_path()) # outdir
158-
cmd.append(os.path.join(doc.get_file_path(),doc.external_url)) # filename
159-
subprocess.check_call(cmd)
160-
except (subprocess.CalledProcessError, OSError) as error:
161-
log("Error converting PPT: %s" % (error))
162-
return
163-
# change extension
164-
base,ext = os.path.splitext(doc.external_url)
165-
doc.external_url = base + '.pdf'
166-
167-
e = DocEvent.objects.create(
168-
type='changed_document',
169-
by=Person.objects.get(name="(System)"),
170-
doc=doc,
171-
desc='Converted document to PDF',
172-
)
173-
doc.save_with_history([e])
174140

141+
175142
# -------------------------------------------------
176143
# AJAX Functions
177144
# -------------------------------------------------

0 commit comments

Comments
 (0)