def festivals(query=None):
    cursor.execute(
        "SELECT * FROM festivals f JOIN PLACES p  ON  f.id_place = p.id_place ORDER BY f.date_start DESC"
    )
    incoming = cursor.fetchall()
    if query:
        incoming = filter_by_query(incoming, query)

    query_form = QueryForm()
    form = FestivalForm()

    cursor.execute("SELECT * FROM places")
    places = cursor.fetchall()
    form.place.choices = BLANK_OPTION + sorted(
        [(place['id_place'], f'{place["city"]} / {place["name"]}')
         for place in places],
        key=lambda x: x[1])

    form.to_edit.choices = Options.EMPTY + sorted(
        [(x['id_festival'], x['festival_name']) for x in incoming],
        key=lambda x: x[1])

    return render_template('festivals.html',
                           incoming=incoming,
                           form=form,
                           query_form=query_form)
예제 #2
0
def albums(query=None):
    cursor.execute("SELECT * FROM albums ORDER BY band, name")
    my_albums = cursor.fetchall()
    if query:
        my_albums = filter_by_query(my_albums, query)

    form = AlbumForm()
    query_form = QueryForm()

    cursor.execute("SELECT * FROM bands")
    bands = cursor.fetchall()
    form.band.choices = Options.BLANK + sorted(
        [(band['name'], band['name']) for band in bands], key=lambda x: x[1])

    cursor.execute("SELECT * FROM genres")
    genres = cursor.fetchall()
    form.genre.choices = Options.BLANK + sorted([(genre['name'], genre['name'])
                                                 for genre in genres],
                                                key=lambda x: x[1])

    form.to_edit.choices = Options.EMPTY + sorted(
        [(x['name'], x['name']) for x in my_albums], key=lambda x: x[1])

    return render_template('albums.html',
                           my_albums=my_albums,
                           form=form,
                           query_form=query_form)
예제 #3
0
def musicians(query=None):
    cursor.execute("SELECT * FROM musicians ORDER BY band, name")
    my_musicians = cursor.fetchall()
    if query:
        my_musicians = filter_by_query(my_musicians, query)

    form = MusicianForm()
    query_form = QueryForm()

    cursor.execute("SELECT * FROM bands")
    bands = cursor.fetchall()
    form.band.choices = Options.BLANK + sorted(
        [(band['name'], band['name']) for band in bands], key=lambda x: x[1])

    cursor.execute("SELECT * FROM instruments")
    instruments = cursor.fetchall()
    form.instrument.choices = Options.BLANK + sorted(
        [(instrument['type'], instrument['type'])
         for instrument in instruments],
        key=lambda x: x[1])

    form.to_edit.choices = Options.EMPTY + [(x['name'], x['name'])
                                            for x in my_musicians]

    return render_template('musicians.html',
                           my_musicians=my_musicians,
                           form=form,
                           query_form=query_form)
예제 #4
0
def awards(query=None):
    cursor.execute("SELECT * FROM awards ORDER BY name ASC")
    awards = cursor.fetchall()

    if query:
        awards = filter_by_query(awards, query)

    query_form = QueryForm()
    form = AwardForm()

    form.to_edit.choices = Options.EMPTY + sorted(
        [(x['name'], x['name']) for x in awards], key=lambda x: x[1])

    return render_template('awards.html',
                           awards=awards,
                           form=form,
                           query_form=query_form)
예제 #5
0
def bands(query=None):
    cursor.execute("SELECT * FROM bands ORDER BY name")
    my_bands = cursor.fetchall()

    if query:
        my_bands = filter_by_query(my_bands, query)

    query_form = QueryForm()
    form = BandForm()

    form.to_edit.choices = Options.EMPTY + [(x['name'], x['name'])
                                            for x in my_bands]

    return render_template('bands.html',
                           my_bands=my_bands,
                           form=form,
                           query_form=query_form)
def instruments(query=None):
    cursor.execute("SELECT * FROM INSTRUMENTS ORDER BY TYPE ASC")
    instruments = cursor.fetchall()

    if query:
        instruments = filter_by_query(instruments, query)

    query_form = QueryForm()
    form = InstrumentForm()

    form.to_edit.choices = Options.EMPTY + sorted(
        [(x['type'], x['type']) for x in instruments], key=lambda x: x[1])

    return render_template('instruments.html',
                           instruments=instruments,
                           form=form,
                           query_form=query_form)
예제 #7
0
def places(query=None):
    cursor.execute("SELECT * FROM PLACES ORDER BY CITY ASC, NAME ASC")
    places = cursor.fetchall()

    if query:
        places = filter_by_query(places, query)

    query_form = QueryForm()
    form = PlaceForm()

    form.to_edit.choices = Options.EMPTY + sorted(
        [(x['id_place'], f'{x["name"]}/{x["city"]}') for x in places],
        key=lambda x: x[1])

    return render_template('places.html',
                           places=places,
                           form=form,
                           query_form=query_form)
예제 #8
0
def genres(query=None):
    cursor.execute("SELECT * FROM genres ORDER BY name ASC")
    genres = cursor.fetchall()

    if query:
        genres = filter_by_query(genres, query)

    query_form = QueryForm()
    form = GenreForm()

    form.supergenre.choices = Options.BLANK + sorted(
        [(x['name'], x['name']) for x in genres], key=lambda x: x[1])
    form.to_edit.choices = Options.EMPTY + sorted(
        [(x['name'], x['name']) for x in genres], key=lambda x: x[1])

    return render_template('genres.html',
                           genres=genres,
                           form=form,
                           query_form=query_form)
예제 #9
0
def appearances(id_festival=None, query=None):

    cursor.execute("SELECT * FROM bands b JOIN appearances a ON b.name = a.band "
                   "WHERE a.id_festival = %s::INTEGER order by b.name", [id_festival])
    my_bands = cursor.fetchall()

    if query:
        my_bands = filter_by_query(my_bands, query)

    form = AppearanceForm()
    query_form = QueryForm()

    cursor.execute("SELECT * FROM bands")
    bands = cursor.fetchall()
    form.band.choices = Options.BLANK + sorted([(band['name'], band['name']) for band in bands], key=lambda x: x[1])

    cursor.execute("SELECT festival_name FROM festivals WHERE id_festival = %s::INTEGER", [id_festival])
    festival = cursor.fetchone()

    return render_template('appearances.html', my_bands=my_bands, query_form=query_form, form=form,
                           id_festival=id_festival, festival_name=festival['festival_name'])
예제 #10
0
def genres_search():
    form = QueryForm()
    query = form.query.data
    if not is_set(query):
        query = None
    return redirect(url_for('genres.genres', query=query))
예제 #11
0
def awards_search():
    form = QueryForm()
    query = form.query.data
    if not is_set(query):
        query = None
    return redirect(url_for('awards.awards', query=query))
def festivals_search():
    form = QueryForm()
    query = form.query.data
    if not is_set(query):
        query = None
    return redirect(url_for('festivals.festivals', query=query))
예제 #13
0
def musicians_search():
    form = QueryForm()
    query = form.query.data
    if not is_set(query):
        query = None
    return redirect(url_for('musicians.musicians', query=query))
def instruments_search():
    form = QueryForm()
    query = form.query.data
    if not is_set(query):
        query = None
    return redirect(url_for('instruments.instruments', query=query))
예제 #15
0
def appearances_search(id_festival):
    form = QueryForm()
    query = form.query.data
    if not is_set(query):
        query = None
    return redirect(url_for('appearances.appearances', id_festival=id_festival, query=query))