mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-23 01:16:18 +00:00
Handle client prefs changes
This commit is contained in:
parent
7947b55297
commit
4beb2d6774
@ -19,8 +19,11 @@
|
|||||||
<li><a href="{{ url_for('change_password') }}">Change password</a></li>
|
<li><a href="{{ url_for('change_password') }}">Change password</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% if clients %}
|
{% if clients.count() %}
|
||||||
<h2>Known streaming clients</h2>
|
<h2>Clients</h2>
|
||||||
|
<p>Here's a list of clients you used to stream music. If you want to use transcoding or downsampling with one of them (for instance using a low bitrate on
|
||||||
|
mobile connections to reduce used bandwidth), but the client doesn't provide options to do so, you can set default values here. They'll only be used if no
|
||||||
|
transcoding/downsampling is requested by the client.</p>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<table>
|
<table>
|
||||||
<tr><th>Client</th><th>Format</th><th>Max bitrate</th><th>Forget</th></tr>
|
<tr><th>Client</th><th>Format</th><th>Max bitrate</th><th>Forget</th></tr>
|
||||||
|
20
user.py
20
user.py
@ -26,6 +26,26 @@ def user_profile():
|
|||||||
prefs = ClientPrefs.query.filter(ClientPrefs.user_id == uuid.UUID(session.get('userid')))
|
prefs = ClientPrefs.query.filter(ClientPrefs.user_id == uuid.UUID(session.get('userid')))
|
||||||
return render_template('profile.html', user = UserManager.get(session.get('userid'))[1], api_key = config.get('lastfm', 'api_key'), clients = prefs)
|
return render_template('profile.html', user = UserManager.get(session.get('userid'))[1], api_key = config.get('lastfm', 'api_key'), clients = prefs)
|
||||||
|
|
||||||
|
@app.route('/user/me', methods = [ 'POST' ])
|
||||||
|
def update_clients():
|
||||||
|
clients_opts = {}
|
||||||
|
for client in set(map(lambda k: k.rsplit('_', 1)[0],request.form.keys())):
|
||||||
|
clients_opts[client] = { k.rsplit('_', 1)[1]: v for k, v in filter(lambda (k, v): k.startswith(client), request.form.iteritems()) }
|
||||||
|
app.logger.debug(clients_opts)
|
||||||
|
|
||||||
|
for client, opts in clients_opts.iteritems():
|
||||||
|
prefs = ClientPrefs.query.get((uuid.UUID(session.get('userid')), client))
|
||||||
|
if 'delete' in opts and opts['delete'] in [ 'on', 'true', 'checked', 'selected', '1' ]:
|
||||||
|
db_sess.delete(prefs)
|
||||||
|
continue
|
||||||
|
|
||||||
|
prefs.format = opts['format'] if 'format' in opts and opts['format'] else None
|
||||||
|
prefs.bitrate = int(opts['bitrate']) if 'bitrate' in opts and opts['bitrate'] else None
|
||||||
|
|
||||||
|
db_sess.commit()
|
||||||
|
flash('Clients preferences updated.')
|
||||||
|
return user_profile()
|
||||||
|
|
||||||
@app.route('/user/changemail', methods = [ 'GET', 'POST' ])
|
@app.route('/user/changemail', methods = [ 'GET', 'POST' ])
|
||||||
def change_mail():
|
def change_mail():
|
||||||
user = UserManager.get(session.get('userid'))[1]
|
user = UserManager.get(session.get('userid'))[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user