diff --git a/alliance_auth/urls.py b/alliance_auth/urls.py
index 29613fc5..35e27966 100755
--- a/alliance_auth/urls.py
+++ b/alliance_auth/urls.py
@@ -177,7 +177,7 @@ urlpatterns += i18n_patterns(
django.contrib.auth.views.password_reset_confirm, name='password_reset_confirm'),
# Portal Urls
- url(_(r'^dashboard/$'), authentication.views.dashboard_view, name='auth_dashboard'),
+ url(_(r'^dashboard/$'), eveonline.views.dashboard_view, name='auth_dashboard'),
url(_(r'^help/$'), authentication.views.help_view, name='auth_help'),
# Eveonline Urls
diff --git a/authentication/views.py b/authentication/views.py
index 745a74bd..c5a3968a 100644
--- a/authentication/views.py
+++ b/authentication/views.py
@@ -88,19 +88,12 @@ def index_view(request):
return render(request, 'public/index.html')
-@login_required
-def dashboard_view(request):
- logger.debug("dashboard_view called by user %s" % request.user)
- render_items = {'characters': EveManager.get_characters_by_owner_id(request.user.id),
- 'authinfo': AuthServicesInfo.objects.get_or_create(user=request.user)[0]}
- return render(request, 'registered/dashboard.html', context=render_items)
-
-
@login_required
def help_view(request):
logger.debug("help_view called by user %s" % request.user)
return render(request, 'registered/help.html')
+
@token_required(new=True)
def sso_login(request, tokens=[]):
token = tokens[0]
@@ -109,7 +102,7 @@ def sso_login(request, tokens=[]):
if char.user:
if char.user.is_active:
login(request, char.user)
- return redirect(dashboard_view)
+ return redirect('auth_dashboard')
else:
messages.error(request, 'Your account has been disabled.')
else:
diff --git a/eveonline/managers.py b/eveonline/managers.py
index 214433e4..7ba677d6 100644
--- a/eveonline/managers.py
+++ b/eveonline/managers.py
@@ -227,6 +227,10 @@ class EveManager:
return None
+ @staticmethod
+ def get_characters_by_api_id(api_id):
+ return EveCharacter.objects.filter(api_id=api_id)
+
@staticmethod
def get_charater_alliance_id_by_id(char_id):
if EveCharacter.objects.filter(character_id=char_id).exists():
diff --git a/eveonline/views.py b/eveonline/views.py
index 51727f3b..a71b43ec 100755
--- a/eveonline/views.py
+++ b/eveonline/views.py
@@ -55,7 +55,7 @@ def add_api_key(request):
auth = AuthServicesInfo.objects.get_or_create(user=request.user)[0]
if not auth.main_char_id:
return redirect('auth_characters')
- return redirect("/api_key_management/")
+ return redirect("auth_dashboard")
else:
logger.debug('Requesting SSO validation of API %s by user %s' % (api_key.api_id, request.user))
return render(request, 'registered/apisso.html', context={'api':api_key})
@@ -76,11 +76,11 @@ def api_sso_validate(request, tokens, api_id):
if api.user and api.user != request.user:
logger.warning('User %s attempting to take ownership of api %s from %s' % (request.user, api_id, api.user))
messages.warning(request, 'API %s already claimed by user %s' % (api_id, api.user))
- return redirect('auth_api_key_management')
+ return redirect('auth_dashboard')
elif api.sso_verified:
logger.debug('API %s has already been verified.' % api_id)
messages.info(request, 'API %s has already been verified' % api_id)
- return redirect('auth_api_key_management')
+ return redirect('auth_dashboard')
token = tokens[0]
logger.debug('API %s has not been verified. Checking if token for %s matches.' % (api_id, token.character_name))
characters = EveApiManager.get_characters_from_api(api.api_id, api.api_key).result
@@ -93,7 +93,7 @@ def api_sso_validate(request, tokens, api_id):
auth, c = AuthServicesInfo.objects.get_or_create(user=request.user)
if not auth.main_char_id:
return redirect('auth_characters')
- return redirect('auth_api_key_management')
+ return redirect('auth_dashboard')
else:
messages.warning(request, '%s not found on API %s. Please SSO as a character on the API.' % (token.character_name, api.api_id))
return render(request, 'registered/apisso.html', context={'api':api})
@@ -101,13 +101,33 @@ def api_sso_validate(request, tokens, api_id):
@login_required
def api_key_management_view(request):
- logger.debug("api_key_management_view called by user %s" % request.user)
- context = {
- 'apikeypairs': EveManager.get_api_key_pairs(request.user.id),
- 'api_sso_validation': settings.API_SSO_VALIDATION or False
- }
+ logger.debug("DEPRECIATED api_key_management_view called by user %s" % request.user)
+ # Legacy redirect in case some links still ghost here
+ return redirect('auth_dashboard')
- return render(request, 'registered/apikeymanagment.html', context=context)
+
+@login_required
+def dashboard_view(request):
+ logger.debug("dashboard_view called by user %s" % request.user)
+ auth_info = AuthServicesInfo.objects.get_or_create(user=request.user)[0]
+ apikeypairs = EveManager.get_api_key_pairs(request.user.id)
+ sso_validation = settings.API_SSO_VALIDATION or False
+ api_chars = []
+
+ if apikeypairs:
+ for api in apikeypairs:
+ api_chars.append({
+ 'id': api.api_id,
+ 'sso_verified': api.sso_verified if sso_validation else True,
+ 'characters': EveManager.get_characters_by_api_id(api.api_id),
+ })
+
+ context = {
+ 'main': EveManager.get_character_by_id(auth_info.main_char_id),
+ 'apis': api_chars,
+ 'api_sso_validation': settings.API_SSO_VALIDATION or False,
+ }
+ return render(request, 'registered/dashboard.html', context=context)
@login_required
@@ -118,13 +138,11 @@ def api_key_removal(request, api_id):
EveManager.delete_characters_by_api_id(api_id, request.user.id)
messages.success(request, 'Deleted API key %s' % api_id)
logger.info("Succesfully processed api delete request by user %s for api %s" % (request.user, api_id))
- if EveCharacter.objects.filter(character_id=authinfo.main_char_id).exists():
- return redirect("auth_api_key_management")
- else:
+ if not EveCharacter.objects.filter(character_id=authinfo.main_char_id).exists():
authinfo.main_char_id = None
authinfo.save()
set_state(request.user)
- return redirect("auth_characters")
+ return redirect("auth_dashboard")
@login_required
@@ -142,7 +160,7 @@ def main_character_change(request, char_id):
AuthServicesInfoManager.update_main_char_id(char_id, request.user)
messages.success(request, 'Changed main character ID to %s' % char_id)
set_state(request.user)
- return redirect("auth_characters")
+ return redirect("auth_dashboard")
messages.error(request, 'Failed to change main character - selected character is not owned by your account.')
return redirect("auth_characters")
@@ -162,4 +180,4 @@ def user_refresh_api(request, api_id):
else:
messages.warning(request, 'Unable to locate API key %s' % api_id)
logger.warn("User %s unable to refresh api id %s - api key not found" % (request.user, api_id))
- return redirect("auth_api_key_management")
+ return redirect("auth_dashboard")
diff --git a/stock/templates/public/base.html b/stock/templates/public/base.html
index 650d843a..cf856172 100755
--- a/stock/templates/public/base.html
+++ b/stock/templates/public/base.html
@@ -110,12 +110,6 @@
-
-
- {% trans " Api Keys" %}
-
-
-
{% trans " Characters" %}
diff --git a/stock/templates/public/characternotexisting.html b/stock/templates/public/characternotexisting.html
index aa4159f1..86fd9ab6 100644
--- a/stock/templates/public/characternotexisting.html
+++ b/stock/templates/public/characternotexisting.html
@@ -71,7 +71,7 @@
Character not registered!
- This character is not part of any registered API-key. You must go to
API key management and add an API with the character on before being able to click fleet attendance links.
+ This character is not part of any registered API-key. You must go to
API key management and add an API with the character on before being able to click fleet attendance links.
diff --git a/stock/templates/registered/apikeymanagment.html b/stock/templates/registered/apikeymanagment.html
deleted file mode 100644
index 66272d06..00000000
--- a/stock/templates/registered/apikeymanagment.html
+++ /dev/null
@@ -1,64 +0,0 @@
-{% extends "public/base.html" %}
-{% load bootstrap %}
-{% load staticfiles %}
-{% load i18n %}
-
-{% block title %}Alliance Auth{% endblock %}
-
-{% block page_title %}{% trans "API Key Management" %}{% endblock page_title %}
-{% block extra_css %}{% endblock extra_css %}
-
-{% block content %}
-
-
-
- {% if apikeypairs %}
-
-
- {% trans "API ID" %} |
- {% if api_sso_validation %}
- {% trans "SSO Verified" %} |
- {% endif %}
- {% trans "Action" %} |
-
- {% for pair in apikeypairs %}
-
- {{ pair.api_id }} |
- {% if api_sso_validation %}
-
- {% if pair.sso_verified %}
-
- {% else %}
-
-
- {% endif %}
- |
- {% endif %}
-
-
-
-
-
-
-
- {% if api_sso_validation and not pair.sso_verified %}
-
-
-
- {% endif %}
- |
-
- {% endfor %}
-
- {% else %}
-
{% trans "No api keys found" %}
- {% endif %}
-
-
-
-{% endblock content %}
diff --git a/stock/templates/registered/dashboard.html b/stock/templates/registered/dashboard.html
index ff1c498b..d405cc74 100644
--- a/stock/templates/registered/dashboard.html
+++ b/stock/templates/registered/dashboard.html
@@ -1,69 +1,123 @@
{% extends "public/base.html" %}
+{% load staticfiles %}
{% load i18n %}
-{% block title %}Alliance Auth{% endblock %}
-{% block page_title %}{% trans "Dashboard" %}{% endblock page_title %}
+
+{% block title %}{% trans "Dashboard" %}{% endblock %}
{% block content %}
-
- {% if STATE == MEMBER_STATE or user.is_superuser%}
-
-
-
+
-
- {% for character in characters %}
- {% ifequal character.character_id authinfo.main_char_id %}
-
-
{% trans "Main character" %}
-
-
-
-

-
-
-
-
{{ character.character_name }}
-
-
{{ character.corporation_name }}
-
-
{{ character.alliance_name }}
-
+
+
+
{% trans "Main Character" %}
+
+ {% if main %}
+
+
+  |
+ {{ main.character_name }} |
+
+
+
+  |
+ {{ main.corporation_name }} |
+
+
+
+ {% if main.alliance_id != '0' %}
+
+  |
+ {{ main.alliance_name }} |
+
+ {% endif %}
+
+ {% else %}
+
Missing main character model.
+ {% endif %}
+
+
- {% endifequal %}
- {% endfor %}
+
+
+
-
-
-
-
+
+
{% trans "Groups" %}
-
+
{% for group in user.groups.all %}
- {{ group.name }}
+ {{ group.name }}
|
{% endfor %}
-
-
-
- {% else %}
- {% if IS_CORP %}
-
{% trans "Not a part of the corporation." %}
- {% else %}
-
{% trans "Not a part of the alliance." %}
- {% endif %}
- {% endif %}
-
-{% endblock content %}
+
+ {% if apis %}
+ {% for api in apis %}
+
+
+
+ {% trans "API ID" %} {{ api.id }}
+
+
+
+
+ {% if api_sso_validation and not api.sso_verified %}
+
+
+
+ {% endif %}
+
+
+
+
+ |
+ {% trans "Name" %} |
+ {% trans "Corp" %} |
+ {% trans "Alliance" %} |
+
+ {% for char in api.characters %}
+
+
+
+ |
+ {{ char.character_name }} |
+ {{ char.corporation_name }} |
+ {{ char.alliance_name }} |
+
+ {% endfor %}
+ {% if api.corp %}
+
+
+
+ |
+ |
+ {{ api.corporation_name }} |
+ {{ api.alliance_name }} |
+
+ {% endif %}
+
+
+ {% endfor %}
+ {% else %}
+
{% trans "No API keys found" %}
+ {% endif %}
+
+
+
+{% endblock %}