示例#1
0
文件: admin.py 项目: nikhilm/muzicast
def index():
    # if it's the first run, we allow in
    # otherwise we ask for the password
    if is_first_run():
        identity_changed.send(admin, identity=Identity('admin'))

    try:
        admin_permission.test()
        return render_template('admin/index.html', first_run=is_first_run())
    except PermissionDenied:
        return redirect(url_for('login'))
示例#2
0
文件: admin.py 项目: nikhilm/muzicast
def login():
    if is_first_run():
        return redirect(url_for('index'))

    wrong = False
    if request.method == 'POST':
        input = sha256(request.form['password']).hexdigest()
        config = GlobalConfig()
        if 'password' not in config:
            wrong = True
        elif input == config['password']:
            session['admin'] = True
            identity_changed.send(admin, identity=Identity('admin'))
            return redirect(url_for('index'))
        else:
            wrong = True
    return render_template('admin/admin_login.html', wrong=wrong)
示例#3
0
from muzicast.const import USERDIR
from muzicast.meta import init_meta
from muzicast.web.util import is_first_run

app = Flask(__name__)

@app.errorhandler(404)
def page_not_found(error):
    return render_template('404.html')

def redirect_firstrun():
    if request.path != '/firstrun' and not request.path.startswith('/static/') and not request.path == '/favicon.ico':
        return redirect('/firstrun')

if is_first_run():
    app.before_request(redirect_firstrun)

from muzicast.web.admin import admin
app.register_module(admin, url_prefix='/admin')

from muzicast.web.artist import artist
app.register_module(artist, url_prefix='/artist')
from muzicast.web.album import album
app.register_module(album, url_prefix='/album')
from muzicast.web.track import track
app.register_module(track, url_prefix='/track')
from muzicast.web.genre import genre
app.register_module(genre, url_prefix='/genre')
from muzicast.web.user import user
app.register_module(user, url_prefix='/user')
示例#4
0
文件: main.py 项目: nikhilm/muzicast
def index():
    #just do first run check
    if is_first_run():
        return redirect(url_for('admin.index'))

    return render_master_page('home.html', title='Muzicast', top_tracks=top_tracks, recently_played=recently_played)