Exemplo n.º 1
0
def home():
    trip = Trip.query.first()
    form = HomeSearchForm()
    if form.validate_on_submit():
        home_search()
    if trip is not None:
        all_trips = Trip.query.all()
        data = []
        for trips in all_trips:
            trips_data = {'location' : trips.location, 'about' : trips.about, 'rating' : trips.trip_rating, 'cost' : trips.total_cost, 'id' : trips.id, 'picture' : trips.trip_picture}
            data.append(trips_data)
        return render_template('home.html', title='Home', data= data, form= form)
    return render_template('home.html', title='Home')
Exemplo n.º 2
0
def home_search():
    trips = Trip.query.all()
    form = HomeSearchForm()
    trips = Trip.query.filter_by(location = form.search.data)
    data = []
    for trip in trips:
        trips_data = {'location' : trip.location, 'about' : trip.about, 'rating' : trip.trip_rating, 'cost' : trip.total_cost, 'id' : trip.id, 'picture' : trip.trip_picture}
        data.append(trips_data)
    return render_template('home.html', title='Home', data= data, form= form)
Exemplo n.º 3
0
def my_trips():
    form = HomeSearchForm()
    trip = Trip.query.first()
    if trip is not None:
        all_trips = Trip.query.filter_by(creator_id=current_user.id)
        data = []
        for trips in all_trips:
            trips_data = {'location' : trips.location, 'about' : trips.about, 'rating' : trips.trip_rating, 'cost' : str(trips.total_cost) + ' kn', 'id' : trips.id}
            data.append(trips_data)
        return render_template('home.html', title='Home', data= data, form= form)
    return render_template('home.html', title='Home', form=form)
Exemplo n.º 4
0
def trips_i_joined():
    trip = Trip.query.first()
    form = HomeSearchForm()
    if trip is not None:
        data = []
        form_join = JoinTrip.query.filter_by(user_id = current_user.id)
        for items in form_join:
            form_join_trip = Trip.query.filter_by(id = items.trip_id)
            for trips in form_join_trip:
                trips_data = {'location' : trips.location, 'about' : trips.about, 'rating' : trips.trip_rating,
                'cost' : str(trips.total_cost) + ' kn', 'id' : trips.id}
                data.append(trips_data)
        return render_template('home.html', title='Home', data= data, form=form)
    return render_template('home.html', title='Home', form=form)
Exemplo n.º 5
0
def search_home(request):
    form = HomeSearchForm()
    artist_search = ArtistNameSearch()
    return render(request, 'home_search.html',{'form':form,'name':artist_search})