Example #1
0
def searchDisplay(keyword):
    form = SearchForm()
    if keyword == 'hotline' or keyword == 'hotlines':
        data = getServices('hotlines')
    else:
        data = Search(keyword)
    total = len(data)

    if total != 0:
        map = ifMap(data)
    else:
        map = 'no'

    page, per_page, offset = get_page_args(page_parameter='page',
                                           per_page_parameter='per_page')

    pagination_data = searchPage(data, offset=offset, per_page=per_page)
    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=total,
                            css_framework='bootstrap4')
    if current_user.is_authenticated:
        email = current_user.email
        favoList = getFavorite(email)
    else:
        favoList = []
    if form.validate_on_submit():
        keyword = form.search.data
        return redirect(url_for('searchDisplay', keyword=keyword))
    return render_template('searchDisplay.html',
                           title='Search Result',
                           form=form,
                           keyword=keyword,
                           favoList=favoList,
                           pagination_data=pagination_data,
                           page=page,
                           per_page=per_page,
                           pagination=pagination,
                           map=map)
Example #2
0
def index():
    search = False
    q = request.args.get('q')
    if q:
        search = True

    page = request.args.get(get_page_parameter(), type=int, default=1)

    user_count = User.query.count()
    users=User.query.all()
    pagination = Pagination(page=page, total=user_count, search=search, record_name='users',per_page=3)
    # 'page' is the default name of the page parameter, it can be customized
    # e.g. Pagination(page_parameter='p', ...)
    # or set PAGE_PARAMETER in config file
    # also likes page_parameter, you can customize for per_page_parameter
    # you can set PER_PAGE_PARAMETER in config file
    # e.g. Pagination(per_page_parameter='pp')

    return render_template('index.html',
                           users=users,
                           pagination=pagination,
                           )
Example #3
0
def custome_pagination(data):
    """
    Function returns a custome pagination and pagination items
    which is display 10 items per page.

    :param data: the input stream data.

    :return: pagination and pagination_items.
    """
    page, per_page, offset = get_page_args(page_parameter='page',
                                           per_page_parameter='per_page')

    pagination_items = data[offset:offset + per_page]

    pagination = Pagination(
        page=page,
        per_page=per_page,
        total=len(data),
        css_framework='bootstrap4',
    )

    return pagination, pagination_items
Example #4
0
def tickets():
    search = False
    response = requests.get("http://localhost:5000/ticketView")
    data = json.loads(response.text)

    per_page = 25

    page = request.args.get(get_page_parameter(), type=int, default=1)
    offset = (page - 1) * per_page

    datas = data[offset:offset + per_page]

    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=len(data),
                            search=search,
                            record_name='data',
                            css_framework='bootstrap4')

    return render_template('tickets.html',
                           tickets=datas,
                           pagination=pagination)
Example #5
0
def room_index():
    search = False
    q = request.args.get('q')
    if q:
        search = True
    page = request.args.get(get_page_parameter(), type=int, default=1)

    total = Room.query.count()
    rooms = Room.query.join(Place, isouter=True).order_by(Place.name, Room.name)\
        .slice((page - 1) * ITEMS_PER_PAGE, page * ITEMS_PER_PAGE)
    pagination = Pagination(page=page,
                            total=total,
                            search=search,
                            record_name='rooms',
                            per_page=ITEMS_PER_PAGE,
                            css_framework=get_css_framework(),
                            format_total=True,
                            format_number=True)

    return render_template("room/list.html",
                           rooms=rooms,
                           pagination=pagination)
def index():

    day = request.args.get('day')
    conn = sqlite3.connect(os.environ['DATABASE_NAME'])
    cur = conn.cursor()

    now = datetime.datetime.now(JST)
    ranking_timestamp = now - datetime.timedelta(hours=4)
    max_day = ranking_timestamp.strftime("%Y-%m-%d")

    if day is None:
        day = max_day

    stop_day = (datetime.datetime.strptime(day, "%Y-%m-%d") +
                datetime.timedelta(days=1)).strftime("%Y-%m-%d")
    params = (day, )

    print(params)

    cur.execute(
        "SELECT RANK() OVER(ORDER BY kcal DESC) AS ranking,user_name,kcal,tweeted_time "
        "FROM (SELECT *, RANK() OVER(PARTITION BY user_screen_name ORDER BY kcal DESC, id) AS rnk FROM Exercise WHERE   date(datetime(tweeted_time,'-4 hours'))==?) tmp "
        "WHERE rnk = 1 ORDER BY kcal DESC, tweeted_time ASC;", params)

    exercise_data_list = cur.fetchall()

    page = request.args.get(get_page_parameter(), type=int, default=1)
    res = exercise_data_list[(page - 1) * 100:page * 100]
    pagination = Pagination(page=page,
                            total=len(exercise_data_list),
                            per_page=100,
                            css_framework='bootstrap4')

    return render_template('index.html',
                           results=res,
                           start_day=day,
                           stop_day=stop_day,
                           max_day=max_day,
                           pagination=pagination)
Example #7
0
def users():
    # post_list = PostModel.query.all()
    # return render_template('cms/cms_posts.html', posts=post_list)

    # 获取当前页码数
    page = request.args.get(get_page_parameter(), type=int, default=1)
    start = (page - 1) * config.MANAGE_PER_PAGE
    end = start + config.MANAGE_PER_PAGE

    query_obj = User.query.order_by(User.join_time.desc())
    total = query_obj.count()
    pagination = Pagination(bs_version=3,
                            page=page,
                            total=total,
                            per_page=config.MANAGE_PER_PAGE)
    users = query_obj.slice(start, end)

    context = {
        'users': users,
        'pagination': pagination,
    }
    return render_template('pcenter/pc_users.html', **context)
Example #8
0
def list_logs(per_page):
    """Returns a page which lists the logs."""
    head_titles = ['Logs']

    time_from = request.args.get('from', '')
    time_to = request.args.get('to', '')
    software = request.args.get('software', '')
    software_version = request.args.get('software_version', '')
    http_referrer = request.args.get('http_referrer', '')

    query = models.Log.query.order_by(desc(models.Log.timestamp))
    if time_from and time_to:
        query = query.filter(models.Log.timestamp.between(time_from, time_to))

    if software:
        query = query.filter(models.Log.software == software)

    if software_version:
        query = query.filter(models.Log.software_version == software_version)

    if http_referrer:
        query = query.filter(models.Log.http_referrer. \
                                            like('%{}%'.format(http_referrer)))

    page, per_page, offset = get_page_args()
    pagination = Pagination(page=page,
                            total=query.count(),
                            css_framework='bootstrap4',
                            search=False,
                            record_name='logs',
                            per_page=per_page)

    return render_template('admin/logs.html',
                           logs=query.offset(offset).limit(per_page),
                           pagination=pagination,
                           head_titles=head_titles,
                           software=software,
                           software_version=software_version,
                           http_referrer=http_referrer)
def profile(username):
    # checks user is in session
    if "user" in session:
        # Gets session user
        session_user = session["user"]
        # Checks username is equal to session user
        if username == session_user:
            page, per_page, offset = get_page_args(
                page_parameter='page', per_page_parameter='per_page')
            per_page = 4

            if page == 1:
                offset = 0
            else:
                offset = (page - 1) * per_page
            # gets recipes
            recipes = mongo.db.recipes.find()

            # grab the session user's username from the db
            user = mongo.db.users.find_one({"username": session["user"]})
            # gets the recipes added by the user
            recipes = mongo.db.recipes.find(
                {'created_by': session.get('user')})
            # counts there total recipes
            total = recipes.count()

            paginatedResults = recipes[offset:offset + per_page]
            pagination = Pagination(page=page, per_page=per_page, total=total)

            return render_template("profile.html",
                                   user=user,
                                   recipes=paginatedResults,
                                   page=page,
                                   per_page=per_page,
                                   pagination=pagination,
                                   total=total)
        return redirect(url_for("profile", username=session["user"]))

    return redirect(url_for("login"))
Example #10
0
def paginated_gallery(self):

    # START TEST

    workingdir = Path(__file__).parent
    app.logger.warning('working directory %s', workingdir)
    app.logger.warning('static img pth %s', staticImagePth)
    # pth = os.path.join(workingdir, staticImagePth)
    pth = str(workingdir / staticImagePth)
    app.logger.warning('Image path %s', pth)
    global image_names
    image_names = os.listdir(pth)
    app.logger.warning('Total images %s', ''.join(image_names))

    # END TEST

    app.logger.warning('Endpoint: paginated_gallery')
    page, per_page, offset = get_page_args(page_parameter='page',
                                           per_page_parameter='per_page')
    total = len(image_names)
    app.logger.warning('Total images %d', total)

    pagination_images = get_images(offset=offset, per_page=per_page)
    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=total,
                            css_framework='bootstrap4')

    app.logger.warning('pagination_image length %d',
                       pagination_images.__len__())
    app.logger.warning('pagination_images %s', ''.join(pagination_images))

    return render_template(
        'pagedgallery.html',
        images=pagination_images,
        page=page,
        per_page=per_page,
        pagination=pagination,
    )
Example #11
0
def allrecipes():
    page = request.args.get(get_page_parameter(), type=int, default=1)
    results = []
    results = db.session.query(
        Recipe, Author, Ingredient,
        Cuisine).join(Author).join(Ingredient).join(Cuisine).all()
    print(results)
    page_size = len(results)
    offset = (page - 1) * PER_PAGE

    pagination_results = get_results(offset, PER_PAGE, results)

    pagination = Pagination(page=page,
                            per_page=PER_PAGE,
                            total=page_size,
                            css_framework='bootstrap3')

    return render_template('allrecipes.html',
                           results=pagination_results,
                           page=page,
                           per_page=PER_PAGE,
                           pagination=pagination)
Example #12
0
def search():
  """
  Searching the papers and uses pagination to render the results
  Takes query from GET(query params) and POST (body params)
  """
  if request.args.get('q'):
    g.search_form.q.data = request.args.get('q')
  q = g.search_form.q.data if g.search_form.q.data else None

  if q is None:
    return render_template('404.html'), 404

  page = request.args.get('page', 1, type=int)
  per_page = app.config['PER_PAGE']

  paginated_papers, total = Paper.search(q, page, per_page)

  href="search?q={}".format(q) + '&page={0}' ##customizing to include search query parameter
  pagination = Pagination(href=href, page=page, per_page=per_page, total=total, record_name='papers',format_total=True, format_number=True)
  # print(pagination.__dict__)

  return render_template('papers.html', papers=paginated_papers, pagination=pagination, per_page=per_page)
Example #13
0
def Contrato():
    SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
    json_url = os.path.join(SITE_ROOT, 'json_files', 'Contrato.json')
    json_data = json.load(open(json_url))
    df = pd.DataFrame(json_data)# todos os dados
    df_co_Ano_Mes_Max = df[df['Ano'] == df.Ano.max()]
    Ano_max_co = df_co_Ano_Mes_Max.Ano.max()
    Mes_max_co = df_co_Ano_Mes_Max.Mês.max()
    df = df[(df['Mês'] == Mes_max_co) & (df['Ano'] == Ano_max_co)][['Mês', 'Ano','Nº (a)', 'Objeto (b)', 'Data da Publicação (c)',
    'Nº do Edital (d)', 'Vigência Inicio (e)', 'Vigência Término (e )',
    'Situação (f)', 'Item Fornecido (g)', 'Unidade de Medida (h)',
    'Valor Unitário (i)', 'Quantidade (j)', 'Valor Total do Item (k)',
    'Valor Total do Contrato (l)', 'Contratado (m)', 'CNPJ/CPF (n)',
    'Sócios (o)', 'Termo Aditivo (p)']]  # dados filtrados
    page = request.args.get(get_page_parameter(), type=int, default=1)
    PER_PAGE = 5
    pagination = Pagination(bs_version=4, page=page, per_page=PER_PAGE, total=len(df), record_name='df')

    form = ConsultaAnoMes()

    if form.validate_on_submit():
        mes = form.mes.data
        ano = form.ano.data
        df = pd.DataFrame(json_data)  # todos os dados
        df = df[(df['Mês'] == int(mes)) & (df['Ano'] == int(ano))
        & (df['Nº (a)'].str.contains(request.form['N']) == True)
        & (df['Contratado (m)'].str.contains(request.form['Contratado']) == True)
        & (df['CNPJ/CPF (n)'].str.contains(request.form['CNPJ_CPF']) == True)
        & (df['Situação (f)'].str.contains(request.form['Situacao']) == True)][['Mês', 'Ano','Nº (a)', 'Objeto (b)', 'Data da Publicação (c)',
       'Nº do Edital (d)', 'Vigência Inicio (e)', 'Vigência Término (e )',
       'Situação (f)', 'Item Fornecido (g)', 'Unidade de Medida (h)',
       'Valor Unitário (i)', 'Quantidade (j)', 'Valor Total do Item (k)',
       'Valor Total do Contrato (l)', 'Contratado (m)', 'CNPJ/CPF (n)',
       'Sócios (o)', 'Termo Aditivo (p)', 'Mês', 'Ano']]  # dados filtrados
        return render_template('main_licitacao_con.html', tables=df[(page - 1) * PER_PAGE:page * PER_PAGE].to_html(classes='table table-fluid', table_id="myTable2"),
    titles='Contratos', form=form, pagination=pagination)

    return render_template('main_licitacao_con.html', tables=df[(page - 1) * PER_PAGE:page * PER_PAGE].to_html(classes='table table-fluid', table_id="myTable2"),
        titles='Contratos', form=form, pagination=pagination)
Example #14
0
def absences_index():
    search = False
    q = request.args.get('q')
    if q:
        search = True
    page = request.args.get(get_page_parameter(), type=int, default=1)

    total = Absence.query.count()
    absences = Absence.query.join(User, isouter=True).order_by(User.name, Absence.date_start, Absence.date_end) \
        .slice((page - 1) * ITEMS_PER_PAGE, page * ITEMS_PER_PAGE)
    pagination = Pagination(page=page,
                            total=total,
                            search=search,
                            record_name='absences',
                            per_page=ITEMS_PER_PAGE,
                            css_framework=get_css_framework(),
                            format_total=True,
                            format_number=True)

    return render_template("absence/list.html",
                           absences=absences,
                           pagination=pagination)
Example #15
0
def all_games():
    '''
    provide users access to see all games that
    have been added in the games collection
    '''
    search = False
    args = request.args.get('args')
    if args:
        search = True
    page = request.args.get(get_page_parameter(), type=int, default=1)
    per_page = 5
    offset = ((page - 1) * per_page)
    games = mongo.db.games.find()
    games_to_render = games.limit(per_page).skip(offset)
    pagination = Pagination(page=page,
                            total=games.count(),
                            search=search,
                            record_name='games',
                            per_page=5)
    return render_template('all_games.html',
                           games=games_to_render,
                           pagination=pagination)
Example #16
0
def quickRec():
    search = False
    q = request.args.get('q')
    if q:
        search = True
    page = request.args.get(get_page_parameter(), type=int, default=1)
    # get_page_arg defaults to page 1, per_page of 10
    page, per_page, offset = get_page_args()
    recipes = mongo.db.recipes.find({
        "Total_time": {
            '$lte': 30
        }
    }).sort('Total_time', pymongo.ASCENDING)
    recipes_to_render = recipes.limit(per_page).skip(offset)
    pagination = Pagination(page=page,
                            total=recipes.count(),
                            per_page=per_page,
                            offset=offset)
    return render_template('quickRec.html',
                           recipes=recipes_to_render,
                           search=search,
                           pagination=pagination)
Example #17
0
def show_hashtag_data():
    if request.method == 'POST':
        create_cookie(request.form, session)
    username = session['username']
    keyword = session['keyword']
    profile_engagements = session['profile_engagements']

    if profile_engagements == "not found":
        return render_template("main-page.html",
                               username_flag=0,
                               keyword=keyword)

    sort_by = session["sort_by"]

    send_telegram_msg(username, keyword, sort_by)

    page, per_page, offset = get_page_args(page_parameter='page',
                                           per_page_parameter='per_page')
    per_page = 100
    hashtag_list = get_hashtags_from_db(keyword, profile_engagements, sort_by)
    total = len(hashtag_list)
    not_found_flag = False
    if total < 20:
        not_found_flag = not_found(keyword, profile_engagements, username)
    pagination_users = get_table_hashtags(hashtag_list, offset, per_page)
    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=total,
                            css_framework='bootstrap4')
    return render_template('main-page.html',
                           rows=pagination_users,
                           username=username,
                           keyword=keyword,
                           page=page,
                           per_page=per_page,
                           pagination=pagination,
                           order_by=sort_by,
                           not_found_flag=not_found_flag,
                           username_found=1)
Example #18
0
def recentlyAdded():
    search = False
    q = request.args.get('q')
    if q:
        search = True
    page = request.args.get(get_page_parameter(), type=int, default=1)
    # get_page_arg defaults to page 1, per_page of 10
    page, per_page, offset = get_page_args()
    recipes = mongo.db.recipes.find({
        "upvotes": {
            "$gte": 0
        }
    }).sort([('_id', pymongo.DESCENDING), ('upvotes', pymongo.DESCENDING)])
    recipes_to_render = recipes.limit(per_page).skip(offset)
    pagination = Pagination(page=page,
                            total=recipes.count(),
                            per_page=per_page,
                            offset=offset)
    return render_template('recentlyAdded.html',
                           recipes=recipes_to_render,
                           search=search,
                           pagination=pagination)
Example #19
0
def product_index():
    search = False
    q = request.args.get('search')
    if q:
        search = True
    page, per_page, offset = get_page_args(page_parameter='page',
                                           per_page_parameter='per_page')
    if search:
        regex = re.compile('.*' + q + '.*')
        product = Product.objects(catalog_id=q,
                                  active=True).skip(offset).limit(per_page)
    else:
        product = Product.objects(active=True).skip(offset).limit(per_page)
    pagination = Pagination(page=page,
                            total=product.count(),
                            record_name='products',
                            css_framework='bootstrap4')
    return render_template('admin/product/index.html',
                           products=product,
                           page=page,
                           per_page=per_page,
                           pagination=pagination)
Example #20
0
def submit():

    if request.form.getlist("download") == ['on']:

        print(type(request.form.getlist("download")))

        outputcsv = result(APP_ROOT, model)

        #outputcsv.to_csv(destination)
        csv = outputcsv.to_csv()
        return Response(
            csv,
            mimetype="text/csv",
            headers={"Content-disposition": "attachment; filename=result.csv"})

    else:

        print(type(request.form.getlist("display")))

        outputcsv = result(APP_ROOT, model)

        dat = outputcsv.to_dict(orient="records")
        page, per_page, offset = get_page_args(page_parameter='page',
                                               per_page_parameter='per_page')
        total = len(dat)

        pagination_pages = get_pages(data=dat,
                                     offset=offset,
                                     per_page=per_page)

        pagination = Pagination(page=page,
                                per_page=per_page,
                                total=total,
                                css_framework='bootstrap4')
        return render_template('submit.html',
                               data=pagination_pages,
                               page=page,
                               per_page=per_page,
                               pagination=pagination)
Example #21
0
File: app.py Project: himaldew/MS3
def get_recipes():
    search = False
    query = request.args.get('query')
    if query:
        search = True

    page = request.args.get(get_page_parameter(), type=int, default=1)
    per_page = 10
    offset = (page - 1) * per_page
    recipes = mongo.db.recipes.find().skip(offset).limit(per_page)

    pagination = Pagination(
        page=page,
        total=recipes.count(),
        search=search,
        offset=offset,
        per_page=per_page,
    )

    return render_template('recipes.html',
                           recipes=recipes,
                           pagination=pagination)
Example #22
0
def upvoted_recipes():

    search = False
    q = request.args.get('q')
    if q:
        search = True

    page = request.args.get(get_page_parameter(), type=int, default=1)

    recipes = mongo.db.recipes.find().sort("upvotes", -1).skip(
        (page - 1) * per_page).limit(per_page)

    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=recipes.count(),
                            search=search,
                            record_name='recipes',
                            bs_version=4)

    return render_template('recipes.html',
                           recipes=recipes,
                           pagination=pagination)
def home():
    micropost = feed_items = pagination = token = None
    if logged_in():
        token = csrf_token()
        user = current_user()
        micropost = user.microposts.build()
        feed_items = user.feed()
        page = request.args.get(get_page_parameter(), type=int, default=1)
        per_page = 30
        total = len(feed_items)
        feed_items = feed_items[(page - 1) * per_page:page * per_page]
        pagination = Pagination(page=page,
                                total=total,
                                per_page=per_page,
                                prev_label='&larr; Previous',
                                next_label='Next &rarr;',
                                css_framework='bootstrap3')
    return render_template('static_pages/home.html',
                           micropost=micropost,
                           feed_items=feed_items,
                           pagination=pagination,
                           csrf_token=token)
def index():
    page = request.args.get(get_page_parameter(), type=int, default=1)
    per_page = 30
    # 全ユーザー数を取得するUser.countメソッドでどのみちUser.allを呼び出すので
    # paginateは使用しないでUser.allを使用する
    #users = User.paginate(page)
    users = User.all()
    total = len(users)
    users = users[(page - 1) * per_page:page * per_page]
    # User.paginateを使う場合
    # pagination = Pagination(page=page, total=User.count(), per_page=per_page,
    #                         prev_label='&larr; Previous', next_label='Next &rarr;',
    #                         css_framework='bootstrap3')
    pagination = Pagination(page=page,
                            total=total,
                            per_page=per_page,
                            prev_label='&larr; Previous',
                            next_label='Next &rarr;',
                            css_framework='bootstrap3')
    return render_template('users/index.html',
                           users=users,
                           pagination=pagination)
Example #25
0
def instruments_index():
    search = False
    q = request.args.get('q')
    if q:
        search = True
    page = request.args.get(get_page_parameter(), type=int, default=1)

    total = Instrument.query.count()
    instruments = Instrument.query.order_by(Instrument.name)\
        .slice((page - 1) * ITEMS_PER_PAGE, page * ITEMS_PER_PAGE)
    pagination = Pagination(page=page,
                            total=total,
                            search=search,
                            record_name='instruments',
                            per_page=ITEMS_PER_PAGE,
                            css_framework=get_css_framework(),
                            format_total=True,
                            format_number=True)

    return render_template("instrument/list.html",
                           instruments=instruments,
                           pagination=pagination)
Example #26
0
def list_all_commodities(limit=10):
    id = session.get('user_id')
    user = User.query.get(id)
    data = Orders.query.filter(
        or_(Orders.status == "已出厂", Orders.status == "已入仓")).all()
    page = int(request.args.get("page", 1))
    start = (page - 1) * limit
    end = page * limit if len(data) > page * limit else len(data)
    pagination = Pagination(css_framework='bootstrap4',
                            page=page,
                            total=len(data),
                            outer_window=0,
                            inner_window=1)
    ret = Orders.query.filter(
        or_(Orders.status == "已出厂", Orders.status == "已入仓")).slice(start, end)
    return render_template("orderslist.html",
                           orders=ret,
                           pagination=pagination,
                           user=user,
                           type="仓库",
                           ops="入仓",
                           hre='warehouse_page.out')
    def _render_oai_html(self):
        pagination = Pagination(page=self.page,
                                per_page=self.per_page,
                                total=self.feature_list.feature_count)

        _template_context = {
            "links": self.links,
            "collection": self.feature_list.collection,
            "members": self.members,
            "pagination": pagination
        }

        if self.request.values.get(
                "bbox"
        ) is not None:  # it it exists at this point, it must be valid
            _template_context["bbox"] = (self.feature_list.bbox_type,
                                         self.request.values.get("bbox"))

        return Response(
            render_template("features.html", **_template_context),
            headers=self.headers,
        )
Example #28
0
def get_products():
    """
        This function will search the products Db and return all products
        in paginated format.
    """
    products = list(mongo.db.products.find().sort("product_name", 1))
    page, per_page, offset = get_page_args(page_parameter='page',
                                           per_page_parameter='per_page',
                                           offset_parameter='offset')
    per_page = 6
    offset = (page - 1) * 6
    total = mongo.db.products.find().count()
    products_paginated = products[offset:offset + per_page]
    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=total,
                            css_framework='materializecss')
    return render_template("products.html",
                           products=products_paginated,
                           page=page,
                           per_page=per_page,
                           pagination=pagination)
Example #29
0
def home():
    loadPost()
    page, per_page, offset = get_page_args(page_parameter='page',
                                           per_page_parameter='per_page')
    total = len(post_list)
    pagination_posts = get_posts(offset=offset, per_page=per_page)
    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=total,
                            css_framework='bootstrap4')
    return render_template(
        'home.html',
        post_list=post_list,
        category_list=category_list,
        len=len,
        BeautifulSoup=BeautifulSoup,
        markdown=markdown,
        posts=pagination_posts,
        page=page,
        per_page=per_page,
        pagination=pagination,
    )
Example #30
0
def my_recipes():
    """
    searches recipes username field to see does it
    match the username in session.
    """
    if 'username' in session:
        per_page = 9
        recipes = mongo.db.recipes.find({'username': session['username']})
        page = request.args.get(get_page_parameter(), type=int, default=1)
        skips = per_page * (page - 1)
        cursor = recipes.skip(skips).limit(per_page)
        pagination = Pagination(page=page,
                                total=recipes.count(),
                                record_name='recipes',
                                per_page=per_page,
                                bs_version=4,
                                css_framework='bootstrap',
                                alignment='center')
        return render_template('my_recipes.html',
                               recipes=recipes,
                               pagination=pagination)
    return redirect(url_for('access_denied'))