Beispiel #1
0
  def GET(self):
    
    rdio, current_user, user_id = get_rdio_and_current_user()
    
    if rdio and current_user:
      if user_id in config.ADMIN_USERS:
        form_input = get_input()
        
        if 'button' in form_input.keys():
          action = form_input['button']
          db = get_db()
          
          if action == 'doitnow_go_on_killme':
            if user_id in config.ADMIN_USERS:
              db.delete(USER_TABLE, where="rdio_user_id=%i" % user_id)
            raise web.seeother('/')

          elif action == 'clear_preferences':
            if user_id in config.ADMIN_USERS:
              db.update(USER_TABLE, where="rdio_user_id=%i" % user_id, prefs=BSONPostgresSerializer.from_dict({}))
          
            raise web.seeother('/admin')
        
        else:
          content=get_admin_content()
          db = get_db()
          users = db.select(USER_TABLE, what='rdio_user_id, last_use')
          users = dict([('s%s' % u['rdio_user_id'], u['last_use']) for u in users])
          rdio_users = rdio.call('get', {'keys': ','.join(users.keys()), 'extras': '-*,username,url'})['result']
          user_list = [(u['username'], u['url'], users[uid]) for uid, u in rdio_users.items()]
          user_list.sort(key=lambda x: x[2], reverse=True)
          return render.admin(env_message=get_environment_message(), admin=content, users=user_list)
      
    raise web.seeother('/')
Beispiel #2
0
  def GET(self):
    
    rdio, currentUser, user_id = get_rdio_and_current_user()
    
    if rdio and currentUser:
      if user_id in config.ADMIN_USERS:
        input = get_input()
        
        if 'button' in input.keys():
          action = input['button']
          db = get_db()
          
          if action == 'doitnow_go_on_killme':
            if user_id in config.ADMIN_USERS:
              db.delete(USER_TABLE, where="rdio_user_id=%i" % user_id)
            raise web.seeother('/')

          elif action == 'clear_preferences':
            if user_id in config.ADMIN_USERS:
              db.update(USER_TABLE, where="rdio_user_id=%i" % user_id, prefs=BSONPostgresSerializer.from_dict({}))
          
            raise web.seeother('/admin')
        
        else:
          admin=get_admin_content()
          return render.admin(env_message=get_environment_message(), admin=admin)
      
    raise web.seeother('/')