Ejemplo n.º 1
0
def entry_posting_page():
    if request.method == 'GET':
        g.active = {'post': True}
        return render_template('admin/entry_post_page.html')
    else:
        user_name = request.form.get('user_name', '').strip()
        title = request.form.get('title', '').strip()
        subtitle = request.form.get('subtitle', '').strip()
        body = request.form.get('body', '').strip()
        extend = request.form.get('extend', '').strip()
        s_tags = request.form.get('tags', '').strip()

        if body:
            user = User.get_by_name(user_name)

            entry = Entry(author_id = user.id if user else g.login_user.id,
                          body = body,
                          title = title,
                          subtitle = subtitle,
                          extend = extend).save(clear_cache = False)
            entry.previous_entry.clear_memcache()
            labels = set([tag.strip() for tag in s_tags.split(',')])
            for label in labels:
                Tag(entry.id, label).save(clear_cache = False)

            return redirect(url_for('entry_editing_page', entry_id = entry.id))
        else:
            return abort(400)
Ejemplo n.º 2
0
def check_login_user():
    g.login_user = None

    if 'user_name' in session:
        login_user = User.get_by_name(session['user_name'])
        if login_user:
            g.login_user = login_user
        else:
            session.pop('username', None)
Ejemplo n.º 3
0
Archivo: user.py Proyecto: setomits/mow
def login_page():
    error = None

    if request.method == 'POST':
        _user_name = request.form.get('user_name', '').strip()
        _password = request.form.get('password', '').strip()
        _next_url = request.form.get('next_url', url_for('top_page'))

        if _user_name and _password:
            user = User.get_by_name(_user_name)
            if user:
                if User.make_hash(_password) == user.password_hash:
                    session['user_name'] = user.name
                    return redirect(_next_url)
        return abort(403)
    else:
        _next_url = request.args.get('next_url', url_for('top_page'))
        return render_template('login.html', next_url = _next_url)