def __init__(self): super(EditLoadoutController, self).__init__() self.username = auth_tests.get_auth() logging.debug("post get_auth") player = auth_tests.get_player_info(self.username) self.level = player.player_level self.mmr = player.mmr self.active_loadout = db_loadout.get_by_id(player.loadout_id) logging.debug(self.active_loadout.id) self.loadout_id = krait.request.query.get("loadout_id") if self.loadout_id == "new": self.loadout_id = db_loadout.create(self.username) else: self.loadout_id = int(self.loadout_id) logging.debug("checking owner") if not db_loadout.check_owner(self.loadout_id, self.username): raise RuntimeError("Not your loadout!") logging.debug("checked owner") self.current_loadout_name = db_loadout.get_by_id(self.loadout_id).name
def update(troop_obj): conn = db_ops.get_connection() cursor = conn.cursor() cursor.execute("select * from troop m " "where m.id = :troop_id", {"troop_id": troop_obj.id}) temp_data = cursor.fetchone() cursor.close() if temp_data is not None: troop_id, class_id, loadout_id, skin_id = temp_data else: return if troop_obj.class_id != class_id: troop_obj.class_id = class_id if troop_obj.troop_class is not None: troop_obj.troop_class = db_troop_class.get_by_id(class_id) if troop_obj.skin_id != skin_id: troop_obj.skin_id = skin_id if troop_obj.skin is not None: troop_obj.skin = db_skin.get_by_id(skin_id) if troop_obj.loadout_id != loadout_id: troop_obj.loadout_id = loadout_id if troop_obj.loadout is not None: troop_obj.loadout = db_loadout.get_by_id(loadout_id)
def __init__(self): self.username = auth_tests.get_auth() player = auth_tests.get_player_info(self.username) self.level = player.player_level self.mmr = player.mmr self.active_loadout = db_loadout.get_by_id(player.loadout_id)
def __init__(self): self.username = auth_tests.get_auth() self.loadout_owner = str(krait.request.query.get("which")) player = db_player.get_by_username(self.username) if self.loadout_owner == "mine": self.loadout = self.get_in_out_format( db_loadout.get_by_id(player.loadout_id)) else: match = db_match.get_by_player(player) if player.id == match.player1_id: opponent = db_player.get_by_id(match.player2_id) else: opponent = db_player.get_by_id(match.player1_id) self.loadout = self.get_in_out_format( db_loadout.get_by_id(opponent.loadout_id))
def __init__(self): self.username = auth_tests.get_auth() self.loadout_id = int(krait.request.query.get("id")) if not db_loadout.check_owner(self.loadout_id, self.username): krait.response = krait.ResponseBadRequest() logging.debug("---------------" + str(self.loadout_id)) self.loadout = self.get_in_out_format(db_loadout.get_by_id(self.loadout_id))
def __init__(self): self.username = auth_tests.get_auth() self.player = auth_tests.get_player_info(self.username) self.level = self.player.player_level self.mmr = self.player.mmr logging.debug("player loadout id: {}".format(self.player.loadout_id)) self.active_loadout = db_loadout.get_by_id(self.player.loadout_id) logging.debug(self.active_loadout.id) self.user_loadouts = db_loadout.get_all_by_id(self.player.id) logging.debug(str(self.user_loadouts[0].name)) self.new_loadout_id = 0
def get_response(): post_form = krait.request.get_post_form() new_name = post_form.get("playername") loadout_id = post_form.get("loadout_id") if new_name is "" or loadout_id is None or new_name is None: return krait.ResponseRedirect( "/edit_loadout?loadout_id={}".format(loadout_id)) logging.debug(new_name) new_name = str(new_name).strip() db_loadout.update_name(db_loadout.get_by_id(loadout_id, True), new_name) return krait.ResponseRedirect( "/edit_loadout?loadout_id={}".format(loadout_id))
def populate(troop_obj): #logging.debug("populating troop: class") if troop_obj.troop_class is None: troop_obj.troop_class = db_troop_class.get_by_id(troop_obj.class_id) #logging.debug(", skin") if troop_obj.skin is None: troop_obj.skin = db_skin.get_by_id(troop_obj.skin_id) #logging.debug(", loadout") if troop_obj.loadout is None: troop_obj.loadout = db_loadout.get_by_id(troop_obj.loadout_id, skip_update=True) troop_obj.loadout.populate() #logging.debug(", modifiers") if troop_obj.modifiers is None: update_modifiers(troop_obj)