Example #1
0
def email_screenplay():
    resource_id = request.form['resource_id']
    title_page = request.form['title_page']
    subject = request.form['subject']
    body_message = request.form['body_message']
    recipients = request.form['recipients'].split(',')

    # Build email body and html
    body = body_message + "\n\n\n    	"
    body += "--- This screenplay written and sent from RawScripts.com."
    body += " Check it out---"
    with app.open_resource('static/text/email.txt') as f:
        html_template = f.read()
    html = html_template.replace("FILLERTEXT", body_message)

    # get pdf file to attach
    include_title_page = title_page == '1'
    export_file = Screenplay.export_to_file(resource_id, 'pdf', include_title_page)
    _file, title, content_type = export_file
    filename = title + '.pdf'

    msg = Message(subject, recipients=recipients, body=body, html=html)
    msg.attach(filename, content_type, _file.getvalue())
    mail.send(msg)

    return Response('sent', mimetype='text/plain')
def email_screenplay():
    resource_id = get_resource_id_from_request()
    title_page = request.form.get('title_page', None)
    if title_page is None:
        title_page = request.json.get('title_page', None)
    subject = "Screenplay"
    body_message = ""
    raw_recipients = request.form.get('recipients', None)
    if raw_recipients is None:
        raw_recipients = request.json.get('recipients', None)
    recipients = raw_recipients.split(',')

    # Build email body and html
    body = body_message + "\n\n\n    	"
    body += "--- This screenplay written and sent from RawScripts.com."
    body += " Check it out---"
    with app.open_resource('static/text/email.txt') as f:
        html_template = f.read()
    html = html_template.replace("FILLERTEXT", body_message)

    # get pdf file to attach
    include_title_page = title_page == '1'
    export_file = Screenplay.export_to_file(resource_id, 'pdf',
                                            include_title_page)
    _file, title, content_type = export_file
    filename = title + '.pdf'

    msg = Message(subject, recipients=recipients, body=body, html=html)
    msg.attach(filename, content_type, _file.getvalue())
    try:
        mail.send(msg)
    except:
        return Response('failed', mimetype='text/plain')
    return Response('sent', mimetype='text/plain')
def email_screenplay():
    resource_id = get_resource_id_from_request()
    title_page = request.form.get('title_page', None)
    if title_page is None:
        title_page = request.json.get('title_page', None)
    subject = "Screenplay"
    body_message = ""
    raw_recipients = request.form.get('recipients', None)
    if raw_recipients is None:
        raw_recipients = request.json.get('recipients', None)
    print request.json
    recipients = raw_recipients.split(',')

    # Build email body and html
    body = body_message + "\n\n\n    	"
    body += "--- This screenplay written and sent from RawScripts.com."
    body += " Check it out---"
    with app.open_resource('static/text/email.txt') as f:
        html_template = f.read()
    html = html_template.replace("FILLERTEXT", body_message)

    # get pdf file to attach
    include_title_page = title_page == '1'
    export_file = Screenplay.export_to_file(resource_id, 'pdf', include_title_page)
    _file, title, content_type = export_file
    filename = title + '.pdf'

    msg = Message(subject, recipients=recipients, body=body, html=html)
    msg.attach(filename, content_type, _file.getvalue())
    try:
        mail.send(msg)
    except:
        return Response('failed', mimetype='text/plain')
    return Response('sent', mimetype='text/plain')
def export_screenplay():
    user = current_user.name
    resource_id = request.args.get('resource_id')
    export_format = request.args.get('export_format')
    title_page = request.args.get('title_page', '0')
    if resource_id == 'Demo':
        return
    permission = UsersScripts.get_users_permission(resource_id, user)
    if permission not in ['owner', 'collab']:
        return

    include_title_page = title_page == '1'
    export_file = Screenplay.export_to_file(resource_id, export_format, include_title_page)
    _file, title, content_type = export_file
    response = make_response(_file.getvalue())
    response.headers['Content-Type'] = content_type
    response.headers['Content-Disposition'] = \
        'attachment; filename={}.{}'.format(title, export_format)
    return response
Example #5
0
def export_screenplay():
    user = current_user.name
    resource_id = request.args.get('resource_id')
    export_format = request.args.get('export_format')
    title_page = request.args.get('title_page', '0')
    if resource_id == 'Demo':
        return
    permission = Screenplay.get_users_permission(resource_id, user)
    if permission not in ['owner', 'collab']:
        return

    include_title_page = title_page == '1'
    export_file = Screenplay.export_to_file(resource_id, export_format,
                                            include_title_page)
    _file, title, content_type = export_file
    response = make_response(_file.getvalue())
    response.headers['Content-Type'] = content_type
    response.headers['Content-Disposition'] = \
        'attachment; filename="{}.{}"'.format(title, export_format)
    return response