def share_screenplay(): resource_id = request.form['resource_id'] collaborators = request.form['collaborators'].split(',') new_collaborators = Screenplay.add_access(resource_id, collaborators) if new_collaborators and request.form.get('sendEmail', '') == 'y': user = current_user.email subject = 'Rawscripts.com: ' + user + " has shared a screenplay with you." title = Screenplay.get_title(resource_id) # build email body and html script_url = url_for('editor', _external=True, resource_id=resource_id) body = script_url + "\n\n\n " body += "--- This screenplay written and sent from RawScripts.com." divArea = '' if request.form.get('addMsg', '') == 'y': divArea = "<div style='width:300px; margin-left:20px; font-size:12pt; font-family:serif'>" divArea += request.form.get('msg', '') divArea += "<br><b>--" + user + "</b></div>" replacements = { 'SCRIPTTITLE': title, 'USER': user, 'SCRIPTURL': script_url, 'TEXTAREA': divArea} with app.open_resource('static/text/notify.txt') as f: html = f.read() for key, val in replacements.items(): html = html.replace(key, val) msg = Message(subject, recipients=new_collaborators, body=body, html=html) mail.send(msg) # TODO: send the danged email output = ",".join(new_collaborators) return Response(output, mimetype='text/plain')
def share_screenplay(): resource_id = get_resource_id_from_request() collaborators_raw = request.form.get('collaborators', None) if collaborators_raw is None: collaborators_raw = request.json.get('collaborators', None) collaborators = collaborators_raw.split(',') new_collaborators = Screenplay.add_access(resource_id, collaborators) if new_collaborators and request.json.get('sendEmail', '') == 'y': user = current_user.email subject = 'Rawscripts.com: ' + user + " has shared a screenplay with you." title = Screenplay.get_title(resource_id) # build email body and html script_url = url_for('editor', _external=True, resource_id=resource_id) body = script_url + "\n\n\n " body += "--- This screenplay written and sent from RawScripts.com." divArea = '' replacements = { 'SCRIPTTITLE': title, 'USER': user, 'SCRIPTURL': script_url, 'TEXTAREA': divArea} with app.open_resource('static/text/notify.txt') as f: html = f.read() for key, val in replacements.items(): html = html.replace(key, val) msg = Message(subject, recipients=new_collaborators, body=body, html=html) mail.send(msg) # TODO: send the danged email output = ",".join(new_collaborators) return Response(output, mimetype='text/plain')
def share_screenplay(): resource_id = get_resource_id_from_request() collaborators_raw = request.form.get('collaborators', None) if collaborators_raw is None: collaborators_raw = request.json.get('collaborators', None) collaborators = collaborators_raw.split(',') new_collaborators = Screenplay.add_access(resource_id, collaborators) send_email = request.form.get('sendEmail', None) if not send_email: send_email = request.json.get('sendEmail', None) if new_collaborators and send_email == 'y': user = current_user.email subject = 'Rawscripts.com: ' + user + " has shared a screenplay with you." title = Screenplay.get_title(resource_id) # build email body and html script_url = url_for('editor', _external=True, resource_id=resource_id) body = script_url + "\n\n\n " body += "--- This screenplay written and sent from RawScripts.com." divArea = '' replacements = { 'SCRIPTTITLE': title, 'USER': user, 'SCRIPTURL': script_url, 'TEXTAREA': divArea } with app.open_resource('static/text/notify.txt') as f: html = f.read() for key, val in replacements.items(): html = html.replace(key, val) msg = Message(subject, recipients=new_collaborators, body=body, html=html) mail.send(msg) # TODO: send the danged email output = ",".join(new_collaborators) return Response(output, mimetype='text/plain')