From 81af610c11a0515d85b01888d9d37d391db6f11e Mon Sep 17 00:00:00 2001 From: ErikKalkoken Date: Wed, 19 Feb 2020 01:29:14 +0100 Subject: [PATCH] Add sorting to characters and groups and remove auto groups --- .../templates/authentication/dashboard.html | 22 +++++----- allianceauth/authentication/urls.py | 31 ++++++++++--- allianceauth/authentication/views.py | 44 +++++++++++++++++-- 3 files changed, 75 insertions(+), 22 deletions(-) diff --git a/allianceauth/authentication/templates/authentication/dashboard.html b/allianceauth/authentication/templates/authentication/dashboard.html index 32896cbc..b6ea8204 100644 --- a/allianceauth/authentication/templates/authentication/dashboard.html +++ b/allianceauth/authentication/templates/authentication/dashboard.html @@ -94,12 +94,12 @@
-

{% trans "Groups" %}

+

{% trans "Group Memberships" %}

- {% for group in user.groups.all %} + {% for group in groups %} @@ -128,16 +128,14 @@ - {% for ownership in request.user.character_ownerships.all %} - {% with ownership.character as char %} - - - - - - - {% endwith %} + {% for char in characters %} + + + + + + {% endfor %}
{{ group.name }}
- {{ char.character_name }}{{ char.corporation_name }}{{ char.alliance_name }}
+ {{ char.character_name }}{{ char.corporation_name }}{{ char.alliance_name }}
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):