From 57b3a8f654bd4f8bd79c9366e18770edc01cd680 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Fri, 7 Oct 2011 09:13:11 +0100 Subject: [PATCH] Allow for EVE API key claiming if they're already in the DB. - Thanks Dorijan and Nil'kandra --- app/eve_api/forms.py | 2 +- app/eve_api/tasks/account.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/eve_api/forms.py b/app/eve_api/forms.py index 7c12f11..744acbc 100644 --- a/app/eve_api/forms.py +++ b/app/eve_api/forms.py @@ -51,7 +51,7 @@ class EveAPIForm(forms.ModelForm): raise forms.ValidationError("You cannot change your API User ID") else: try: - eaccount = EVEAccount.objects.get(api_user_id=self.cleaned_data['api_user_id']) + eaccount = EVEAccount.objects.get(api_user_id=self.cleaned_data['api_user_id'], user__isnull=False) except EVEAccount.DoesNotExist: pass else: diff --git a/app/eve_api/tasks/account.py b/app/eve_api/tasks/account.py index 7cfb2f8..0c1d0a4 100644 --- a/app/eve_api/tasks/account.py +++ b/app/eve_api/tasks/account.py @@ -161,8 +161,8 @@ def import_apikey_func(api_userid, api_key, user=None, force_cache=False, log=lo if not 'error' in doc: if not account: account, created = EVEAccount.objects.get_or_create(pk=api_userid) - if user: - account.user = User.objects.get(id=user) + if user and not account.user: + account.user = User.objects.get(id=user) if not account.api_key == api_key: account.api_key = api_key account.api_status = API_STATUS_OK