コード例 #1
0
def account_settings_page():
    user = User.query.get(session['user']['id'])
    form = SettingsForm(name=user.name)

    return render_template("account_settings.html",
                           user=user,
                           form=form,
                           user_privs=dump_user_privileges(user))
コード例 #2
0
ファイル: admin.py プロジェクト: imbstack/partify
def make_admin_admin_form_object(user):
    user_form_obj = {}
    user_privs = dump_user_privileges(user)

    for key in privs.iterkeys():
        user_form_obj["%d_%s" % (user.id, key.lower())] = key in user_privs

    return user_form_obj
コード例 #3
0
ファイル: admin.py プロジェクト: zippyy/partify
def make_admin_admin_form_object(user):
    """Returns information about the user for use with an AdminAdminForm."""
    user_form_obj = {}
    user_privs = dump_user_privileges(user)

    for key in privs.iterkeys():
        user_form_obj["%d_%s" % (user.id, key.lower())] = key in user_privs

    return user_form_obj
コード例 #4
0
ファイル: admin.py プロジェクト: charlierm/partify
def make_admin_admin_form_object(user):
    """Returns information about the user for use with an AdminAdminForm."""
    user_form_obj = {}
    user_privs = dump_user_privileges(user)

    for key in privs.iterkeys():
        user_form_obj["%d_%s" % (user.id, key.lower())] = key in user_privs

    return user_form_obj
コード例 #5
0
ファイル: admin.py プロジェクト: imbstack/partify
def admin_console():
    user = User.query.get(session['user']['id'])

    form_object = dict( ( (k.lower(),v) for k,v in app.config.iteritems()) )

    configuration_form = ConfigurationForm(request.form, **form_object)

    admin_admin_forms = create_admin_admin_form()
    user_ids_to_names = dict( (u.id, u.name) for u in User.query.all() )

    return render_template("admin.html",
        admin_admin_forms=admin_admin_forms,
        user_ids_to_names=user_ids_to_names,
        configuration_form=configuration_form, 
        user=user, 
        user_privs=dump_user_privileges(user))
コード例 #6
0
def account_settings_update():
    user = User.query.get(session['user']['id'])
    form = SettingsForm(request.form)

    if form.validate():
        user.name = form.name.data
        if form.current_password.data != "" and form.new_password.data != "":
            if check_password_hash(user.password, form.current_password.data):
                user.password = generate_password_hash(form.new_password.data)
    else:
        return render_template("account_settings.html",
                               user=user,
                               form=form,
                               user_privs=dump_user_privileges(user))

    db.session.commit()

    return redirect(url_for('account_settings_page'))
コード例 #7
0
ファイル: admin.py プロジェクト: zippyy/partify
def admin_console():
    """Shows the admin console.
    admin.html expects a list of forms for the admin_admin functions,
    a dict of user ids and names, a configuration form, the current user,
    and the privileges a user has.
    """
    user = User.query.get(session['user']['id'])

    form_object = dict(((k.lower(), v) for k, v in app.config.iteritems()))

    configuration_form = ConfigurationForm(request.form, **form_object)

    admin_admin_forms = create_admin_admin_form()
    user_ids_to_names = dict((u.id, u.name) for u in User.query.all())

    return render_template("admin.html",
                           admin_admin_forms=admin_admin_forms,
                           user_ids_to_names=user_ids_to_names,
                           configuration_form=configuration_form,
                           user=user,
                           user_privs=dump_user_privileges(user))
コード例 #8
0
ファイル: admin.py プロジェクト: charlierm/partify
def admin_console():
    """Shows the admin console.
    admin.html expects a list of forms for the admin_admin functions,
    a dict of user ids and names, a configuration form, the current user,
    and the privileges a user has.
    """
    user = User.query.get(session['user']['id'])

    form_object = dict( ( (k.lower(),v) for k,v in app.config.iteritems()) )

    configuration_form = ConfigurationForm(request.form, **form_object)

    admin_admin_forms = create_admin_admin_form()
    user_ids_to_names = dict( (u.id, u.name) for u in User.query.all() )

    return render_template("admin.html",
        admin_admin_forms=admin_admin_forms,
        user_ids_to_names=user_ids_to_names,
        configuration_form=configuration_form, 
        user=user, 
        user_privs=dump_user_privileges(user))
コード例 #9
0
ファイル: user.py プロジェクト: charlierm/partify
def account_settings_update():
    user = User.query.get(session["user"]["id"])
    form = SettingsForm(request.form)

    if form.validate():
        user.name = form.name.data
        if form.current_password.data != "" and form.new_password.data != "":
            if check_password_hash(user.password, form.current_password.data):
                user.password = generate_password_hash(form.new_password.data)
    else:
        return render_template("account_settings.html", user=user, form=form, user_privs=dump_user_privileges(user))

    db.session.commit()

    return redirect(url_for("account_settings_page"))
コード例 #10
0
ファイル: user.py プロジェクト: charlierm/partify
def account_settings_page():
    user = User.query.get(session["user"]["id"])
    form = SettingsForm(name=user.name)

    return render_template("account_settings.html", user=user, form=form, user_privs=dump_user_privileges(user))
コード例 #11
0
ファイル: player.py プロジェクト: charlierm/partify
def player():
    """Display the player page.

    Sends the user's queue and the global queue along and displays the player page."""
    users_tracks = get_user_queue(session['user']['id'])
    global_queue = get_global_queue()

    config = {'lastfm_api_key': app.config['LASTFM_API_KEY'], 'lastfm_api_secret': app.config['LASTFM_API_SECRET']}

    user = User.query.get(session['user']['id'])

    # Do some logic to figure out if we need to show the admin console (i.e. the hostname or port for the MPD server are blank)
    if app.config['MPD_SERVER_HOSTNAME'] == "" or app.config['MPD_SERVER_PORT'] == "":
        if user_has_privilege(user, "ADMIN_INTERFACE") and user_has_privilege(user, "ADMIN_CONFIG"):
            return redirect(url_for("admin_console"))

    return render_template("player.html", user=user, user_play_queue=users_tracks, global_play_queue=global_queue, config=config, voting_enabled=needs_voting[app.config['SELECTION_SCHEME']], user_privs=dump_user_privileges(user))
コード例 #12
0
ファイル: priv_test.py プロジェクト: charlierm/partify
    def test_dump_user_privileges(self):
        assert dump_user_privileges(self.user) == []

        give_user_privilege(self.user, "ADMIN_INTERFACE")
        assert "ADMIN_INTERFACE" in dump_user_privileges(self.user)
コード例 #13
0
ファイル: priv_test.py プロジェクト: zippyy/partify
    def test_dump_user_privileges(self):
        assert dump_user_privileges(self.user) == []

        give_user_privilege(self.user, "ADMIN_INTERFACE")
        assert "ADMIN_INTERFACE" in dump_user_privileges(self.user)