Merge branch 'ppt-gdrive' of https://github.com/FinalsClub/karmaworld into ppt-gdrive
authorSeth Woodworth <seth@sethish.com>
Wed, 26 Jun 2013 20:35:10 +0000 (20:35 +0000)
committerSeth Woodworth <seth@sethish.com>
Wed, 26 Jun 2013 20:35:10 +0000 (20:35 +0000)
Conflicts:
karmaworld/apps/notes/gdrive.py

1  2 
karmaworld/apps/notes/gdrive.py

index 120720132bb3cc2fea5d399d342d74e03b148d22,437300cd0717bf48905fee20130abf347fdf17f1..d7bacb9dbdf1fdccf65ab23016948c5080f317a9
@@@ -169,16 -161,25 +170,31 @@@ def convert_with_google_drive(note)
      if extension.lower() == '.pdf':
          new_note.file_type = 'pdf'
  
+     elif extension.lower() in ['.ppt', '.pptx']:
+         print "try to save ppt"
+         now = datetime.datetime.utcnow()
+         # create a folder path to store the ppt > pdf file with year and month folders
+         _path = os.path.join(settings.MEDIA_ROOT, 'ppt_pdf/%s/%s' % (now.year, now.month), filename)
+         try:
+             # If those folders don't exist, create them
+             os.makedirs(os.path.realpath(os.path.dirname(_path)))
+         _writer = BufferedWriter(FileIO(_path, "w"))
+         _writer.write(content_dict['pdf'])
+         _writer.close()
+         new_note.pdf_file = os.path.join(_path, filename)
  
      # set the .odt as the download from google link
 -    new_note.gdrive_url = file_dict[u'exportLinks']['application/vnd.oasis.opendocument.text']
 -    new_note.html = content_dict['html']
 +    if extension.lower() in ['.ppt', '.pptx']:
 +        print "is ppt"
 +        new_note.pdf_file = File(content_dict['pdf'])
 +    else:
 +        # PPT files do not have this export ability
 +        new_note.gdrive_url = file_dict[u'exportLinks']['application/vnd.oasis.opendocument.text']
 +        new_note.html = content_dict['html']
 +
      new_note.text = content_dict['text']
  
      # before we save new html, sanitize a tags in note.html