1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-10 04:02:17 +00:00
supysonic/api/user.py

36 lines
870 B
Python
Raw Normal View History

2012-10-14 17:04:39 +00:00
# coding: utf-8
from flask import request
from web import app
from db import User
2012-11-22 13:51:43 +00:00
@app.route('/rest/getUser.view', methods = [ 'GET', 'POST' ])
2012-10-14 17:04:39 +00:00
def user_info():
username = request.args.get('username')
if username is None:
return request.error_formatter(10, 'Missing username')
2012-10-14 17:04:39 +00:00
user = User.query.filter(User.name == username).first()
if user is None:
return request.error_formatter(0, 'Unknown user')
2012-10-14 17:04:39 +00:00
return request.formatter({
'user': {
'username': user.name,
'email': user.mail,
2012-11-23 16:13:25 +00:00
'scrobblingEnabled': user.lastfm_session is not None and user.lastfm_status,
2012-10-14 17:04:39 +00:00
'adminRole': user.admin,
'settingsRole': user.admin,
'downloadRole': True,
2012-10-14 17:04:39 +00:00
'uploadRole': False,
'playlistRole': False,
'coverArtRole': False,
'commentRole': False,
'podcastRole': False,
'streamRole': True,
2012-10-14 17:04:39 +00:00
'jukeboxRole': False,
'shareRole': False
}
})