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:
|
2012-10-20 18:23:38 +00:00
|
|
|
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:
|
2012-10-20 18:23:38 +00:00
|
|
|
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,
|
2013-06-13 16:17:33 +00:00
|
|
|
'settingsRole': user.admin,
|
|
|
|
'downloadRole': True,
|
2012-10-14 17:04:39 +00:00
|
|
|
'uploadRole': False,
|
|
|
|
'playlistRole': False,
|
|
|
|
'coverArtRole': False,
|
|
|
|
'commentRole': False,
|
|
|
|
'podcastRole': False,
|
2012-11-10 22:02:30 +00:00
|
|
|
'streamRole': True,
|
2012-10-14 17:04:39 +00:00
|
|
|
'jukeboxRole': False,
|
|
|
|
'shareRole': False
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|