コード例 #1
0
ファイル: controllers.py プロジェクト: cyang/crowd-navigation
 def __init__(self, request):
     user = users.get_current_user()
     room_key = request.get('room_id')
     if not room_key:
         room_key = request.get('g') #TODO - Remove with old page
     if user and room_key:
         self.room = Room.get_by_key_name(room_key)
コード例 #2
0
ファイル: controllers.py プロジェクト: cyang/crowd-navigation
    def get(self):
        user = users.get_current_user()

        if user:
            room_key = self.request.get('g')
            if not room_key:
                room_key = user.user_id()
                room = Room(key_name = room_key,
                            current_user = user)
                room.put()
            else:
                if room_key == "vr":
                    self.redirect("/vr-room")
                    return
                if room_key == "demo":
                    self.redirect("/demo")
                    return
                room = Room.get_by_key_name(room_key)

            if room:
                #Check if the crowdee already exists for this user and room.
                crowdeeQuery = Crowdee.all()
                crowdeeQuery.filter("user ="******"room =", room_key)
                crowdee = crowdeeQuery.get()
                #If the crowdee doesn't exist...
                if not crowdee:
                    #Create the crowdee for the user and room.
                    crowdee = Crowdee(user = user,
                                      room = room_key,
                                      channel = room_key + "_" + user.user_id(),
                                      direction = "None",
                                      weight = 1)
                    crowdee.put()
                
                token = channel.create_channel(room_key + "_" + user.user_id())
                template_values = {'token': token,
                                   'current_user_id': user.user_id(),
                                   'room_key': room_key,
                                   'weight': 1,
                                   'initial_message': RoomUpdater(room).get_room_message()
                                   }
                #Add tokbox tokens if they exist.
                if room.session_id:
                    template_values.update({'tokbox_api_key': tokbox_api_key,
                                            'tokbox_session_id': room.session_id,
                                            'tokbox_token': room.sub_token
                                           })
                template = jinja_environment.get_template('nav-room-base.html')
                self.response.out.write(template.render(template_values))
            else:
                self.response.out.write('No such room')
        else:
            self.redirect(users.create_login_url(self.request.uri))
コード例 #3
0
ファイル: controllers.py プロジェクト: cyang/crowd-navigation
 def post(self):
     channel_token = self.request.get('from')
     user_crowd = Crowdee.all().filter("channel =", channel_token)
     #Although there should only be one user, it will still be received as a list.
     for user_crowdee in user_crowd:
         room = Room.get_by_key_name(user_crowdee.room)
         user_id = user_crowdee.user.user_id()
         user_crowdee.delete()
         if room:
             RoomUpdater(room).delete_move(user_id)
     room_list = Room.all()
     for room in room_list:
         if room.key().name() == channel_token:
             room.active = False
             room.put()
コード例 #4
0
ファイル: controllers.py プロジェクト: cyang/crowd-navigation
    def put(self):
        """Used by the crowdee to enter the existing room information."""
        user = users.get_current_user()

        if not user:
            #Handle the user not being logged in. TODO
            return
        
        #Get the room.
        room_key = self.request.get('room_id')
        room = Room.get_by_key_name(room_key)

        if not room:
            #Handle the room not existing.
            return
        
        #Check if the crowdee already exists for this user and room.
        crowdeeQuery = Crowdee.all()
        crowdeeQuery.filter("user ="******"room =", room_key)
        crowdee = crowdeeQuery.get()
        #If the crowdee doesn't exist...
        if not crowdee:
            #Create the crowdee for the user and room.
            crowdee = Crowdee(user = user,
                              room = room_key,
                              channel = room_key + "_" + user.user_id(),
                              direction = "None",
                              weight = 1)
            crowdee.put()
        
        token = channel.create_channel(room_key + "_" + user.user_id())
        
        #Compile the crowdee data.
        crowdee_data = {
                        'channel_token': token,
                        'user_id': user.user_id(),
                        'user_name': user.nickname(),
                        'room_key': room_key,
                        'user_weight': 1,
                        'tokbox_api_key': tokbox_api_key,
                        'tokbox_session_id': room.session_id,
                        'tokbox_token': room.sub_token,
                       }
        
        #Respond with the json.
        self.response.out.write(json.dumps(crowdee_data))
コード例 #5
0
ファイル: controllers.py プロジェクト: cyang/crowd-navigation
    def get(self):
        user = users.get_current_user()
        
        if user:
            room_key = "demo"
            room = Room.get_by_key_name(room_key)
            if not room:
                room = Room(key_name = room_key,
                            current_user = user)
                room.put()

            #Check if the crowdee already exists for this user and room.
            crowdeeQuery = Crowdee.all()
            crowdeeQuery.filter("user ="******"room =", room_key)
            crowdee = crowdeeQuery.get()
            #If the crowdee doesn't exist...
            if not crowdee:
                #Create the crowdee for the user and room.
                crowdee = Crowdee(user = user,
                                  room = room_key,
                                  channel = room_key + "_" + user.user_id(),
                                  direction = "None",
                                  weight = 1)
                crowdee.put()
            
            token = channel.create_channel(room_key + "_" + user.user_id())
            template_values = {'token': token,
                               'current_user_id': user.user_id(),
                               'room_key': room_key,
                               'weight': 1,
                               'initial_message': RoomUpdater(room).get_room_message()
                               }
            template = jinja_environment.get_template('demo-room.html')
            self.response.out.write(template.render(template_values))
        else:
            self.redirect(users.create_login_url(self.request.uri))
コード例 #6
0
ファイル: controllers.py プロジェクト: cyang/crowd-navigation
 def get(self):
     room = Room.get_by_key_name("demo")
     direction = "None"
     if(room.direction):
         direction = room.direction
     self.response.out.write(direction)