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 )
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)
def show_dashboard(): if not current_user.is_authenticated: return current_app.login_manager.unauthorized() else: servername = socket.gethostname() approot = os.path.split(app.root_path) users = g.user instance = SysInfo() freespace = instance.diskspace() ltime = instance.systime() atime = instance.altertime() flash('Welcome, ' + users, 'info') return render_template('adminboard/adminboard.html', servername=servername, approot=approot[-2], freespace=freespace, users=users, ltime=ltime, atime=atime)