예제 #1
0
 def GET(self):
   
   rdio, currentUser = get_rdio_and_current_user()
   
   if rdio and currentUser:
     user_id = int(currentUser['key'][1:])
     
     myPlaylists = rdio.call('getPlaylists')['result']['owned']
     
     db = get_db()
     
     result = list(db.select('discoversong_user', what='address, playlist', where="rdio_user_id=%i" % user_id))
     if len(result) == 0:
       access_token = web.cookies().get('at')
       access_token_secret = web.cookies().get('ats')
       db.insert('discoversong_user', rdio_user_id=user_id, address=make_unique_email(currentUser), token=access_token, secret=access_token_secret, playlist='new')
       result = list(db.select('discoversong_user', what='address, playlist', where="rdio_user_id=%i" % user_id))[0]
     else:
       result = result[0]
     
     message = ''
     if 'saved' in get_input():
       message = '  Saved your selections.'
     
     return render.loggedin(name=currentUser['firstName'],
                            message=message,
                            to_address=result['address'],
                            editform=editform(myPlaylists, result['playlist'])
                           )
   else:
     return render.loggedout()
예제 #2
0
파일: app.py 프로젝트: eae/discoversong
 def GET(self):
   rdio, current_user, user_id = get_rdio_and_current_user()
   disco_user, prefs = get_discoversong_user(user_id)
   # circular import
   from discoversong.sources import SourceAppsManager
   
   return render.config(params=Params(user=disco_user, preferences=prefs, message="", environment_message=get_environment_message()),
                        capabilities=SourceAppsManager.all_capabilities(),
                        editform=editform(playlists=rdio.call('getPlaylists')['result']['owned'], prefs=get_db_prefs(user_id)))
예제 #3
0
 def GET(self):
   rdio, currentUser, user_id = get_rdio_and_current_user()
   disco_user, message = get_discoversong_user(user_id)
   prefs = BSONPostgresSerializer.to_dict(disco_user['prefs'])
   # circular import
   from discoversong.sources import SourceAppsManager
   
   return render.config(user=disco_user,
                        prefs=prefs,
                        capabilities=SourceAppsManager.all_capabilities(),
                        editform=editform(playlists=rdio.call('getPlaylists')['result']['owned'], prefs=get_db_prefs(user_id)),
                        env_message=get_environment_message(),
                        message=message)