def listings(): page = request.args.get("page", 1, type=int) categories = Category.query.all() listings = (Listing.query.filter(Listing.status == True).order_by( Listing.rating.desc()).paginate(page, current_app.config["POSTS_PER_PAGE"], False)) if request.args.get("place") or request.args.get("date"): name = request.args.get("place") or "" date = request.args.get("date") or datetime.now() if isinstance(date, str): checkdate = datetime.strptime(date, "%m/%d/%Y") date = datetime.combine(checkdate, datetime.min.time()) listings = get_search(name, date, page) next_url = (url_for("home.listings", page=listings.next_num) if listings.has_next else None) prev_url = (url_for("home.listings", page=listings.prev_num) if listings.has_prev else None) maxlist = Listing.query.filter(Listing.status == True).all() maxval = (int(max(node.price.total_price_adults for node in maxlist)) if maxlist else 0) arcodes = get_arcode() return render_template( "home/list.html", listings=listings.items, next_url=next_url, prev_url=prev_url, arcodes=arcodes, categories=categories, maxval=maxval, )
def tour_operator_listings(publisher_id): page = request.args.get("page", 1, type=int) publisher = User.query.filter_by(id=publisher_id).first() publisher_listings = (Listing.query.filter_by( publisher_id=publisher_id).filter(Listing.status == True).order_by( Listing.createdAt.desc()).paginate(page, 8, False)) next_url = (url_for( "home.tour_operator_listings", publisher_id=publisher_id, page=publisher_listings.next_num, ) if publisher_listings.has_next else None) prev_url = (url_for( "home.tour_operator_listings", publisher_id=publisher_id, page=publisher_listings.prev_num, ) if publisher_listings.has_prev else None) arcodes = get_arcode() return render_template( "home/operator_listings.html", publisher=publisher, publisher_listings=publisher_listings.items, next_url=next_url, prev_url=prev_url, arcodes=arcodes, )
def package(): pricing = Price.query.filter_by(publisher=current_user).group_by( Price.location) arcodes = get_arcode() return render_template("publisher/package.html", items=pricing, arcodes=arcodes)
def tour_operator_contact(publisher_id): publisher = User.query.filter_by(id=publisher_id).first() publisher_listings = Listing.query.filter_by(publisher_id=publisher_id) arcodes = get_arcode() return render_template( "home/operator_contact.html", publisher=publisher, publisher_listings=publisher_listings, arcodes=arcodes, )
def get_country_code(country): from app.publisher.countries import get_arcode code = get_arcode() if country.lower().title() in code: county_code = code[country.lower().title()] else: county_code = "KE" return county_code
def tour_operator_destinations(publisher_id): publisher = User.query.filter_by(id=publisher_id).first() publisher_listings = Listing.query.filter_by( publisher_id=publisher_id).group_by(Listing.location) arcodes = get_arcode() return render_template( "home/operator_destinations.html", publisher=publisher, publisher_listings=publisher_listings, arcodes=arcodes, )
def tour_operator_reviews(publisher_id): publisher = User.query.filter_by(id=publisher_id).first() publisher_listings = Listing.query.filter_by( publisher_id=publisher_id).filter(Listing.status == True) arcodes = get_arcode() return render_template( "home/operator_reviews.html", publisher=publisher, publisher_listings=publisher_listings, arcodes=arcodes, )
def _get_tour_ratings(): data = request.args page = request.args.get("page", 1, type=int) publishers = User.get_tour_ratings(data, page) next_url = (url_for("home.tour_operators", page=publishers.next_num) if publishers.has_next else None) prev_url = (url_for("home.tour_operators", page=publishers.prev_num) if publishers.has_prev else None) arcodes = get_arcode() return render_template( "home/_tour_operators.html", publishers=publishers.items, arcodes=arcodes, next_url=next_url, prev_url=prev_url, )
def _get_ratings(): data = request.args page = request.args.get("page", 1, type=int) listings = get_ratings(data, page) next_url = (url_for("home.listings", page=listings.next_num) if listings.has_next else None) prev_url = (url_for("home.listings", page=listings.prev_num) if listings.has_prev else None) arcodes = get_arcode() return render_template( "home/_listings.html", listings=listings.items, arcodes=arcodes, next_url=next_url, prev_url=prev_url, )
def _get_range(): max_val = request.args.get("maxval", 1, type=int) min_val = request.args.get("minval", 1, type=int) page = request.args.get("page", 1, type=int) listings = get_range(max_val, min_val, page) next_url = (url_for("home.listings", page=listings.next_num) if listings.has_next else None) prev_url = (url_for("home.listings", page=listings.prev_num) if listings.has_prev else None) arcodes = get_arcode() return render_template( "home/_listings.html", listings=listings.items, arcodes=arcodes, next_url=next_url, prev_url=prev_url, )
def tour_operators_list(): page = request.args.get("page", 1, type=int) place = request.args.get("place", "none", type=str) publishers = (Publisher.query.join( User, (User.id == Publisher.user_id)).join( Publocations, (Publocations.publisher_id == Publisher.id)).filter( User.status == True).filter( Publocations.country.like("%" + place + "%")).order_by( Publisher.overal_ratings.desc()).paginate( page, current_app.config["POSTS_PER_PAGE"], False)) next_url = (url_for("home.tour_operators", page=publishers.next_num) if publishers.has_next else None) prev_url = (url_for("home.tour_operators", page=publishers.prev_num) if publishers.has_prev else None) offices = Publocations.query.group_by(Publocations.country) arcodes = get_arcode() return render_template( "home/tour_operators.html", publishers=publishers.items, arcodes=arcodes, offices=offices, next_url=next_url, prev_url=prev_url, )
def countries_and_parks_list(): countries = Country.query.all() arcodes = get_arcode() return render_template("home/countries_and_parks.html", countries=countries, arcodes=arcodes)