Prevent admin error when EveCharacter has no assigned user.

This commit is contained in:
Adarnof 2016-11-13 16:51:15 -05:00
parent b4dc624b17
commit 97743cfe16

View File

@ -22,12 +22,13 @@ class EveCharacterAdmin(admin.ModelAdmin):
@staticmethod
def main_character(obj):
auth = AuthServicesInfo.objects.get_or_create(user=obj.user)[0]
if auth and auth.main_char_id:
try:
return EveCharacter.objects.get(character_id=auth.main_char_id)
except EveCharacter.DoesNotExist:
pass
if obj.user:
auth = AuthServicesInfo.objects.get_or_create(user=obj.user)[0]
if auth and auth.main_char_id:
try:
return EveCharacter.objects.get(character_id=auth.main_char_id)
except EveCharacter.DoesNotExist:
pass
return None