Exemplo n.º 1
0
def show_dashboard_inner():
    per_page = 9
    paginator = Paginator()
    form = dashboard_itemsform.DashboardItemsForm()
    servername = socket.gethostname()
    approot = os.path.split(app.root_path)
    users = g.user
    instance = SysInfo()
    freespace = instance.diskspace()
    ltime = instance.systime()
    atime = instance.altertime()
    pages = request.args.get('page', type=int, default=1)
    if not users and pages == None:
        abort(404)
    else:
        contents_loop = sql.session.query(Content).limit(
            (per_page)).offset(
            (pages - 1) * per_page).all()
        pagination = paginator.paginate_queries(Content, pages, per_page)
        return render_template('adminboard/adminboard_inner.html',
                               servername=servername,
                               approot=approot[-2],
                               freespace=freespace,
                               users=users, ltime=ltime,
                               atime=atime,
                               contents_loop=contents_loop,
                               form=form,
                               pagination=pagination
                               )
Exemplo n.º 2
0
def show_dashboard_filenamanager():
    browser = FileBrowser()
    per_page = 9
    pages = request.args.get('page', type=int, default=1)
    paginator = Paginator()
    form = dashboard_filesform.DashboardFilesForm()
    servername = socket.gethostname()
    approot = os.path.split(app.root_path)
    users = g.user
    instance = SysInfo()
    freespace = instance.diskspace()
    ltime = instance.systime()
    atime = instance.altertime()
    f = None
    get_relpath = None

    if session['login'] != 'admin':
        flash("You don't have administrator privilegies!", 'error')
        return redirect(url_for('show_dashboard'))

    if not users and pages is None:
        abort(404)
    else:

        if exists("{}/static/get_path.tmp".format(app.root_path)) is False:
            get_relpath = "/static/images/"
        elif exists("{}/static/get_path.tmp".format(app.root_path)):
            with open("{}/static/get_path.tmp".format(app.root_path),
                      'r') as f:
                get_relpath = f.read()

        limit = per_page

        if get_relpath == '':
            get_relpath = "/static/images/"

        files = browser.show_files(get_relpath)
        offset = ((pages - 1) * per_page)
        if pages == 0 or pages == 1:
            f = files[:limit]
        elif len(files) - offset > offset:
            f = files[offset:-offset]
        elif len(files) - offset < offset:
            f = files[offset:]
        pagination = paginator.paginate(files, pages, per_page)
        return render_template('adminboard/adminboard_filemanager.html',
                               servername=servername,
                               approot=approot[-2],
                               freespace=freespace,
                               users=users,
                               ltime=ltime,
                               atime=atime,
                               files=f,
                               get_relpath=get_relpath,
                               form=form,
                               pagination=pagination)
Exemplo n.º 3
0
def show_index():
    per_page = 7
    search_limit = 4
    pages = request.args.get('page', type=int, default=1)
    form = searchform.SearchForm()
    articles = Articles.query.filter_by(article_author='admin').first()
    articles_loop = Articles.query.filter_by(
        article_category='Blender3D').all()
    contents = Content.query.filter_by(content_author='admin').all()
    c_howto = Articles.query.filter_by(article_category='HowTo').all()
    c_games = Articles.query.filter_by(article_category='Игры').all()
    c_misc = Articles.query.filter_by(article_category='разное').all()
    paginator = Paginator()
    dlogics = Dlogics()
    menu = sql.session.query(Articles).limit((per_page)).offset(
        (pages - 1) * per_page).all()

    app.jinja_env.filters['ctxt'] = dlogics.textcutn

    pagination = paginator.paginate_queries(Articles, pages, per_page)

    if request.method == 'POST' and form.validate_on_submit():

        s_menus = sql.session.query(Articles).filter(
            Articles.article_text.like("%{}%".format(
                form.query.data))).limit(search_limit).offset(
                    (pages - 1) * search_limit).all()

        if form.query.data not in s_menus:
            s_menus = sql.session.query(Articles).filter(
                Articles.article_title.like("%{}%".format(
                    form.query.data))).limit(search_limit).offset(
                        (pages - 1) * search_limit).all()

        return render_template('site/inner_search.html',
                               articles_loop=articles_loop,
                               contents=contents,
                               c_howto=c_howto,
                               c_games=c_games,
                               c_misc=c_misc,
                               menus=menus,
                               s_menus=s_menus,
                               pagination=pagination,
                               form=form)

    return render_template('site/index.html',
                           articles=articles,
                           articles_loop=articles_loop,
                           contents=contents,
                           c_howto=c_howto,
                           c_games=c_games,
                           c_misc=c_misc,
                           menu=menu,
                           pagination=pagination,
                           form=form)