Example #1
0
def render_tours(id_tour):
    return render_template(
        "tour.html",
        data_tours=data_tours.get(id_tour),
        title=data_title,
        departures=data_departures,
    )
Example #2
0
File: app.py Project: xaknet/tours
def tour(id):
    if id in tours.keys():
        id = tours.get(id)
    else:
        return not_found(404)

    current_country = id.get("departure")
    from_city = data.departures.get(current_country)

    output = render_template(
        "tour.html",
        id=id,
        title=id.get("title"),
        description=id.get("description"),
        departure=id.get("departure"),
        picture=id.get("picture"),
        price=id.get("price"),
        stars=int(id.get("stars")),
        country=id.get("country"),
        nights=id.get("nights"),
        date=id.get("date"),
        departures=data.departures,
        current_country=current_country,
        from_city=from_city,
    )

    return output
Example #3
0
 def get(self, request, tour_id):
     tour = tours.get(tour_id).copy()
     del tour['departure'], tour['date']
     tour['stars'] = int(tour['stars']) * '★'
     tour_departure = {
         'tour': tour,
     }
     return render(request, 'tour.html', context=tour_departure)
Example #4
0
def tour(id):
    tour = tours.get(id)
    if tour is None:
        abort(404)
    return render_template('tour.html',
                           tour=tour,
                           single_departures=single_departures,
                           departures=departures,
                           stars=int(tour["stars"]),
                           title=title, )
 def get(self, request, id):
     tour = tours.get(id)
     return render(request,
                   'tours/tour.html',
                   context={
                       'id': id,
                       'tour': tour,
                       'stars': '★' * int(tour['stars']),
                       'dep': departures.get(tour['departure'])
                   })
Example #6
0
def tour_view(request, id):
    """View for the specific tour page. """
    context_data = get_base_context()

    tour_data = tours.get(id)
    if not tour_data:
        raise Http404("404: Tour doesn't exist")

    context_data = {**context_data, **tour_data}
    context_data["stars_str"] = "★" * int(context_data["stars"])
    return render(request, "tours/tour.html", context=context_data)
Example #7
0
def get_tour(id):
    #фильтр тура по id
    tour = tours.get(int(id))
    # костыль, чтобы сделать формат вывода стоимости как в образце "ЧЧ ЧЧЧ"
    price = str(tour["price"])[:2] + ' ' + str(tour["price"])[2:]
    output = render_template('tour.html',
                             tour=tour,
                             departures=departures,
                             price=price,
                             title=title)
    return output
Example #8
0
def tour_view(tour_id):
    tour = tours.get(tour_id)
    if tour is None:
        abort(404, "The tour is not found.")
    return render_template(
        "tour.html",
        tour={
            **tour,
            "departure_name": departures[tour["departure"]],
        },
        title=title,
        navbar=departures,
    )
Example #9
0
def show_tour(id_tour):
    tour = tours.get(id_tour)
    tour_departure = tour.get("departure")
    from_town = departures.get(tour_departure)
    # correct typo for 'ночь/и/ей'
    nights = tour.get('nights')
    if nights == 1:
        nights_line = '1 ночь'
    elif nights == 11:
        nights_line = f'{nights} ночей'
    elif 4 >= nights % 10 >= 1:
        nights_line = f'{nights} ночи'
    else:
        nights_line = f'{nights} ночей'
    return render_template('tour.html',
                           title=tour.get('title'),
                           tour=tour,
                           from_town=from_town,
                           nights=nights_line,
                           departures=departures)
Example #10
0
def render_tours(id):
    return render_template('tour.html',
                           title=title,
                           tour=tours.get(int(id)),
                           departures=departures)
Example #11
0
 def get(self, request):
     num_on_page = 6
     rand_tours_keys = sample(range(1, len(tours) + 1), num_on_page)
     rand_tours = {key: tours.get(key) for key in rand_tours_keys}
     context = {"tours": rand_tours}
     return render(request, 'index.html', context=context)
 def get(self, request):
     random_keys = sample(tours.keys(), 6)
     random_tours = {key: tours.get(key) for key in random_keys}
     return render(request,
                   'tours/index.html',
                   context={'tours': random_tours})
Example #13
0
def render_tour(id):
    tour = tours.get(int(id))
    return render_template('tour.html', tour=tour)