Exemplo n.º 1
0
 def get(self, username):
     connected = self.get_argument('connected', None)
     if username:
         resp = Frames.get_by_username(username, connected)
     else:
         print('username missing')
         resp = {'error': 'username required'}
     _unify_ids(resp)
     self.write(dumps(resp))
Exemplo n.º 2
0
 def get(self, username=None):
     if self.current_user != username:
         self.redirect('/login')
     frames = []
     content = []
     timestamp = time.time()
     if username:
         frames = Frames.get_by_username(username, connected=True)
         content = Content.get_by_username(username)
     self.render(
         "index.html", user=username, frames=frames,
         content=content, timestamp=timestamp
     )
 def handle_admin_connected(self, admin_ws):
     """
     When a new admin connects, clean up the 'connected' statuses of
     the user's frames.
     """
     user_frames = Frames.get_by_username(admin_ws.user['username'])
     # iterate through all user's frames and update the connected flag
     for frame in user_frames:
         if frame['_id'] in self.frames:
             # the frame is connected
             if 'connected' not in frame or frame['connected'] is False:
                 # but isn't marked so in the db, set it.
                 frame = Frames.update_by_id(
                     frame['_id'], {'connected': True})
         else:
             # the frame is NOT connected
             if 'connected' not in frame or frame['connected'] is True:
                 # but is marked so in the db, set it.
                 frame = Frames.update_by_id(
                     frame['_id'], {'connected': False})