def show_adv(id): advertisement = query.get(id) if 'error' in advertisement: page_not_found('Wrong id') images = query.get_images(id) return render_template('advertisement.html', advertisement=advertisement, images=images)
def edit_adv(id): images = query.get_images(id) advertisement = query.get(id) if advertisement: if advertisement[1] != session['id']: return page_not_found return render_template('edit.html', images=images, advertisement=advertisement, advertisement_id=id)
def show_unpub_adv(): incompletes = query.get_incompletes(session['id']) images = [] for incomplete in incompletes: advert_id = incomplete[0] result = query.get_images(advert_id) images.append(result) print(images) return render_template('create.html', advertisements=incompletes, images=images)
def show_profile(user_id): profile = user.get_user(user_id) published = query.get_published(user_id) images = [] for adv in published: advert_id = adv[0] result = query.get_images(advert_id) images.append(result) return render_template('profile.html', advertisements=published, images=images, profile=profile)
def index(): advertisements = query.get_all() ## part query to 5 item pages current_page = request.args.get('page', 1, type=int) items_per_page = 5 pages = round(len(advertisements) / items_per_page + .499) from_page = int(current_page) * items_per_page - items_per_page upto_page = int(current_page) * items_per_page list_part = advertisements[from_page:upto_page] images = [] for adv in list_part: images.append(query.get_images(adv[0])) return render_template('index.html', images=images, advertisements=list_part, pages=pages, current_page=current_page)
def search(): region = request.args['region'] max = request.args['max'] min = request.args['min'] result = query.search(region, min, max) current_page = request.args.get('page', 1, type=int) items_per_page = 5 pages = round(len(result) / items_per_page + .499) from_page = int(current_page) * items_per_page - items_per_page upto_page = int(current_page) * items_per_page list_part = result[from_page:upto_page] images = [] for adv in list_part: images.append(query.get_images(adv[0])) return render_template('search.html', images=images, advertisements=list_part, pages=pages, current_page=current_page, region=region, max=max, min=min)