Cleanup some access checking code, make has_access a bit more smart

This commit is contained in:
2011-10-26 14:04:25 +01:00
parent c4dbe6061f
commit 98bda18f25
2 changed files with 8 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from gargoyle import gargoyle
from eve_api.app_defines import * from eve_api.app_defines import *
from eve_api.models import EVEAPIModel from eve_api.models import EVEAPIModel
@@ -47,7 +48,10 @@ class EVEAccount(EVEAPIModel):
def has_access(self, bit): def has_access(self, bit):
""" Checks if a specific bit is enabled in the key's access mask """ """ Checks if a specific bit is enabled in the key's access mask """
return self._mask_check(self.api_accessmask, bit) if gargoyle.is_active('eve-cak') and self.is_cak:
return self._mask_check(self.api_accessmask, bit)
else:
return True
def check_access(self, accessmask): def check_access(self, accessmask):
""" Checks if the account has equal or higher access than the bitmask provided """ """ Checks if the account has equal or higher access than the bitmask provided """

View File

@@ -117,19 +117,8 @@ def import_eve_character_func(character_id, key_id=None, logger=logging.getLogge
else: else:
acc = None acc = None
# If we have a key, call CharSheet
# If we have a key, check if we should import the charsheet if acc and acc.has_access(3) and not acc.api_keytype == API_KEYTYPE_CORPORATION:
if acc:
if gargoyle.is_active('eve-cak'):
if (acc.is_cak and acc.has_access(3) and not acc.api_keytype == API_KEYTYPE_CORPORATION) or not acc.is_cak:
process_charsheet = True
else:
process_charsheet = False
else:
process_charsheet = True
# Actual Key? Get further information
if acc and process_charsheet:
if gargoyle.is_active('eve-cak') and acc.is_cak: if gargoyle.is_active('eve-cak') and acc.is_cak:
auth_params = {'keyid': acc.api_user_id, 'vcode': acc.api_key, 'characterid': character_id } auth_params = {'keyid': acc.api_user_id, 'vcode': acc.api_key, 'characterid': character_id }
else: else:
@@ -163,7 +152,7 @@ def import_eve_character_func(character_id, key_id=None, logger=logging.getLogge
charskillobj.save() charskillobj.save()
pchar.total_sp = pchar.total_sp + int(skill['skillpoints']) pchar.total_sp = pchar.total_sp + int(skill['skillpoints'])
if not acc.is_cak or acc.has_access(18): if acc.has_access(18):
try: try:
skillqueue = CachedDocument.objects.api_query('/char/SkillInTraining.xml.aspx', params=auth_params, no_cache=False) skillqueue = CachedDocument.objects.api_query('/char/SkillInTraining.xml.aspx', params=auth_params, no_cache=False)
except DocumentRetrievalError, exc: except DocumentRetrievalError, exc: