コード例 #1
0
ファイル: contents.py プロジェクト: koalalorenzo/OpenProfile
def page(page_url):
    """Generic Page View"""
    profile = Profile()
    profile.database = db
    profile.load_admin()
    
    page = Page("/%s" % page_url)
    page.database = db
    try:
        page.load()
    except PageNotFound:
        abort(404)
    html = markdown.markdown(page.content)
    
    return render_template('page.html', page=page, html=html, profile=profile)
コード例 #2
0
ファイル: contents.py プロジェクト: koalalorenzo/OpenProfile
def index():
    """Home page of the profile"""
    profile = Profile()
    profile.database = db
    try:
        profile.load_admin()
    except AdminNotFound:
        return redirect(url_for("installation_index"))
    page = Page("/")
    page.database = db
    try:
        page.load()
    except PageNotFound:
        abort(500)
    html = markdown.markdown(page.content)
    return render_template('homepage.html', html=html, profile=profile)
コード例 #3
0
ファイル: api.py プロジェクト: koalalorenzo/OpenProfile
def api_show_profile(userhash=None):
    """
        Returns the openprofile in json format: used by other installations
        it contains also the key (or a sort of ) to verify messages. If the key change,
        the owner must re-authorize the other friend.
    """
    profile = Profile()
    profile.database = db
    if not userhash:
        profile.load_admin()
    else:
        profile.userhash = userhash
        profile.load()
    jsoned = profile.__dict__()
    del jsoned['is_admin']
    return json.dumps(jsoned)
コード例 #4
0
ファイル: auth.py プロジェクト: koalalorenzo/OpenProfile
def login():
    next = request.args.get('next', '/admin', type=str)
    if 'auth' in session:
        return redirect(next)
        
    if request.method == 'POST':
        try:
            username = request.form['username']
            password = request.form['password']
        except KeyError:
            flash(u"Invalid Username or Password", "error")
            return render_template("auth/login.html", next=next)
            
        profile = Profile()
        profile.database = db
        profile.load_admin()
            
        if profile.verify_login(username, password):
            flash(u"Welcome back %s" % profile.username, "info" )
            session['auth'] = profile.userhash
            return redirect(next)
        else:
            flash(u"Invalid Username or Password", "error")
    return render_template("auth/login.html", next=next)