From 98bda18f251a24e0278a6c5e68a5bbe7176ac1b9 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Wed, 26 Oct 2011 14:04:25 +0100 Subject: [PATCH] Cleanup some access checking code, make has_access a bit more smart --- app/eve_api/models/account.py | 6 +++++- app/eve_api/tasks/character.py | 17 +++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/app/eve_api/models/account.py b/app/eve_api/models/account.py index cc1aa0c..95d7f19 100644 --- a/app/eve_api/models/account.py +++ b/app/eve_api/models/account.py @@ -1,5 +1,6 @@ from django.db import models from django.contrib.auth.models import User +from gargoyle import gargoyle from eve_api.app_defines import * from eve_api.models import EVEAPIModel @@ -47,7 +48,10 @@ class EVEAccount(EVEAPIModel): def has_access(self, bit): """ 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): """ Checks if the account has equal or higher access than the bitmask provided """ diff --git a/app/eve_api/tasks/character.py b/app/eve_api/tasks/character.py index 7127b31..ec522e4 100644 --- a/app/eve_api/tasks/character.py +++ b/app/eve_api/tasks/character.py @@ -117,19 +117,8 @@ def import_eve_character_func(character_id, key_id=None, logger=logging.getLogge else: acc = None - - # If we have a key, check if we should import the charsheet - 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 we have a key, call CharSheet + if acc and acc.has_access(3) and not acc.api_keytype == API_KEYTYPE_CORPORATION: if gargoyle.is_active('eve-cak') and acc.is_cak: auth_params = {'keyid': acc.api_user_id, 'vcode': acc.api_key, 'characterid': character_id } else: @@ -163,7 +152,7 @@ def import_eve_character_func(character_id, key_id=None, logger=logging.getLogge charskillobj.save() 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: skillqueue = CachedDocument.objects.api_query('/char/SkillInTraining.xml.aspx', params=auth_params, no_cache=False) except DocumentRetrievalError, exc: