Beispiel #1
0
def before_request():
    g.navbar = navbar

    if current_user.is_anonymous():
        endpoint = request.endpoint
        if endpoint and endpoint.split('.')[-1] in ('new', 'edit', 'delete', 'upload'):
            return redirect(url_for('common.login', next=request.url))
Beispiel #2
0
def ajax_execute():
    if current_user.is_anonymous():
        return "Hey, It's is private!"
    command = request.form.get('command', 'None')
    from commands import getstatusoutput
    status, output = getstatusoutput(command)
    output = u'$ %s\n========================================\n%s' % (command, utf8(output))
    if status == 0:
        return output
    else:
        return '[Bad Command: %s]' % command
Beispiel #3
0
def index():
    perpage = current_app.config['GALLERY_PERPAGE']
    page = request.args.get('page', 1, type=int)
    key = request.args.get('key', '')
    base_query = Image.query
    if current_user.is_anonymous():
        base_query = base_query.filter(Image.public==1)
    query = base_query
    if key:
        ikey = '%' + key + '%'
        query = query.filter(db.or_(Image.source_name.ilike(ikey),
                                    Image.title.ilike(ikey),
                                    Image.tag.ilike(ikey)))
    query = query.order_by(Image.create_at.desc())
    page_obj = query.paginate(page=page, per_page=perpage)
    page_url = lambda page : url_for('gallery.index', page=page)
    recents = base_query.order_by(Image.create_at.desc()).offset(0).limit(perpage)
    kwargs = {
        'key'     : key,
        'page_obj': page_obj,
        'page_url': page_url,
        'recents' : recents
    }
    return render_template('gallery/index.html', **kwargs)
Beispiel #4
0
def index():
    if current_user.is_anonymous():
        return "Hey, It's is private!"
    return render_template('vps/index.html')
Beispiel #5
0
 def inject_vars():
     vars = {
         'islogin' : not current_user.is_anonymous()
     }
     return vars