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 scriptcontent(): resource_id = request.form['resource_id'] if resource_id == 'Demo': latest_version = ScriptData.get_latest_version('Demo') lines = [["Fade in:", 1], ["INT. ", 0]] if latest_version is not None: lines = json.loads(latest_version.data) return jsonify(title='Duck Soup', lines=lines, notes=[], sharedwith=[], contacts=[], autosave='true') user_email = get_current_user_email_with_default() permission = Screenplay.get_users_permission(resource_id, user_email) if permission not in ['owner', 'collab']: return 'not found' title = Screenplay.get_title(resource_id) latest_version = ScriptData.get_latest_version(resource_id) sharedwith = Screenplay.get_all_collaborators(resource_id) user = current_user.name unread_notes = UnreadNote.query. \ filter_by(resource_id=resource_id, user=user).all() unread_msg_ids = set([n.msg_id for n in unread_notes]) note_rows = Note.get_by_resource_id(resource_id) notes = [note.to_dict(unread_msg_ids) for note in note_rows] return jsonify(title=title, lines=json.loads(latest_version.data), lastSavedVersionNumber=latest_version.version, notes=notes, sharedwith=sharedwith, autosave='true')
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 notes_view(): resource_id = request.args.get('resource_id') title = Screenplay.get_title(resource_id) notes = Note.get_by_resource_id(resource_id) output = [[n.row, n.col, json.loads(n.data), n.thread_id] for n in notes] j = json.dumps(output) # TODO: figure out correct permission here f = False # is allowed to delete threads? defaulting to NO return render_template('mobile/MobileViewNotes.html', j=j, title=title, f=f, user=current_user.name, sign_out='/user/sign-out')
def titlepage(): resource_id = request.args.get('resource_id') if not current_user.is_authenticated() and resource_id != 'Demo': return redirect(url_for('welcome')) user_email = get_current_user_email_with_default() permission = Screenplay.get_users_permission(resource_id, user_email) if permission != 'owner' and resource_id != 'Demo': return redirect(url_for('scriptlist')) fields = TitlePageData.get_fields_by_resource_id(resource_id) screenplay_title = Screenplay.get_title(resource_id) return render_template('titlepage.html', user=user_email, screenplay_title=screenplay_title, **fields)
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')
def revision_history(): user = current_user.name resource_id = request.args.get('resource_id') version = request.args.get('version') revisions = ResourceVersion.get_historical_metadata(resource_id, version) data = [] for revision in revisions: d = {'updated': revision.timestamp.strftime("%b %d")} d['version'] = revision.version d['autosave_class'] = 'autosave' if revision.autosave else 'manualsave' exports, tag = revision.get_exports_and_tags() d['export'] = exports d['tag'] = tag d['emailed'] = '' if exports.startswith('[[],') else 'Emailed' d['tagged'] = '' if tag == '' else 'Tag' data.append(d) title = Screenplay.get_title(resource_id) return render_template('revisionhistory.html', user=user, mode="PRO", resource_id=resource_id, r=data, title=title)