mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-12 14:00:17 +02:00
Complete removal of single tenant aspects.
This commit is contained in:
parent
3cdbff6b36
commit
2f2c2bd0e5
@ -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
|
||||
|
@ -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)
|
||||
EveManager.create_corporation(corp_id)
|
||||
|
||||
alliance_id = eve_adapter_factory().get_corp(settings.CORP_ID).alliance_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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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,
|
||||
'SITE_NAME': settings.SITE_NAME,
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user