diff --git a/alliance_auth/settings.py.example b/alliance_auth/settings.py.example index 3e5fa862..f977a268 100644 --- a/alliance_auth/settings.py.example +++ b/alliance_auth/settings.py.example @@ -192,15 +192,6 @@ MESSAGE_TAGS = { ## ##################################################### -########################### -# ALLIANCE / CORP TOGGLE -########################### -# Specifies to run membership checks against corp or alliance -# Set to FALSE for alliance -# Set to TRUE for corp -########################### -IS_CORP = 'True' == os.environ.get('AA_IS_CORP', 'True') - ################# # EMAIL SETTINGS ################# @@ -224,11 +215,12 @@ EMAIL_USE_TLS = 'True' == os.environ.get('AA_EMAIL_USE_TLS', 'True') # KILLBOARD_URL - URL for your killboard. Blank to hide link # MEDIA_URL - URL for your media page (youtube etc). Blank to hide link # FORUM_URL - URL for your forums. Blank to hide link -# SMF_URL - URL for your SMF forums. +# SITE_NAME - Name of the auth site. #################### KILLBOARD_URL = os.environ.get('AA_KILLBOARD_URL', '') EXTERNAL_MEDIA_URL = os.environ.get('AA_EXTERNAL_MEDIA_URL', '') FORUM_URL = os.environ.get('AA_FORUM_URL', '') +SITE_NAME = os.environ.get('AA_SITE_NAME', 'Alliance Auth') ################### # SSO Settings @@ -288,7 +280,6 @@ ENABLE_AUTH_XENFORO = 'True' == os.environ.get('AA_ENABLE_AUTH_XENFORO', 'False' ##################### # Blue service Setup ##################### -# BLUE_STANDING - The default lowest standings setting to consider blue # ENABLE_BLUE_FORUM - Enable forum support in the auth for blues # ENABLE_BLUE_JABBER - Enable jabber support in the auth for blues # ENABLE_BLUE_MUMBLE - Enable mumble support in the auth for blues @@ -301,7 +292,6 @@ ENABLE_AUTH_XENFORO = 'True' == os.environ.get('AA_ENABLE_AUTH_XENFORO', 'False' # ENABLE_BLUE_PATHFINDER = Enable Pathfinder support in the auth for blues # ENABLE_BLUE_XENFORO = Enable XenForo forum support in the auth for blue ##################### -BLUE_STANDING = float(os.environ.get('AA_BLUE_STANDING', '5.0')) ENABLE_BLUE_FORUM = 'True' == os.environ.get('AA_ENABLE_BLUE_FORUM', 'False') ENABLE_BLUE_JABBER = 'True' == os.environ.get('AA_ENABLE_BLUE_JABBER', 'False') ENABLE_BLUE_MUMBLE = 'True' == os.environ.get('AA_ENABLE_BLUE_MUMBLE', 'False') @@ -315,27 +305,28 @@ ENABLE_BLUE_MARKET = 'True' == os.environ.get('AA_ENABLE_BLUE_MARKET', 'False') ENABLE_BLUE_XENFORO = 'True' == os.environ.get('AA_ENABLE_BLUE_XENFORO', 'False') ######################### -# Corp Configuration +# Tenant Configuration ######################### -# If running in alliance mode, the following should be for the executor corp# -# CORP_ID - Set this to your corp ID (get this from https://zkillboard.com/corporation/#######) -# CORP_NAME - Set this to your Corporation Name -# CORP_API_ID - Set this to the api id for the corp API key -# CORP_API_VCODE - Set this to the api vcode for the corp API key -######################## -CORP_ID = os.environ.get('AA_CORP_ID', '') -CORP_NAME = os.environ.get('AA_CORP_NAME', '') -CORP_API_ID = os.environ.get('AA_CORP_API_ID', '') -CORP_API_VCODE = os.environ.get('AA_CORP_API_VCODE', '') +# CORP_IDS - A list of corporation IDs to treat as members. +# ALLIANCE_IDS - A list of alliance IDs to treat as members. +# Any corps in a specified alliance will be treated as members, so do not include them in CORP_IDS +######################### +CORP_IDS = [] +ALLIANCE_IDS = [] ######################### -# Alliance Configuration +# Standings Configuration ######################### -# ALLIANCE_ID - Set this to your Alliance ID (get this from https://zkillboard.com/alliance/#######) -# ALLIANCE_NAME - Set this to your Alliance Name +# Add a corp API key to add blue standings to grant access. +# CORP_API_ID - Set this to the api id for the corp API key +# CORP_API_VCODE - Set this to the api vcode for the corp API key +# BLUE_STANDING - The lowest standings value to consider blue +# STANDING_LEVEL - The level of standings to query. Accepted values are 'corp' and 'alliance'. ######################## -ALLIANCE_ID = os.environ.get('AA_ALLIANCE_ID', '') -ALLIANCE_NAME = os.environ.get('AA_ALLIANCE_NAME', '') +CORP_API_ID = os.environ.get('AA_CORP_API_ID', '') +CORP_API_VCODE = os.environ.get('AA_CORP_API_VCODE', '') +BLUE_STANDING = float(os.environ.get('AA_BLUE_STANDING', '5.0')) +STANDING_LEVEL = os.environ.get('AA_STANDING_LEVEL', 'corp') ######################## # API Configuration @@ -668,3 +659,7 @@ if ENABLE_AUTH_MARKET or ENABLE_BLUE_MARKET: DATABASES['market'] = MARKET_DB if ENABLE_AUTH_IPS4 or ENABLE_BLUE_IPS4: DATABASES['ips4'] = IPS4_DB + +# Ensure corp/alliance IDs are expected types +STR_CORP_IDS = [str(id) for id in CORP_IDS] +STR_ALLIANCE_IDS = [str(id) for id in ALLIANCE_IDS] diff --git a/authentication/tasks.py b/authentication/tasks.py index 4e7ff355..1026e147 100644 --- a/authentication/tasks.py +++ b/authentication/tasks.py @@ -63,15 +63,13 @@ def make_blue(auth): def determine_membership_by_character(char): - if settings.IS_CORP: - if int(char.corporation_id) == int(settings.CORP_ID): - logger.debug("Character %s in owning corp id %s" % (char, char.corporation_id)) - return MEMBER_STATE - else: - if int(char.alliance_id) == int(settings.ALLIANCE_ID): - logger.debug("Character %s in owning alliance id %s" % (char, char.alliance_id)) - return MEMBER_STATE - if EveCorporationInfo.objects.filter(corporation_id=char.corporation_id).exists() is False: + if char.corporation_id in settings.STR_CORP_IDS: + logger.debug("Character %s in member corp id %s" % (char, char.corporation_id)) + return MEMBER_STATE + elif char.alliance_id in settings.STR_ALLIANCE_IDS: + logger.debug("Character %s in member alliance id %s" % (char, char.alliance_id)) + return MEMBER_STATE + elif not EveCorporationInfo.objects.filter(corporation_id=char.corporation_id).exists(): logger.debug("No corp model for character %s corp id %s. Unable to check standings. Non-member." % ( char, char.corporation_id)) return NONE_STATE diff --git a/eveonline/tasks.py b/eveonline/tasks.py index 10ed57cf..9aae4760 100644 --- a/eveonline/tasks.py +++ b/eveonline/tasks.py @@ -113,30 +113,25 @@ def update_alliance(id): @periodic_task(run_every=crontab(minute=0, hour="*/2")) def run_corp_update(): - if EveApiManager.check_if_api_server_online() is False: + if not EveApiManager.check_if_api_server_online(): logger.warn("Aborted updating corp and alliance models: API server unreachable") return - standing_level = 'alliance' - alliance_id = settings.ALLIANCE_ID - # get corp info for owning corp if required - if settings.IS_CORP: - standing_level = 'corp' - if EveCorporationInfo.objects.filter(corporation_id=settings.CORP_ID).exists(): - update_corp(settings.CORP_ID) + # generate member corps + for corp_id in settings.STR_CORP_IDS: + if EveCorporationInfo.objects.filter(corporation_id=corp_id).exists(): + update_corp(corp_id) else: - EveManager.create_corporation(settings.CORP_ID) - - alliance_id = eve_adapter_factory().get_corp(settings.CORP_ID).alliance_id + EveManager.create_corporation(corp_id) - # get and create alliance info for owning alliance if required - if alliance_id: + # generate member alliances + for alliance_id in settings.STR_ALLIANCE_IDS: if EveAllianceInfo.objects.filter(alliance_id=alliance_id).exists(): logger.debug("Updating existing owner alliance model with id %s" % alliance_id) update_alliance(alliance_id) else: - EveManager.create_alliance(id) - EveManager.populate_alliance(id) + EveManager.create_alliance(alliance_id) + EveManager.populate_alliance(alliance_id) # update existing corp models for corp in EveCorporationInfo.objects.all(): @@ -150,9 +145,9 @@ def run_corp_update(): # create standings standings = EveApiManager.get_corp_standings() if standings: - standings = standings[standing_level] + standings = standings[settings.STANDING_LEVEL] for standing in standings: - if int(standings[standing]['standing']) >= settings.BLUE_STANDING: + if float(standings[standing]['standing']) >= settings.BLUE_STANDING: logger.debug("Standing %s meets threshold" % standing) if EveApiManager.check_if_id_is_alliance(standing): logger.debug("Standing %s is an alliance" % standing) @@ -211,37 +206,20 @@ def run_corp_update(): # delete unnecessary alliance models for alliance in EveAllianceInfo.objects.filter(is_blue=False): logger.debug("Checking to delete alliance %s" % alliance) - if not settings.IS_CORP: - if not alliance.alliance_id == settings.ALLIANCE_ID: - logger.info("Deleting unnecessary alliance model %s" % alliance) - alliance.delete() - else: - if not alliance.evecorporationinfo_set.filter(corporation_id=settings.CORP_ID).exists(): - logger.info("Deleting unnecessary alliance model %s" % alliance) - alliance.delete() + if not alliance.alliance_id in settings.STR_ALLIANCE_IDS: + logger.info("Deleting unnecessary alliance model %s" % alliance) + alliance.delete() # delete unnecessary corp models for corp in EveCorporationInfo.objects.filter(is_blue=False): logger.debug("Checking to delete corp %s" % corp) - if not settings.IS_CORP: + if not corp.corporation_id in settings.STR_CORP_IDS: + logger.debug("Corp %s is not member corp" % corp) if corp.alliance: logger.debug("Corp %s has alliance %s" % (corp, corp.alliance)) - if not corp.alliance.alliance_id == settings.ALLIANCE_ID: + if not corp.alliance.alliance_id in settings.STR_ALLIANCE_IDS: logger.info("Deleting unnecessary corp model %s" % corp) corp.delete() else: logger.info("Deleting unnecessary corp model %s" % corp) corp.delete() - else: - if corp.corporation_id != settings.CORP_ID: - logger.debug("Corp %s is not owning corp" % corp) - if corp.alliance: - logger.debug("Corp %s has alliance %s" % (corp, corp.alliance)) - if not corp.alliance.evecorporationinfo_set.filter(corporation_id=settings.CORP_ID).exists(): - logger.info("Deleting unnecessary corp model %s" % corp) - corp.delete() - else: - logger.info("Deleting unnecessary corp model %s" % corp) - corp.delete() - else: - logger.debug("Corp %s is owning corp" % corp) diff --git a/fleetactivitytracking/views.py b/fleetactivitytracking/views.py index 133b588f..02404b33 100644 --- a/fleetactivitytracking/views.py +++ b/fleetactivitytracking/views.py @@ -98,10 +98,10 @@ def fatlink_statistics_view(request, year=datetime.date.today().year, month=date # get FAT stats for member corps - if settings.IS_CORP: - fat_stats[settings.CORP_ID] = CorpStat(settings.CORP_ID, start_of_month, start_of_next_month) - else: - alliance_corps = EveCorporationInfo.objects.filter(alliance__alliance_id=settings.ALLIANCE_ID) + for corp_id in settings.STR_CORP_IDS: + fat_stats[corp_id] = CorpStat(corp_id, start_of_month, start_of_next_month) + for alliance_id in settings.STR_ALLIANCE_IDS: + alliance_corps = EveCorporationInfo.objects.filter(alliance__alliance_id=alliance_id) for corp in alliance_corps: fat_stats[corp.corporation_id] = CorpStat(corp.corporation_id, start_of_month, start_of_next_month) diff --git a/services/context_processors.py b/services/context_processors.py index 35bfadfc..d90c67a9 100644 --- a/services/context_processors.py +++ b/services/context_processors.py @@ -23,9 +23,5 @@ def auth_settings(request): 'MEMBER_API_MASK': settings.MEMBER_API_MASK, 'MEMBER_API_ACCOUNT': settings.MEMBER_API_ACCOUNT, 'JABBER_URL': settings.JABBER_URL, - 'ALLIANCE_NAME': settings.ALLIANCE_NAME, - 'ALLIANCE_ID': settings.ALLIANCE_ID, - 'CORP_NAME': settings.CORP_NAME, - 'CORP_ID': settings.CORP_ID, - 'IS_CORP': settings.IS_CORP, - } \ No newline at end of file + 'SITE_NAME': settings.SITE_NAME, + } diff --git a/stock/templates/public/base.html b/stock/templates/public/base.html index 03025900..2a1028a6 100755 --- a/stock/templates/public/base.html +++ b/stock/templates/public/base.html @@ -46,11 +46,7 @@