예제 #1
0
 def edit_game_image(self, id, image):
     response, content = self.login_required_file(endpoint="/game/%d/edit_image/"%id, 
                                                  file=image)
     if not response.status == 200:
         self.error_handler(content)
     print "Image sent from frontend"
     return Game.from_dict(json.loads(content))
예제 #2
0
 def edit_game_image(self, id, image):
     response, content = self.login_required_file(
         endpoint="/game/%d/edit_image/" % id, file=image)
     if not response.status == 200:
         self.error_handler(content)
     print "Image sent from frontend"
     return Game.from_dict(json.loads(content))
예제 #3
0
 def games(self,search_term):
     games_dict = dict(search_term=search_term)
     response, content = self.request(endpoint="/games/",  
                                      method="POST",
                                      body=games_dict)
     if not response.status == 200:
         self.error_handler(content)
     return [Game.from_dict(game) for game in json.loads(content).get("games")]
예제 #4
0
    def get_games(self):
        response, content = self.request(endpoint="/games/")

        if not response.status == 200:
            self.error_handler(content)
        return [
            Game.from_dict(game) for game in json.loads(content).get("games")
        ]
예제 #5
0
 def add_game(self, title, platform_id):
     game_dict = dict(title=title, platform_id=str(platform_id))
     response, content = self.login_required_request(endpoint="/game/add/", 
                                                     method="POST", 
                                                     body=game_dict)
     if not response.status == 200:
         print "/game/add/ error"
         self.error_handler(content)
     return Game.from_dict(json.loads(content))
예제 #6
0
 def add_game(self, title, platform_id):
     game_dict = dict(title=title, platform_id=str(platform_id))
     response, content = self.login_required_request(endpoint="/game/add/",
                                                     method="POST",
                                                     body=game_dict)
     if not response.status == 200:
         print "/game/add/ error"
         self.error_handler(content)
     return Game.from_dict(json.loads(content))
예제 #7
0
 def games(self, search_term):
     games_dict = dict(search_term=search_term)
     response, content = self.request(endpoint="/games/",
                                      method="POST",
                                      body=games_dict)
     if not response.status == 200:
         self.error_handler(content)
     return [
         Game.from_dict(game) for game in json.loads(content).get("games")
     ]
예제 #8
0
 def edit_game(self, id, title, platform_id, info, release_date, developer, publisher):
     # platform title developer publisher description release_date
     game_dict = dict(title=title, 
                      platform_id=platform_id, 
                      info=info, 
                      release_date=release_date, 
                      developer=developer,
                      publisher=publisher)
     response, content = self.login_required_request(endpoint="/game/%d/edit/"%id, 
                                      method="POST",
                                      body=game_dict)
     if not response.status == 200:
         self.error_handler(content)
     return Game.from_dict(json.loads(content))
예제 #9
0
 def edit_game(self, id, title, platform_id, info, release_date, developer,
               publisher):
     # platform title developer publisher description release_date
     game_dict = dict(title=title,
                      platform_id=platform_id,
                      info=info,
                      release_date=release_date,
                      developer=developer,
                      publisher=publisher)
     response, content = self.login_required_request(
         endpoint="/game/%d/edit/" % id, method="POST", body=game_dict)
     if not response.status == 200:
         self.error_handler(content)
     return Game.from_dict(json.loads(content))
예제 #10
0
 def game(self, id):
     response, content = self.request(endpoint="/game/%d/"%id)
     if not response.status == 200:
         print "/game/id/ error"
         self.error_handler(content)
     return Game.from_dict(json.loads(content))
예제 #11
0
    def get_games(self):
        response, content = self.request(endpoint="/games/")

        if not response.status == 200:
            self.error_handler(content)
        return [Game.from_dict(game) for game in json.loads(content).get("games")]
예제 #12
0
 def game(self, id):
     response, content = self.request(endpoint="/game/%d/" % id)
     if not response.status == 200:
         print "/game/id/ error"
         self.error_handler(content)
     return Game.from_dict(json.loads(content))