def post(self): request_data = json.loads(self.request.body) logging.info(request_data) team_owner = current_user_player() application = TeamApplication.get_by_id(int(request_data['application_id'])) team = application.team.get() # VALIDATIONS if not validate_is_team_owner(self.response, team_owner, team): return # DO SHIT applicant = application.player.get() applicant.team = application.team applicant.put() application.key.delete() _websocket_notify_team("Team_NewMember", team.key, "player.team.members.[%s]" % applicant.key.id(), applicant.get_data_nick_and_id()) # Because how this transaction work, we manualy add the player itself as a member of the team team_data = team.get_data("full") team_data['members'].append(applicant.get_data_nick_and_id()) websocket_notify_player("Player_TeamApplicationAccepted", applicant.key, "player", {'team': team_data}) set_json_response(self.response, {'code': "OK"})
def post(self): request_data = json.loads(self.request.body) logging.info(request_data) player = current_user_player() application = TeamApplication.get_by_id(int(request_data['application_id'])) team = application.team.get() # VALIDATIONS if not validate_is_team_owner(self.response, player, team): return # DO SHIT application.key.delete() _websocket_notify_team("Team_ApplicationDeclined", team.key, "player.team.applications.-[%s]" % application.key.id(), application.get_data()) set_json_response(self.response, {'code': "OK"})
def post(self): request_data = json.loads(self.request.body) logging.info(request_data) player = current_user_player() team_key = ndb.Key(Team, int(request_data['team_id'])) # VALIDATIONS if not validate_request_data(self.response, request_data, ['team_id']): return elif not validate_logged_inn(self.response): return elif not _validate_has_no_team(self.response, player): return team_application = TeamApplication( team=team_key, player=player.key, text=request_data['text'] ).put().get() _websocket_notify_team('Team_NewApplication', team_key, "player.team.applications.[%s]" % team_application.key.id(), team_application.get_data()) set_json_response(self.response, {'code': "OK"})