Ejemplo n.º 1
0
def edit_set(set_number):
    if 'username' not in session: return redirect(url_for('login'))
    set_id = int(set_number)
    book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(conn, set_id)
    if request.method == 'GET':
        return render_template('edit_set.html',
                               set_id=set_id,
                               book_name=book_name,
                               set_name=set_name,
                               wrap=wrap,
                               wrap_to=wrap_to,
                               tune_count=len(tune_list),
                               tune_list=tune_list)
    else:
        book_name = request.form['book_name']
        set_name = request.form['set_name']
        if 'wrap' in request.form:
            wrap_to = int(request.form['wrap_to'])
            wrap = True
        else:
            wrap = False
            wrap_to = 0
        tune_list = list()
        for i in [1, 2, 3, 4, 5, 6]:
            tune_id = request.form['tune_id_%d' % i]
            repeats = request.form['repeats_%d' % i]
            if tune_id is None or tune_id == '': break
            tune_list.append((int(tune_id), repeats))
        sets.update(conn, set_id, book_name, set_name, wrap, wrap_to,
                    tune_list)
        return redirect(request.referrer)
Ejemplo n.º 2
0
def json_set(set_number):
    book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(conn, set_number)
    tuneList = list()
    for (tune_id, repeats) in tune_list:
        image_path, title, composer, tune_type, timesig, key, file_ext, url, abc = tunes.retrieve(conn, tune_id)
        tuneList.append((image_path, title, repeats))
    return json.dumps([book_name, set_name, wrap, wrap_to, tuneList])
Ejemplo n.º 3
0
def preview_set(set_number):
    book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(conn, set_number)
    tuneList = list()
    for (tune_id, repeats) in tune_list:
        image_path, title, composer, tune_type, timesig, key, file_ext, url, abc = tunes.retrieve(conn, tune_id)
        tuneList.append((image_path, title, repeats))
    return render_template('set_preview.html', book_name=book_name, set_name=set_name, wrap=wrap, wrap_to=wrap_to, tune_list=tuneList)
Ejemplo n.º 4
0
def json_set(set_number):
    book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(
        conn, set_number)
    tuneList = list()
    for (tune_id, repeats) in tune_list:
        image_path, title, composer, tune_type, timesig, key, file_ext, url, abc = tunes.retrieve(
            conn, tune_id)
        tuneList.append((image_path, title, repeats))
    return json.dumps([book_name, set_name, wrap, wrap_to, tuneList])
Ejemplo n.º 5
0
def expand_setnames(book):
    if type(book) is list:
        name, chapters = book
        expandedChapters = list()
        for chapter in chapters:
            expandedChapters.append(expand_setnames(chapter))
        return [name, expandedChapters]
    else:
        set_id = int(book)
        book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(conn, set_id)
        return [set_id, set_name]
Ejemplo n.º 6
0
def expand_setnames(book):
    if type(book) is list:
        name, chapters = book
        expandedChapters = list()
        for chapter in chapters:
            expandedChapters.append(expand_setnames(chapter))
        return [name, expandedChapters]
    else:
        set_id = int(book)
        book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(
            conn, set_id)
        return [set_id, set_name]
Ejemplo n.º 7
0
def preview_set(set_number):
    book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(
        conn, set_number)
    tuneList = list()
    for (tune_id, repeats) in tune_list:
        image_path, title, composer, tune_type, timesig, key, file_ext, url, abc = tunes.retrieve(
            conn, tune_id)
        tuneList.append((image_path, title, repeats))
    return render_template('set_preview.html',
                           book_name=book_name,
                           set_name=set_name,
                           wrap=wrap,
                           wrap_to=wrap_to,
                           tune_list=tuneList)
Ejemplo n.º 8
0
def expand_sets(book):
    if type(book) is list:
        name, chapters = book
        expandedChapters = list()
        for chapter in chapters:
            expandedChapters.append(expand_sets(chapter))
        return [name, expandedChapters]
    else:
        set_id = int(book)
        book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(conn, set_id)
        tuneList = list()
        for (tune_id, repeats) in tune_list:
            image_path, title, composer, tune_type, timesig, key, file_ext, url, abc = tunes.retrieve(conn, tune_id)
            tuneList.append([image_path, title, repeats])
        return [set_name, wrap, wrap_to, tuneList]
Ejemplo n.º 9
0
def show_set(set_number):
    book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(conn, set_number)
    tuneList = list()
    wrap_title = ""
    # once through the tune list
    for (tune_id, repeats) in tune_list:
        image_path, title, composer, tune_type, timesig, key, file_ext, url, abc = tunes.retrieve(conn, tune_id)
        tuneList.append((image_path, title, repeats))
    if wrap:
        wrap_title = tuneList[wrap_to][1]
        tune_count = len(tuneList)
        for i in xrange(29):
            # 30 more times through the repeated portion
            for j in xrange(wrap_to, tune_count):
                image_path, title, repeats = tuneList[j]
                tuneList.append((image_path, title, repeats))
    return render_template('set_show.html', set_name=set_name, tune_list=tuneList, wrap=wrap, wrap_title=wrap_title)
Ejemplo n.º 10
0
def expand_sets(book):
    if type(book) is list:
        name, chapters = book
        expandedChapters = list()
        for chapter in chapters:
            expandedChapters.append(expand_sets(chapter))
        return [name, expandedChapters]
    else:
        set_id = int(book)
        book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(
            conn, set_id)
        tuneList = list()
        for (tune_id, repeats) in tune_list:
            image_path, title, composer, tune_type, timesig, key, file_ext, url, abc = tunes.retrieve(
                conn, tune_id)
            tuneList.append([image_path, title, repeats])
        return [set_name, wrap, wrap_to, tuneList]
Ejemplo n.º 11
0
def edit_set(set_number):
    if 'username' not in session: return redirect(url_for('login'))
    set_id = int(set_number)
    book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(conn, set_id)
    if request.method == 'GET':
        return render_template('edit_set.html', set_id=set_id, book_name=book_name, set_name=set_name, wrap=wrap, wrap_to=wrap_to, tune_count=len(tune_list), tune_list=tune_list)
    else:
        book_name = request.form['book_name']
        set_name = request.form['set_name']
        if 'wrap' in request.form:
            wrap_to = int(request.form['wrap_to'])
            wrap = True
        else:
            wrap = False
            wrap_to = 0
        tune_list = list()
        for i in [1,2,3,4,5,6]:
            tune_id = request.form['tune_id_%d' % i]
            repeats = request.form['repeats_%d' % i]
            if tune_id is None or tune_id == '': break
            tune_list.append((int(tune_id), repeats))
        sets.update(conn, set_id, book_name, set_name, wrap, wrap_to, tune_list)
        return redirect(request.referrer)
Ejemplo n.º 12
0
def show_set(set_number):
    book_name, set_name, wrap, wrap_to, tune_list = sets.retrieve(
        conn, set_number)
    tuneList = list()
    wrap_title = ""
    # once through the tune list
    for (tune_id, repeats) in tune_list:
        image_path, title, composer, tune_type, timesig, key, file_ext, url, abc = tunes.retrieve(
            conn, tune_id)
        tuneList.append((image_path, title, repeats))
    if wrap:
        wrap_title = tuneList[wrap_to][1]
        tune_count = len(tuneList)
        for i in xrange(29):
            # 30 more times through the repeated portion
            for j in xrange(wrap_to, tune_count):
                image_path, title, repeats = tuneList[j]
                tuneList.append((image_path, title, repeats))
    return render_template('set_show.html',
                           set_name=set_name,
                           tune_list=tuneList,
                           wrap=wrap,
                           wrap_title=wrap_title)