- {% for group in user.groups.all %}
+ {% for group in groups %}
{{ group.name }} |
@@ -128,16 +128,14 @@
- {% for ownership in request.user.character_ownerships.all %}
- {% with ownership.character as char %}
-
-
- |
- {{ char.character_name }} |
- {{ char.corporation_name }} |
- {{ char.alliance_name }} |
-
- {% endwith %}
+ {% for char in characters %}
+
+
+ |
+ {{ char.character_name }} |
+ {{ char.corporation_name }} |
+ {{ char.alliance_name }} |
+
{% endfor %}
diff --git a/allianceauth/authentication/urls.py b/allianceauth/authentication/urls.py
index c3089b84..962483fe 100644
--- a/allianceauth/authentication/urls.py
+++ b/allianceauth/authentication/urls.py
@@ -7,11 +7,28 @@ from . import views
app_name = 'authentication'
urlpatterns = [
- url(r'^$', login_required(TemplateView.as_view(template_name='authentication/dashboard.html')),),
- url(r'^account/login/$', TemplateView.as_view(template_name='public/login.html'), name='login'),
- url(r'^account/characters/main/$', views.main_character_change, name='change_main_character'),
- url(r'^account/characters/add/$', views.add_character, name='add_character'),
- url(r'^help/$', login_required(TemplateView.as_view(template_name='allianceauth/help.html')), name='help'),
- url(r'^dashboard/$',
- login_required(TemplateView.as_view(template_name='authentication/dashboard.html')), name='dashboard'),
+ url(r'^$', views.index, name='index'),
+ url(
+ r'^account/login/$',
+ TemplateView.as_view(template_name='public/login.html'),
+ name='login'
+ ),
+ url(
+ r'^account/characters/main/$',
+ views.main_character_change,
+ name='change_main_character'
+ ),
+ url(
+ r'^account/characters/add/$',
+ views.add_character,
+ name='add_character'
+ ),
+ url(
+ r'^help/$',
+ login_required(
+ TemplateView.as_view(template_name='allianceauth/help.html')
+ ),
+ name='help'
+ ),
+ url(r'^dashboard/$', views.dashboard, name='dashboard'),
]
diff --git a/allianceauth/authentication/views.py b/allianceauth/authentication/views.py
index 9ddd2f85..9cd8e884 100644
--- a/allianceauth/authentication/views.py
+++ b/allianceauth/authentication/views.py
@@ -7,20 +7,58 @@ from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core import signing
from django.urls import reverse
-from django.shortcuts import redirect
+from django.shortcuts import redirect, render
from django.utils.translation import ugettext_lazy as _
+
+from allianceauth.eveonline.models import EveCharacter
from esi.decorators import token_required
from esi.models import Token
-from registration.backends.hmac.views import RegistrationView as BaseRegistrationView, \
- ActivationView as BaseActivationView, REGISTRATION_SALT
+
+from registration.backends.hmac.views import (
+ RegistrationView as BaseRegistrationView,
+ ActivationView as BaseActivationView,
+ REGISTRATION_SALT
+)
from registration.signals import user_registered
from .models import CharacterOwnership
from .forms import RegistrationForm
+if 'allianceauth.eveonline.autogroups' in settings.INSTALLED_APPS:
+ _has_auto_groups = True
+ from allianceauth.eveonline.autogroups.models import *
+else:
+ _has_auto_groups = False
+
+
logger = logging.getLogger(__name__)
+@login_required
+def index(request):
+ return redirect('authentication:dashboard')
+
+
+@login_required
+def dashboard(request):
+ groups = request.user.groups.all()
+ if _has_auto_groups:
+ groups = groups\
+ .filter(managedalliancegroup__isnull=True)\
+ .filter(managedcorpgroup__isnull=True)
+ groups = groups.order_by('name')
+ characters = EveCharacter.objects\
+ .filter(character_ownership__user=request.user)\
+ .select_related()\
+ .order_by('character_name')
+
+ context = {
+ 'groups': groups,
+ 'characters': characters
+ }
+ return render(request, 'authentication/dashboard.html', context)
+
+
@login_required
@token_required(scopes=settings.LOGIN_TOKEN_SCOPES)
def main_character_change(request, token):