From c85882fa7456c83e626f2623432a14c14ac1c4be Mon Sep 17 00:00:00 2001 From: Adarnof Date: Wed, 2 Dec 2015 04:45:57 +0000 Subject: [PATCH] Added error handling for missing corp models. Addresses #116 and more unreported. --- eveonline/views.py | 36 +++++++++++------------ hrapplications/views.py | 7 +++-- stock/templates/registered/corpstats.html | 12 ++++++-- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/eveonline/views.py b/eveonline/views.py index d5b4ab58..f3bfb3b4 100755 --- a/eveonline/views.py +++ b/eveonline/views.py @@ -139,21 +139,21 @@ def corp_stats_view(request): # Get the corp the member is in auth_info = AuthServicesInfo.objects.get(user=request.user) main_char = EveCharacter.objects.get(character_id=auth_info.main_char_id) - corp = EveCorporationInfo.objects.get(corporation_id=main_char.corporation_id) - current_count = 0 - allcharacters = {} - all_characters = EveCharacter.objects.all() - for char in all_characters: - if char: - try: - if char.corporation_id == corp.corporation_id: - current_count = current_count + 1 - allcharacters[char.character_name] = EveApiKeyPair.objects.get(api_id=char.api_id) - except: - pass - - context = {"corp": corp, - "currentCount": current_count, - "characters": allcharacters} - - return render_to_response('registered/corpstats.html', context, context_instance=RequestContext(request)) + if EveCorporationInfo.objects.filter(corporation_id=main_char.corporation_id).exists(): + current_count = 0 + allcharacters = {} + corp = EveCorporationInfo.objects.get(corporation_id=main_char.corporation_id) + all_characters = EveCharacter.objects.all() + for char in all_characters: + if char: + try: + if char.corporation_id == corp.corporation_id: + current_count = current_count + 1 + allcharacters[char.character_name] = EveApiKeyPair.objects.get(api_id=char.api_id) + except: + pass + context = {"corp": corp, + "currentCount": current_count, + "characters": allcharacters} + return render_to_response('registered/corpstats.html', context, context_instance=RequestContext(request)) + return render_to_response('registered/corpstats.html', None, context_instance=RequestContext(request)) diff --git a/hrapplications/views.py b/hrapplications/views.py index 3f4fa9b3..f63fc928 100755 --- a/hrapplications/views.py +++ b/hrapplications/views.py @@ -32,8 +32,11 @@ def hr_application_management_view(request): main_alliance_id = EveManager.get_charater_alliance_id_by_id(auth_info.main_char_id) if (settings.IS_CORP and main_corp_id == settings.CORP_ID) or (not settings.IS_CORP and main_alliance_id == settings.ALLIANCE_ID): main_char = EveCharacter.objects.get(character_id=auth_info.main_char_id) - corp = EveCorporationInfo.objects.get(corporation_id=main_char.corporation_id) - corp_applications = HRApplication.objects.filter(corp=corp).filter(approved_denied=None) + if EveCorporationInfo.objects.filter(corporation_id=main_char.corporation_id).exists(): + corp = EveCorporationInfo.objects.get(corporation_id=main_char.corporation_id) + corp_applications = HRApplication.objects.filter(corp=corp).filter(approved_denied=None) + else: + corp_applications = None else: corp_applications = None diff --git a/stock/templates/registered/corpstats.html b/stock/templates/registered/corpstats.html index 050dc2ee..f373d253 100755 --- a/stock/templates/registered/corpstats.html +++ b/stock/templates/registered/corpstats.html @@ -8,7 +8,7 @@

Corporation Stats

{% if perms.auth.member %}
- + {% if corp %}
@@ -63,7 +63,15 @@
- + {% else %} +
+
+
+ +
+
+
+ {% endif %}
{% else %}