2012-10-14 17:04:39 +00:00
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
from flask import request
|
|
|
|
from web import app
|
|
|
|
from db import User
|
|
|
|
|
|
|
|
@app.route('/rest/getUser.view')
|
|
|
|
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,
|
|
|
|
'scrobblingEnabled': False,
|
|
|
|
'adminRole': user.admin,
|
|
|
|
'settingsRole': False,
|
|
|
|
'downloadRole': False,
|
|
|
|
'uploadRole': False,
|
|
|
|
'playlistRole': False,
|
|
|
|
'coverArtRole': False,
|
|
|
|
'commentRole': False,
|
|
|
|
'podcastRole': False,
|
|
|
|
'streamRole': False,
|
|
|
|
'jukeboxRole': False,
|
|
|
|
'shareRole': False
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|