From 02bd4570b062f74c730c7c280c045a973848523d Mon Sep 17 00:00:00 2001 From: Adarnof Date: Tue, 13 Dec 2016 17:45:42 -0500 Subject: [PATCH] Default to only available corpstats if no corp_id --- corputils/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/corputils/views.py b/corputils/views.py index d768a58b..b21254ad 100644 --- a/corputils/views.py +++ b/corputils/views.py @@ -61,10 +61,14 @@ def corpstats_view(request, corp_id=None): # get available models available = CorpStats.objects.visible_to(request.user) - # ensure we can see this one + # ensure we can see the requested model if corpstats and not corpstats in available: raise PermissionDenied('You do not have permission to view the selected corporation statistics module.') + # get default model if none requested + if not corp_id and available.count() == 1: + corpstats = available[0] + context = { 'available': available, }