def run_alliance_corp_update(): # I am not proud of this block of code if EveApiManager.check_if_api_server_online(): characters = EveCharacter.query.order_by( EveCharacter.character_id).all() for character in characters: if not EveCorporationInfo.query.filter_by( corporation_id=character.corporation_id).first(): corpinfo = EveApiManager.get_corporation_information( character.corporation_id) if corpinfo: # print corpinfo EveManager.create_corporation_info( corporation_id=corpinfo['id'], corp_name=corpinfo['name'], corp_ticker=corpinfo['ticker'], corp_member_count=corpinfo['members']['current'], alliance_id=corpinfo['alliance']['id']) if int(character.alliance_id) != 0: if not EveAllianceInfo.query.filter_by( alliance_id=character.alliance_id).first(): print character.alliance_id allianceinfo = EveApiManager.get_alliance_information( character.alliance_id) if allianceinfo: # print allianceinfo EveManager.create_alliance_info( alliance_id=allianceinfo['id'], alliance_name=allianceinfo['name'], alliance_ticker=allianceinfo['ticker'], alliance_executor_corp_id=allianceinfo[ 'executor_id'], alliance_member_count=allianceinfo['member_count'])
def api_delete(api_id): # Check if our users main id is in the to be deleted characters characters = EveManager.get_characters_by_owner(current_user) if characters is not None: for character in characters: if character.api_id == api_id and character.character_id == current_user.main_character_id: # TODO disable services and such pass EveManager.delete_api_key_pair(api_id, current_user) return redirect(url_for('user.api_manage'))
def api_delete(api_id): # Check if our users main id is in the to be deleted characters characters = EveManager.get_characters_by_owner(current_user) if characters is not None: for character in characters: if character.character_id == current_user.auth_info[0].main_character_id: if character.api_id == api_id: # TODO disable services and such pass EveManager.delete_characters_by_api_id_user(api_id, current_user) EveManager.delete_api_key_pair(api_id, current_user) return redirect(url_for('user.api_manage'))
def run_api_key_update(): with current_app.app_context(): # I am not proud of this block of code if EveApiManager.check_if_api_server_online(): api_keys = EveApiKeyPair.query.order_by(EveApiKeyPair.api_id).all() for api_key in api_keys: if EveApiManager.check_api_is_not_expire( api_key.api_id, api_key.api_key): EveManager.update_api_keypair(api_key.api_id, api_key.api_key) current_app.logger.debug("Updating {0}".format( api_key.api_id)) else: current_app.logger.debug( "Removing expired api_key {0} {1}".format( api_key.api_id, api_key.api_key)) EveManager.delete_api_key_pair(api_key.api_id, None)
def eve_main_character_change(character_id): if EveManager.check_if_character_owned_by_user(character_id, current_user.get_id()): AuthInfoManager.update_main_character_id(character_id, current_user) return redirect(url_for('user.eve_characters')) return redirect(url_for('user.eve_characters'))
def api_update(api_id): # Break out application logic from the view to the manager update = EveManager.update_user_api(api_id, current_user) if update == "Wait": flash(u'Please wait before refreshing your api', category='message') elif update == "Success": flash(u'API key Refreshed', category='message') return redirect(url_for('user.api_manage'))
def api_update(api_id): # Break out application logic from the view to the manager update = EveManager.update_user_api(api_id, current_user) if update == "Wait": flash(u'Please wait before refreshing your api', category='message') elif update == "Success": flash(u'API key Refreshed', category='message') elif update == "Failed": flash(u'Error updating API key! Either your key is invalid or the CCP servers are temporarily down.', category='error') return redirect(url_for('user.api_manage'))
def api_add(): form = UpdateKeyForm() if form.validate_on_submit(): characters = EveApiManager.get_characters_from_api( form.data['api_id'], form.data['api_key']) if EveManager.create_api_keypair(form.data['api_id'], form.data['api_key'], current_user.get_id()): EveManager.create_alliances_from_list(characters) EveManager.create_corporations_from_character_list(characters) character_creation = EveManager.create_characters_from_list( characters, current_user, form.data['api_id']) if character_creation: flash(character_creation, category="message") # else: # flash("Character error, RIP. (contact IT)", category="message") else: flash("API Key already in use", category='message') return render_template("users/api_add.html", form=form) return redirect(url_for('user.api_manage')) else: return render_template("users/api_add.html", form=form)
def api_add(): form = UpdateKeyForm() if form.validate_on_submit(): characters = EveApiManager.get_characters_from_api(form.data['api_id'], form.data['api_key']) if EveManager.create_api_keypair(form.data['api_id'], form.data['api_key'], current_user.get_id()): EveManager.create_alliances_from_list(characters) EveManager.create_corporations_from_character_list(characters) character_creation = EveManager.create_characters_from_list(characters, current_user, form.data['api_id']) if character_creation: flash(character_creation, category="message") # else: # flash("Character error, RIP. (contact IT)", category="message") else: flash("API Key already in use", category='message') return render_template("users/api_add.html", form=form) return redirect(url_for('user.api_manage')) else: return render_template("users/api_add.html", form=form)
def run_alliance_corp_update(): with current_app.app_context(): if EveApiManager.check_if_api_server_online(): corporations = EveCorporationInfo.query.all() for corp in corporations: corp_info = EveApiManager.get_corporation_information( corp.corporation_id) if corp_info: # Set alliance info first to set foreign key if corp_info['alliance']['id']: alliance_info = EveApiManager.get_alliance_information( corp_info['alliance']['id']) if alliance_info: if not EveAllianceInfo.query.filter_by( alliance_id=str( alliance_info['id'])).first(): EveManager.create_alliance_info( alliance_id=alliance_info['id'], alliance_name=alliance_info['name'], alliance_ticker=alliance_info['ticker'], alliance_executor_corp_id=alliance_info[ 'executor_id'], alliance_member_count=alliance_info[ 'member_count']) else: EveManager.update_alliance_info( alliance_id=alliance_info['id'], alliance_executor_corp_id=alliance_info[ 'executor_id'], alliance_member_count=alliance_info[ 'member_count']) EveManager.update_corporation_info( corporation_id=corp_info['id'], corp_member_count=corp_info['members']['current'], alliance_id=corp_info['alliance']['id'])
def run_api_key_update(): with current_app.app_context(): # I am not proud of this block of code if EveApiManager.check_if_api_server_online(): api_keys = EveApiKeyPair.query.order_by(EveApiKeyPair.api_id).all() for api_key in api_keys: if not EveApiManager.check_api_is_type_account(api_key.api_id, api_key.api_key): EveManager.delete_characters_by_api_id(api_key.api_id) if not EveApiManager.check_api_is_full(api_key.api_id, api_key.api_key): EveManager.delete_characters_by_api_id(api_key.api_id) if not EveApiManager.check_api_is_not_expire(api_key.api_id, api_key.api_key): EveManager.delete_characters_by_api_id(api_key.api_id) EveManager.update_api_keypair(api_key.api_id, api_key.api_key)
def run_api_key_update(): with current_app.app_context(): # I am not proud of this block of code if EveApiManager.check_if_api_server_online(): api_keys = EveApiKeyPair.query.order_by(EveApiKeyPair.api_id).all() for api_key in api_keys: if not EveApiManager.check_api_is_type_account( api_key.api_id, api_key.api_key): EveManager.delete_characters_by_api_id(api_key.api_id) if not EveApiManager.check_api_is_full(api_key.api_id, api_key.api_key): EveManager.delete_characters_by_api_id(api_key.api_id) if not EveApiManager.check_api_is_not_expire( api_key.api_id, api_key.api_key): EveManager.delete_characters_by_api_id(api_key.api_id) EveManager.update_api_keypair(api_key.api_id, api_key.api_key)
def run_alliance_corp_update(): with current_app.app_context(): # I am not proud of this block of code if EveApiManager.check_if_api_server_online(): characters = EveCharacter.query.order_by(EveCharacter.character_id).all() for character in characters: corp_info = EveApiManager.get_corporation_information(character.corporation_id) if corp_info: if not EveCorporationInfo.query.filter_by(corporation_id=character.corporation_id).first(): # print corp_info EveManager.create_corporation_info(corporation_id=corp_info['id'], corp_name=corp_info['name'], corp_ticker=corp_info['ticker'], corp_member_count=corp_info['members']['current'], alliance_id=corp_info['alliance']['id']) else: EveManager.update_corporation_info(corporation_id=corp_info['id'], corp_member_count=corp_info['members']['current'], alliance_id=corp_info['alliance']['id']) if character.alliance_id: if character.alliance_id != "0": alliance_info = EveApiManager.get_alliance_information(character.alliance_id) if alliance_info: if not EveAllianceInfo.query.filter_by(alliance_id=character.alliance_id).first(): # print alliance_info EveManager.create_alliance_info(alliance_id=alliance_info['id'], alliance_name=alliance_info['name'], alliance_ticker=alliance_info['ticker'], alliance_executor_corp_id=alliance_info['executor_id'], alliance_member_count=alliance_info['member_count']) else: # print alliance_info EveManager.create_alliance_info(alliance_id=alliance_info['id'], alliance_name=alliance_info['name'], alliance_ticker=alliance_info['ticker'], alliance_executor_corp_id=alliance_info['executor_id'], alliance_member_count=alliance_info['member_count'])
def api_manage(): api_key_pairs = EveManager.get_api_key_pairs(current_user) return render_template("users/api_manage.html", api_key_pairs=api_key_pairs)
def eve_main_character_change(character_id): if EveManager.check_if_character_owned_by_user(character_id, current_user.get_id()): current_user.main_character_id = character_id current_user.save() return redirect(url_for('user.eve_characters'))