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')
Beispiel #2
0
def scriptcontent():
    resource_id = request.form['resource_id']
    if resource_id == 'Demo':
        latest_version = ScriptData.get_latest_version('Demo')
        return jsonify(title='Duck Soup', lines=json.loads(latest_version.data),
                       spelling=[],
                       notes=[], sharedwith=[], contacts=[], autosave='true')

    user_email = get_current_user_email_with_default()
    screenplay = UsersScripts.query.filter_by(resource_id=resource_id,
                                              user=user_email).first()
    if not screenplay:
        return 'not found'

    latest_version = ScriptData.get_latest_version(resource_id)
    sharedwith = UsersScripts.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=screenplay.title,
                   lines=json.loads(latest_version.data),
                   lastSavedVersionNumber=latest_version.version,
                   notes=notes,
                   sharedwith=sharedwith,
                   autosave='true')
Beispiel #3
0
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 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')