diff --git a/allianceauth/analytics/migrations/0001_initial.py b/allianceauth/analytics/migrations/0001_initial.py
index c5a1f33a..e6385469 100644
--- a/allianceauth/analytics/migrations/0001_initial.py
+++ b/allianceauth/analytics/migrations/0001_initial.py
@@ -1,8 +1,9 @@
# Generated by Django 3.1.4 on 2020-12-30 13:11
-from django.db import migrations, models
import uuid
+from django.db import migrations, models
+
class Migration(migrations.Migration):
diff --git a/allianceauth/analytics/migrations/0002_add_AA_Team_Token.py b/allianceauth/analytics/migrations/0002_add_AA_Team_Token.py
index 13071b8a..4acb725f 100644
--- a/allianceauth/analytics/migrations/0002_add_AA_Team_Token.py
+++ b/allianceauth/analytics/migrations/0002_add_AA_Team_Token.py
@@ -21,7 +21,7 @@ def remove_aa_team_token(apps, schema_editor):
# Have to define some code to remove this identifier
# In case of migration rollback?
Tokens = apps.get_model('analytics', 'AnalyticsTokens')
- token = Tokens.objects.filter(token="UA-186249766-2").delete()
+ Tokens.objects.filter(token="UA-186249766-2").delete()
class Migration(migrations.Migration):
diff --git a/allianceauth/analytics/migrations/0003_Generate_Identifier.py b/allianceauth/analytics/migrations/0003_Generate_Identifier.py
index 5c4daba8..08df9ca8 100644
--- a/allianceauth/analytics/migrations/0003_Generate_Identifier.py
+++ b/allianceauth/analytics/migrations/0003_Generate_Identifier.py
@@ -1,6 +1,5 @@
# Generated by Django 3.1.4 on 2020-12-30 08:53
-from uuid import uuid4
from django.db import migrations
diff --git a/allianceauth/analytics/migrations/0008_add_AA_GA-4_Team_Token .py b/allianceauth/analytics/migrations/0008_add_AA_GA-4_Team_Token .py
index efc816ac..db7e8afd 100644
--- a/allianceauth/analytics/migrations/0008_add_AA_GA-4_Team_Token .py
+++ b/allianceauth/analytics/migrations/0008_add_AA_GA-4_Team_Token .py
@@ -1,7 +1,7 @@
# Generated by Django 3.1.4 on 2020-12-30 08:53
-from django.db import migrations
from django.core.exceptions import ObjectDoesNotExist
+from django.db import migrations
def add_aa_team_token(apps, schema_editor):
@@ -51,7 +51,7 @@ def remove_aa_team_token(apps, schema_editor):
# Have to define some code to remove this identifier
# In case of migration rollback?
Tokens = apps.get_model('analytics', 'AnalyticsTokens')
- token = Tokens.objects.filter(token="G-6LYSMYK8DE").delete()
+ Tokens.objects.filter(token="G-6LYSMYK8DE").delete()
class Migration(migrations.Migration):
diff --git a/allianceauth/analytics/models.py b/allianceauth/analytics/models.py
index ddee495a..72d11abe 100644
--- a/allianceauth/analytics/models.py
+++ b/allianceauth/analytics/models.py
@@ -1,9 +1,9 @@
-from django.db import models
-from django.core.exceptions import ValidationError
-from django.utils.translation import gettext_lazy as _
-
from uuid import uuid4
+from django.core.exceptions import ValidationError
+from django.db import models
+from django.utils.translation import gettext_lazy as _
+
class AnalyticsIdentifier(models.Model):
@@ -11,6 +11,9 @@ class AnalyticsIdentifier(models.Model):
default=uuid4,
editable=False)
+ def __str__(self) -> str:
+ return f"{self.identifier}"
+
def save(self, *args, **kwargs):
if not self.pk and AnalyticsIdentifier.objects.exists():
# Force a single object
@@ -31,3 +34,6 @@ class AnalyticsTokens(models.Model):
token = models.CharField(max_length=254, blank=False)
secret = models.CharField(max_length=254, blank=True)
send_stats = models.BooleanField(default=False)
+
+ def __str__(self) -> str:
+ return self.name
diff --git a/allianceauth/analytics/tasks.py b/allianceauth/analytics/tasks.py
index cc9ef160..00ed8202 100644
--- a/allianceauth/analytics/tasks.py
+++ b/allianceauth/analytics/tasks.py
@@ -1,16 +1,16 @@
-import requests
import logging
-from django.conf import settings
-from django.apps import apps
+
+import requests
from celery import shared_task
-from .models import AnalyticsTokens, AnalyticsIdentifier
-from .utils import (
- install_stat_addons,
- install_stat_tokens,
- install_stat_users)
+
+from django.apps import apps
+from django.conf import settings
from allianceauth import __version__
+from .models import AnalyticsIdentifier, AnalyticsTokens
+from .utils import install_stat_addons, install_stat_tokens, install_stat_users
+
logger = logging.getLogger(__name__)
BASE_URL = "https://www.google-analytics.com"
diff --git a/allianceauth/analytics/tests/test_models.py b/allianceauth/analytics/tests/test_models.py
index 452c4eaa..b430f03d 100644
--- a/allianceauth/analytics/tests/test_models.py
+++ b/allianceauth/analytics/tests/test_models.py
@@ -1,10 +1,9 @@
-from allianceauth.analytics.models import AnalyticsIdentifier
-from django.core.exceptions import ValidationError
-
-from django.test.testcases import TestCase
-
from uuid import UUID, uuid4
+from django.core.exceptions import ValidationError
+from django.test.testcases import TestCase
+
+from allianceauth.analytics.models import AnalyticsIdentifier
# Identifiers
uuid_1 = "ab33e241fbf042b6aa77c7655a768af7"
diff --git a/allianceauth/analytics/tests/test_tasks.py b/allianceauth/analytics/tests/test_tasks.py
index 0a542e23..08a5676a 100644
--- a/allianceauth/analytics/tests/test_tasks.py
+++ b/allianceauth/analytics/tests/test_tasks.py
@@ -2,12 +2,9 @@ import requests_mock
from django.test.utils import override_settings
-from allianceauth.analytics.tasks import (
- analytics_event,
- send_ga_tracking_celery_event)
+from allianceauth.analytics.tasks import analytics_event, send_ga_tracking_celery_event
from allianceauth.utils.testing import NoSocketsTestCase
-
GOOGLE_ANALYTICS_DEBUG_URL = 'https://www.google-analytics.com/debug/mp/collect'
diff --git a/allianceauth/analytics/tests/test_utils.py b/allianceauth/analytics/tests/test_utils.py
index b9a22329..838513d8 100644
--- a/allianceauth/analytics/tests/test_utils.py
+++ b/allianceauth/analytics/tests/test_utils.py
@@ -1,10 +1,9 @@
from django.apps import apps
-from allianceauth.authentication.models import User
-from esi.models import Token
-from allianceauth.analytics.utils import install_stat_users, install_stat_tokens, install_stat_addons
-
from django.test.testcases import TestCase
+from allianceauth.analytics.utils import install_stat_addons, install_stat_users
+from allianceauth.authentication.models import User
+
def create_testdata():
User.objects.all().delete()
diff --git a/allianceauth/analytics/utils.py b/allianceauth/analytics/utils.py
index e8c57927..d09cc65c 100644
--- a/allianceauth/analytics/utils.py
+++ b/allianceauth/analytics/utils.py
@@ -1,7 +1,9 @@
from django.apps import apps
-from allianceauth.authentication.models import User
+
from esi.models import Token
+from allianceauth.authentication.models import User
+
def install_stat_users() -> int:
"""Count and Return the number of User accounts
diff --git a/allianceauth/apps.py b/allianceauth/apps.py
index 098f50ba..1191fed9 100644
--- a/allianceauth/apps.py
+++ b/allianceauth/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-from django.core.checks import Warning, Error, register
class AllianceAuthConfig(AppConfig):
diff --git a/allianceauth/authentication/admin.py b/allianceauth/authentication/admin.py
index 6da117e2..9729e200 100644
--- a/allianceauth/authentication/admin.py
+++ b/allianceauth/authentication/admin.py
@@ -1,43 +1,21 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
-from django.contrib.auth.models import Group
-from django.contrib.auth.models import Permission as BasePermission
-from django.contrib.auth.models import User as BaseUser
+from django.contrib.auth.models import Group, Permission as BasePermission, User as BaseUser
from django.db.models import Count, Q
from django.db.models.functions import Lower
-from django.db.models.signals import (
- m2m_changed,
- post_delete,
- post_save,
- pre_delete,
- pre_save
-)
+from django.db.models.signals import m2m_changed, post_delete, post_save, pre_delete, pre_save
from django.dispatch import receiver
from django.urls import reverse
from django.utils.html import format_html
from django.utils.text import slugify
-from allianceauth.authentication.models import (
- CharacterOwnership,
- OwnershipRecord,
- State,
- UserProfile,
- get_guest_state
-)
-from allianceauth.eveonline.models import (
- EveAllianceInfo,
- EveCharacter,
- EveCorporationInfo,
- EveFactionInfo
-)
+from allianceauth.authentication.models import CharacterOwnership, OwnershipRecord, State, UserProfile, get_guest_state
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo, EveFactionInfo
from allianceauth.eveonline.tasks import update_character
from allianceauth.hooks import get_hooks
from allianceauth.services.hooks import ServicesHook
-from .app_settings import (
- AUTHENTICATION_ADMIN_USERS_MAX_CHARS,
- AUTHENTICATION_ADMIN_USERS_MAX_GROUPS
-)
+from .app_settings import AUTHENTICATION_ADMIN_USERS_MAX_CHARS, AUTHENTICATION_ADMIN_USERS_MAX_GROUPS
from .forms import UserChangeForm, UserProfileForm
@@ -132,10 +110,7 @@ def user_username(obj):
To be used for all user based admin lists
"""
link = reverse(
- 'admin:{}_{}_change'.format(
- obj._meta.app_label,
- type(obj).__name__.lower()
- ),
+ f'admin:{obj._meta.app_label}_{type(obj).__name__.lower()}_change',
args=(obj.pk,)
)
user_obj = obj.user if hasattr(obj, 'user') else obj
@@ -548,7 +523,7 @@ class BaseOwnershipAdmin(admin.ModelAdmin):
def get_readonly_fields(self, request, obj=None):
if obj and obj.pk:
return 'owner_hash', 'character'
- return tuple()
+ return ()
@admin.register(OwnershipRecord)
diff --git a/allianceauth/authentication/app_settings.py b/allianceauth/authentication/app_settings.py
index 449bef08..e06d1eb8 100644
--- a/allianceauth/authentication/app_settings.py
+++ b/allianceauth/authentication/app_settings.py
@@ -25,7 +25,7 @@ def _clean_setting(
if not required_type:
required_type = type(default_value)
- if min_value is None and required_type == int:
+ if min_value is None and required_type is int:
min_value = 0
if (hasattr(settings, name)
diff --git a/allianceauth/authentication/apps.py b/allianceauth/authentication/apps.py
index 30e5a4f2..db52502c 100644
--- a/allianceauth/authentication/apps.py
+++ b/allianceauth/authentication/apps.py
@@ -1,5 +1,5 @@
from django.apps import AppConfig
-from django.core.checks import register, Tags
+from django.core.checks import Tags, register
class AuthenticationConfig(AppConfig):
diff --git a/allianceauth/authentication/auth_hooks.py b/allianceauth/authentication/auth_hooks.py
index b29a3300..34d62fc3 100644
--- a/allianceauth/authentication/auth_hooks.py
+++ b/allianceauth/authentication/auth_hooks.py
@@ -1,6 +1,7 @@
-from allianceauth.hooks import DashboardItemHook
from allianceauth import hooks
-from .views import dashboard_characters, dashboard_esi_check, dashboard_groups, dashboard_admin
+from allianceauth.hooks import DashboardItemHook
+
+from .views import dashboard_admin, dashboard_characters, dashboard_esi_check, dashboard_groups
class UserCharactersHook(DashboardItemHook):
diff --git a/allianceauth/authentication/backends.py b/allianceauth/authentication/backends.py
index 260dd293..7c3b00a3 100644
--- a/allianceauth/authentication/backends.py
+++ b/allianceauth/authentication/backends.py
@@ -1,10 +1,9 @@
import logging
from django.contrib.auth.backends import ModelBackend
-from django.contrib.auth.models import User, Permission
-
-from .models import UserProfile, CharacterOwnership, OwnershipRecord
+from django.contrib.auth.models import Permission, User
+from .models import CharacterOwnership, OwnershipRecord, UserProfile
logger = logging.getLogger(__name__)
diff --git a/allianceauth/authentication/checks.py b/allianceauth/authentication/checks.py
index 1a687b62..88ea1219 100644
--- a/allianceauth/authentication/checks.py
+++ b/allianceauth/authentication/checks.py
@@ -1,5 +1,5 @@
-from django.core.checks import Error
from django.conf import settings
+from django.core.checks import Error
def check_login_scopes_setting(*args, **kwargs):
diff --git a/allianceauth/authentication/core/celery_workers.py b/allianceauth/authentication/core/celery_workers.py
index ceb1f40d..c1e91bfe 100644
--- a/allianceauth/authentication/core/celery_workers.py
+++ b/allianceauth/authentication/core/celery_workers.py
@@ -2,7 +2,6 @@
import itertools
import logging
-from typing import Optional
from amqp.exceptions import ChannelError
from celery import current_app
diff --git a/allianceauth/authentication/decorators.py b/allianceauth/authentication/decorators.py
index 81403615..e54f34b0 100644
--- a/allianceauth/authentication/decorators.py
+++ b/allianceauth/authentication/decorators.py
@@ -1,15 +1,11 @@
-from django.urls import include
-from django.contrib.auth.decorators import user_passes_test
-from django.core.exceptions import PermissionDenied
-from functools import wraps
-from typing import Optional
from collections.abc import Callable, Iterable
+from functools import wraps
-from django.urls import include
from django.contrib import messages
from django.contrib.auth.decorators import login_required, user_passes_test
from django.core.exceptions import PermissionDenied
from django.shortcuts import redirect
+from django.urls import include
from django.utils.translation import gettext_lazy as _
diff --git a/allianceauth/authentication/forms.py b/allianceauth/authentication/forms.py
index fabff9d9..a4959abd 100644
--- a/allianceauth/authentication/forms.py
+++ b/allianceauth/authentication/forms.py
@@ -60,7 +60,7 @@ class UserChangeForm(BaseUserChangeForm):
{
"groups": _(
"You are not allowed to add or remove these "
- "restricted groups: %s" % restricted_names
+ "restricted groups: {}".format(restricted_names)
)
}
)
diff --git a/allianceauth/authentication/hmac_urls.py b/allianceauth/authentication/hmac_urls.py
index 61bcd99b..9538582a 100644
--- a/allianceauth/authentication/hmac_urls.py
+++ b/allianceauth/authentication/hmac_urls.py
@@ -1,5 +1,6 @@
+from django.urls import include, path, re_path
+
from allianceauth.authentication import views
-from django.urls import include, re_path, path
urlpatterns = [
path('activate/complete/', views.activation_complete, name='registration_activation_complete'),
diff --git a/allianceauth/authentication/management/commands/checkmains.py b/allianceauth/authentication/management/commands/checkmains.py
index 5605687b..fad33078 100644
--- a/allianceauth/authentication/management/commands/checkmains.py
+++ b/allianceauth/authentication/management/commands/checkmains.py
@@ -1,4 +1,5 @@
from django.core.management.base import BaseCommand
+
from allianceauth.authentication.models import UserProfile
@@ -11,8 +12,7 @@ class Command(BaseCommand):
if profiles.exists():
for profile in profiles:
self.stdout.write(self.style.ERROR(
- '{} does not have an ownership. Resetting user {} main character.'.format(profile.main_character,
- profile.user)))
+ f'{profile.main_character} does not have an ownership. Resetting user {profile.user} main character.'))
profile.main_character = None
profile.save()
self.stdout.write(self.style.WARNING(f'Reset {profiles.count()} main characters.'))
diff --git a/allianceauth/authentication/managers.py b/allianceauth/authentication/managers.py
index 5959db96..3e16b3c2 100644
--- a/allianceauth/authentication/managers.py
+++ b/allianceauth/authentication/managers.py
@@ -1,7 +1,7 @@
import logging
from django.db import transaction
-from django.db.models import Manager, QuerySet, Q
+from django.db.models import Manager, Q, QuerySet
from allianceauth.eveonline.models import EveCharacter
diff --git a/allianceauth/authentication/middleware.py b/allianceauth/authentication/middleware.py
index ca28d92f..15f0b431 100644
--- a/allianceauth/authentication/middleware.py
+++ b/allianceauth/authentication/middleware.py
@@ -1,8 +1,8 @@
+import logging
+
from django.conf import settings
from django.utils.deprecation import MiddlewareMixin
-import logging
-
logger = logging.getLogger(__name__)
diff --git a/allianceauth/authentication/migrations/0001_initial.py b/allianceauth/authentication/migrations/0001_initial.py
index a7d3ff64..1c3a8842 100644
--- a/allianceauth/authentication/migrations/0001_initial.py
+++ b/allianceauth/authentication/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# Generated by Django 1.10.1 on 2016-09-05 21:38
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/allianceauth/authentication/migrations/0004_create_permissions.py b/allianceauth/authentication/migrations/0004_create_permissions.py
index 1f938d21..7b2042f9 100644
--- a/allianceauth/authentication/migrations/0004_create_permissions.py
+++ b/allianceauth/authentication/migrations/0004_create_permissions.py
@@ -2,6 +2,7 @@
from django.db import migrations
+
def create_permissions(apps, schema_editor):
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
diff --git a/allianceauth/authentication/migrations/0005_delete_perms.py b/allianceauth/authentication/migrations/0005_delete_perms.py
index e870b8cd..d61a27af 100644
--- a/allianceauth/authentication/migrations/0005_delete_perms.py
+++ b/allianceauth/authentication/migrations/0005_delete_perms.py
@@ -2,6 +2,7 @@
from django.db import migrations
+
def delete_permissions(apps, schema_editor):
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
diff --git a/allianceauth/authentication/migrations/0010_only_one_authservicesinfo.py b/allianceauth/authentication/migrations/0010_only_one_authservicesinfo.py
index a88bb301..86d6175c 100644
--- a/allianceauth/authentication/migrations/0010_only_one_authservicesinfo.py
+++ b/allianceauth/authentication/migrations/0010_only_one_authservicesinfo.py
@@ -2,6 +2,7 @@
from django.db import migrations
+
def count_completed_fields(model):
return len([True for key, value in model.__dict__.items() if bool(value)])
diff --git a/allianceauth/authentication/migrations/0011_authservicesinfo_user_onetoonefield.py b/allianceauth/authentication/migrations/0011_authservicesinfo_user_onetoonefield.py
index d12f2875..e1c28b19 100644
--- a/allianceauth/authentication/migrations/0011_authservicesinfo_user_onetoonefield.py
+++ b/allianceauth/authentication/migrations/0011_authservicesinfo_user_onetoonefield.py
@@ -1,8 +1,8 @@
# Generated by Django 1.10.1 on 2017-01-07 07:11
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/allianceauth/authentication/migrations/0012_remove_add_delete_authservicesinfo_permissions.py b/allianceauth/authentication/migrations/0012_remove_add_delete_authservicesinfo_permissions.py
index 60fcc189..7949ab59 100644
--- a/allianceauth/authentication/migrations/0012_remove_add_delete_authservicesinfo_permissions.py
+++ b/allianceauth/authentication/migrations/0012_remove_add_delete_authservicesinfo_permissions.py
@@ -1,6 +1,7 @@
# Generated by Django 1.10.5 on 2017-01-12 00:59
-from django.db import migrations, models
+from django.db import migrations
+
def remove_permissions(apps, schema_editor):
ContentType = apps.get_model('contenttypes', 'ContentType')
diff --git a/allianceauth/authentication/migrations/0013_service_modules.py b/allianceauth/authentication/migrations/0013_service_modules.py
index f046905c..871e070b 100644
--- a/allianceauth/authentication/migrations/0013_service_modules.py
+++ b/allianceauth/authentication/migrations/0013_service_modules.py
@@ -1,9 +1,9 @@
# Generated by Django 1.10.2 on 2016-12-11 23:14
-from django.db import migrations
-
import logging
+from django.db import migrations
+
logger = logging.getLogger(__name__)
diff --git a/allianceauth/authentication/migrations/0015_user_profiles.py b/allianceauth/authentication/migrations/0015_user_profiles.py
index 10ba691c..48ecdefb 100644
--- a/allianceauth/authentication/migrations/0015_user_profiles.py
+++ b/allianceauth/authentication/migrations/0015_user_profiles.py
@@ -1,11 +1,12 @@
# Generated by Django 1.10.5 on 2017-03-22 23:09
-import allianceauth.authentication.models
import django.db.models.deletion
from django.conf import settings
from django.contrib.auth.hashers import make_password
from django.db import migrations, models
+import allianceauth.authentication.models
+
def create_guest_state(apps, schema_editor):
State = apps.get_model('authentication', 'State')
diff --git a/allianceauth/authentication/migrations/0016_ownershiprecord.py b/allianceauth/authentication/migrations/0016_ownershiprecord.py
index b2df6d8d..91887454 100644
--- a/allianceauth/authentication/migrations/0016_ownershiprecord.py
+++ b/allianceauth/authentication/migrations/0016_ownershiprecord.py
@@ -1,8 +1,8 @@
# Generated by Django 2.0.4 on 2018-04-14 18:28
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
def create_initial_records(apps, schema_editor):
diff --git a/allianceauth/authentication/models.py b/allianceauth/authentication/models.py
index 714f1934..dd22883d 100644
--- a/allianceauth/authentication/models.py
+++ b/allianceauth/authentication/models.py
@@ -1,11 +1,11 @@
import logging
-from django.contrib.auth.models import User, Permission
+from django.contrib.auth.models import Permission, User
from django.db import models, transaction
from django.utils.translation import gettext_lazy as _
-from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo, EveAllianceInfo, EveFactionInfo
+
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo, EveFactionInfo
from allianceauth.notifications import notify
-from django.conf import settings
from .managers import CharacterOwnershipManager, StateManager
@@ -60,8 +60,7 @@ def get_guest_state_pk():
class UserProfile(models.Model):
- class Meta:
- default_permissions = ('change',)
+
class Language(models.TextChoices):
"""
@@ -108,10 +107,15 @@ class UserProfile(models.Model):
_("Theme"),
max_length=200,
blank=True,
- null=True,
help_text="Bootstrap 5 Themes from https://bootswatch.com/ or Community Apps"
)
+ class Meta:
+ default_permissions = ('change',)
+
+ def __str__(self) -> str:
+ return str(self.user)
+
def assign_state(self, state=None, commit=True):
if not state:
state = State.objects.get_for_user(self.user)
@@ -122,7 +126,7 @@ class UserProfile(models.Model):
self.save(update_fields=['state'])
notify(
self.user,
- _('State changed to: %s' % state),
+ _('State changed to: {}'.format(state)),
_('Your user\'s state is now: %(state)s')
% ({'state': state}),
'info'
@@ -137,19 +141,18 @@ class UserProfile(models.Model):
sender=self.__class__, user=self.user, state=self.state
)
- def __str__(self):
- return str(self.user)
+
class CharacterOwnership(models.Model):
- class Meta:
- default_permissions = ('change', 'delete')
- ordering = ['user', 'character__character_name']
+
character = models.OneToOneField(EveCharacter, on_delete=models.CASCADE, related_name='character_ownership')
owner_hash = models.CharField(max_length=28, unique=True)
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='character_ownerships')
objects = CharacterOwnershipManager()
-
+ class Meta:
+ default_permissions = ('change', 'delete')
+ ordering = ['user', 'character__character_name']
def __str__(self):
return f"{self.user}: {self.character}"
diff --git a/allianceauth/authentication/signals.py b/allianceauth/authentication/signals.py
index dfb9ba1b..10c278a0 100644
--- a/allianceauth/authentication/signals.py
+++ b/allianceauth/authentication/signals.py
@@ -1,19 +1,16 @@
import logging
-from .models import (
- CharacterOwnership,
- UserProfile,
- get_guest_state,
- State,
- OwnershipRecord)
from django.contrib.auth.models import User
from django.db.models import Q
-from django.db.models.signals import pre_save, post_save, pre_delete, post_delete, m2m_changed
-from django.dispatch import receiver, Signal
+from django.db.models.signals import m2m_changed, post_delete, post_save, pre_delete, pre_save
+from django.dispatch import Signal, receiver
+
from esi.models import Token
from allianceauth.eveonline.models import EveCharacter
+from .models import CharacterOwnership, OwnershipRecord, State, UserProfile, get_guest_state
+
logger = logging.getLogger(__name__)
state_changed = Signal()
@@ -108,8 +105,7 @@ def record_character_ownership(sender, instance, created, *args, **kwargs):
def validate_main_character(sender, instance, *args, **kwargs):
try:
if instance.user.profile.main_character == instance.character:
- logger.info("Ownership of a main character {} has been revoked. Resetting {} main character.".format(
- instance.character, instance.user))
+ logger.info(f"Ownership of a main character {instance.character} has been revoked. Resetting {instance.user} main character.")
# clear main character as user no longer owns them
instance.user.profile.main_character = None
instance.user.profile.save()
diff --git a/allianceauth/authentication/task_statistics/counters.py b/allianceauth/authentication/task_statistics/counters.py
index 6d1f6175..3d146343 100644
--- a/allianceauth/authentication/task_statistics/counters.py
+++ b/allianceauth/authentication/task_statistics/counters.py
@@ -1,7 +1,7 @@
"""Counters for Task Statistics."""
import datetime as dt
-from typing import NamedTuple, Optional
+from typing import NamedTuple
from .event_series import EventSeries
diff --git a/allianceauth/authentication/task_statistics/event_series.py b/allianceauth/authentication/task_statistics/event_series.py
index 3eb96abe..b602ef04 100644
--- a/allianceauth/authentication/task_statistics/event_series.py
+++ b/allianceauth/authentication/task_statistics/event_series.py
@@ -2,7 +2,6 @@
import datetime as dt
import logging
-from typing import List, Optional
from pytz import utc
from redis import Redis
diff --git a/allianceauth/authentication/task_statistics/signals.py b/allianceauth/authentication/task_statistics/signals.py
index e9d7babc..5f12bfac 100644
--- a/allianceauth/authentication/task_statistics/signals.py
+++ b/allianceauth/authentication/task_statistics/signals.py
@@ -1,7 +1,11 @@
"""Signals for Task Statistics."""
from celery.signals import (
- task_failure, task_internal_error, task_retry, task_success, worker_ready,
+ task_failure,
+ task_internal_error,
+ task_retry,
+ task_success,
+ worker_ready,
)
from django.conf import settings
diff --git a/allianceauth/authentication/task_statistics/tests/test_counters.py b/allianceauth/authentication/task_statistics/tests/test_counters.py
index 2d2555aa..96494b4c 100644
--- a/allianceauth/authentication/task_statistics/tests/test_counters.py
+++ b/allianceauth/authentication/task_statistics/tests/test_counters.py
@@ -4,7 +4,10 @@ from django.test import TestCase
from django.utils.timezone import now
from allianceauth.authentication.task_statistics.counters import (
- dashboard_results, failed_tasks, retried_tasks, succeeded_tasks,
+ dashboard_results,
+ failed_tasks,
+ retried_tasks,
+ succeeded_tasks,
)
diff --git a/allianceauth/authentication/task_statistics/tests/test_helpers.py b/allianceauth/authentication/task_statistics/tests/test_helpers.py
index 51dae201..45edffd7 100644
--- a/allianceauth/authentication/task_statistics/tests/test_helpers.py
+++ b/allianceauth/authentication/task_statistics/tests/test_helpers.py
@@ -4,7 +4,8 @@ from unittest.mock import patch
from redis import RedisError
from allianceauth.authentication.task_statistics.helpers import (
- _RedisStub, get_redis_client_or_stub,
+ _RedisStub,
+ get_redis_client_or_stub,
)
MODULE_PATH = "allianceauth.authentication.task_statistics.helpers"
diff --git a/allianceauth/authentication/task_statistics/tests/test_signals.py b/allianceauth/authentication/task_statistics/tests/test_signals.py
index 1e1634bd..d04f11e2 100644
--- a/allianceauth/authentication/task_statistics/tests/test_signals.py
+++ b/allianceauth/authentication/task_statistics/tests/test_signals.py
@@ -10,8 +10,8 @@ from allianceauth.authentication.task_statistics.counters import (
succeeded_tasks,
)
from allianceauth.authentication.task_statistics.signals import (
- reset_counters,
is_enabled,
+ reset_counters,
)
from allianceauth.eveonline.tasks import update_character
diff --git a/allianceauth/authentication/tasks.py b/allianceauth/authentication/tasks.py
index eaf3c59a..ff5f7e63 100644
--- a/allianceauth/authentication/tasks.py
+++ b/allianceauth/authentication/tasks.py
@@ -1,9 +1,10 @@
import logging
-from esi.errors import TokenExpiredError, TokenInvalidError, IncompleteResponseError
-from esi.models import Token
from celery import shared_task
+from esi.errors import IncompleteResponseError, TokenExpiredError, TokenInvalidError
+from esi.models import Token
+
from allianceauth.authentication.models import CharacterOwnership
logger = logging.getLogger(__name__)
@@ -22,8 +23,7 @@ def check_character_ownership(owner_hash):
continue
except (KeyError, IncompleteResponseError):
# We can't validate the hash hasn't changed but also can't assume it has. Abort for now.
- logger.warning("Failed to validate owner hash of {} due to problems contacting SSO servers.".format(
- tokens[0].character_name))
+ logger.warning(f"Failed to validate owner hash of {tokens[0].character_name} due to problems contacting SSO servers.")
break
if not t.character_owner_hash == old_hash:
@@ -33,7 +33,7 @@ def check_character_ownership(owner_hash):
break
if not Token.objects.filter(character_owner_hash=owner_hash).exists():
- logger.info('No tokens found with owner hash %s. Revoking ownership.' % owner_hash)
+ logger.info(f'No tokens found with owner hash {owner_hash}. Revoking ownership.')
CharacterOwnership.objects.filter(owner_hash=owner_hash).delete()
diff --git a/allianceauth/authentication/tests/__init__.py b/allianceauth/authentication/tests/__init__.py
index 13410df4..55fd9fe9 100644
--- a/allianceauth/authentication/tests/__init__.py
+++ b/allianceauth/authentication/tests/__init__.py
@@ -1,12 +1,7 @@
-from django.db.models.signals import (
- m2m_changed,
- post_save,
- pre_delete,
- pre_save
-)
-from django.urls import reverse
from unittest import mock
+from django.urls import reverse
+
MODULE_PATH = 'allianceauth.authentication'
@@ -17,9 +12,7 @@ def patch(target, *args, **kwargs):
def get_admin_change_view_url(obj: object) -> str:
"""returns URL to admin change view for given object"""
return reverse(
- 'admin:{}_{}_change'.format(
- obj._meta.app_label, type(obj).__name__.lower()
- ),
+ f'admin:{obj._meta.app_label}_{type(obj).__name__.lower()}_change',
args=(obj.pk,)
)
diff --git a/allianceauth/authentication/tests/core/test_celery_workers.py b/allianceauth/authentication/tests/core/test_celery_workers.py
index 95bec08d..5551c318 100644
--- a/allianceauth/authentication/tests/core/test_celery_workers.py
+++ b/allianceauth/authentication/tests/core/test_celery_workers.py
@@ -5,7 +5,8 @@ from amqp.exceptions import ChannelError
from django.test import TestCase
from allianceauth.authentication.core.celery_workers import (
- active_tasks_count, queued_tasks_count,
+ active_tasks_count,
+ queued_tasks_count,
)
MODULE_PATH = "allianceauth.authentication.core.celery_workers"
diff --git a/allianceauth/authentication/tests/test_admin.py b/allianceauth/authentication/tests/test_admin.py
index 0f43a14c..26d389b7 100644
--- a/allianceauth/authentication/tests/test_admin.py
+++ b/allianceauth/authentication/tests/test_admin.py
@@ -1,42 +1,37 @@
-from bs4 import BeautifulSoup
+from unittest.mock import MagicMock, patch
from urllib.parse import quote
-from unittest.mock import patch, MagicMock
+from bs4 import BeautifulSoup
from django_webtest import WebTest
from django.contrib.admin.sites import AdminSite
from django.contrib.auth.models import Group
-from django.test import TestCase, RequestFactory, Client
+from django.test import Client, RequestFactory, TestCase
-from allianceauth.authentication.models import (
- CharacterOwnership, State, OwnershipRecord
-)
-from allianceauth.eveonline.models import (
- EveCharacter, EveCorporationInfo, EveAllianceInfo, EveFactionInfo
-)
+from allianceauth.authentication.models import CharacterOwnership, OwnershipRecord, State
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo, EveFactionInfo
from allianceauth.services.hooks import ServicesHook
from allianceauth.tests.auth_utils import AuthUtils
from ..admin import (
BaseUserAdmin,
CharacterOwnershipAdmin,
- StateAdmin,
- MainCorporationsFilter,
MainAllianceFilter,
+ MainCorporationsFilter,
MainFactionFilter,
OwnershipRecordAdmin,
+ StateAdmin,
User,
UserAdmin,
+ make_service_hooks_sync_nickname_action,
+ make_service_hooks_update_groups_action,
+ update_main_character_model,
user_main_organization,
user_profile_pic,
user_username,
- update_main_character_model,
- make_service_hooks_update_groups_action,
- make_service_hooks_sync_nickname_action
)
from . import get_admin_change_view_url, get_admin_search_url
-
MODULE_PATH = 'allianceauth.authentication.admin'
@@ -327,15 +322,15 @@ class TestUserAdmin(TestCaseWithTestData):
def test_user_username_u1(self):
expected = (
- ''
- 'Bruce_Wayne
Bruce Wayne'.format(self.user_1.pk)
+ f''
+ 'Bruce_Wayne
Bruce Wayne'
)
self.assertEqual(user_username(self.user_1), expected)
def test_user_username_u3(self):
expected = (
- ''
- 'Lex_Luthor'.format(self.user_3.pk)
+ f''
+ 'Lex_Luthor'
)
self.assertEqual(user_username(self.user_3), expected)
diff --git a/allianceauth/authentication/tests/test_app_settings.py b/allianceauth/authentication/tests/test_app_settings.py
index 8fa9d368..5dd62930 100644
--- a/allianceauth/authentication/tests/test_app_settings.py
+++ b/allianceauth/authentication/tests/test_app_settings.py
@@ -1,4 +1,5 @@
from unittest.mock import Mock, patch
+
from django.test import TestCase
from .. import app_settings
@@ -83,7 +84,7 @@ class TestSetAppSetting(TestCase):
self.assertEqual(result, 50)
@patch(MODULE_PATH + '.app_settings.settings')
- def test_default_for_invalid_type_int(self, mock_settings):
+ def test_default_for_outofrange_int(self, mock_settings):
mock_settings.TEST_SETTING_DUMMY = 1000
result = app_settings._clean_setting(
'TEST_SETTING_DUMMY',
@@ -96,7 +97,7 @@ class TestSetAppSetting(TestCase):
def test_default_is_none_needs_required_type(self, mock_settings):
mock_settings.TEST_SETTING_DUMMY = 'invalid type'
with self.assertRaises(ValueError):
- result = app_settings._clean_setting(
+ app_settings._clean_setting(
'TEST_SETTING_DUMMY',
default_value=None
)
diff --git a/allianceauth/authentication/tests/test_backend.py b/allianceauth/authentication/tests/test_backend.py
index 92936355..d4969877 100644
--- a/allianceauth/authentication/tests/test_backend.py
+++ b/allianceauth/authentication/tests/test_backend.py
@@ -1,13 +1,13 @@
-from django.contrib.auth.models import User, Group
+from django.contrib.auth.models import Group, User
from django.test import TestCase
+from esi.models import Token
+
from allianceauth.eveonline.models import EveCharacter
from allianceauth.tests.auth_utils import AuthUtils
-from esi.models import Token
-
from ..backends import StateBackend
-from ..models import CharacterOwnership, UserProfile, OwnershipRecord
+from ..models import CharacterOwnership, OwnershipRecord, UserProfile
MODULE_PATH = 'allianceauth.authentication'
diff --git a/allianceauth/authentication/tests/test_decorators.py b/allianceauth/authentication/tests/test_decorators.py
index 5b729d01..5a2fd39c 100644
--- a/allianceauth/authentication/tests/test_decorators.py
+++ b/allianceauth/authentication/tests/test_decorators.py
@@ -6,12 +6,11 @@ from django.contrib.auth.models import AnonymousUser
from django.http.response import HttpResponse
from django.test import TestCase
from django.test.client import RequestFactory
-from django.urls import reverse, URLPattern
+from django.urls import URLPattern, reverse
from allianceauth.eveonline.models import EveCharacter
from allianceauth.tests.auth_utils import AuthUtils
-
from ..decorators import decorate_url_patterns, main_character_required
from ..models import CharacterOwnership
@@ -47,7 +46,7 @@ class DecoratorTestCase(TestCase):
@mock.patch(MODULE_PATH + '.decorators.messages')
def test_login_redirect(self, m):
- setattr(self.request, 'user', AnonymousUser())
+ self.request.user = AnonymousUser()
response = self.dummy_view(self.request)
self.assertEqual(response.status_code, 302)
url = getattr(response, 'url', None)
@@ -55,7 +54,7 @@ class DecoratorTestCase(TestCase):
@mock.patch(MODULE_PATH + '.decorators.messages')
def test_main_character_redirect(self, m):
- setattr(self.request, 'user', self.no_main_user)
+ self.request.user = self.no_main_user
response = self.dummy_view(self.request)
self.assertEqual(response.status_code, 302)
url = getattr(response, 'url', None)
@@ -63,7 +62,7 @@ class DecoratorTestCase(TestCase):
@mock.patch(MODULE_PATH + '.decorators.messages')
def test_successful_request(self, m):
- setattr(self.request, 'user', self.main_user)
+ self.request.user = self.main_user
response = self.dummy_view(self.request)
self.assertEqual(response.status_code, 200)
diff --git a/allianceauth/authentication/tests/test_middleware.py b/allianceauth/authentication/tests/test_middleware.py
index 70335e58..5f94abbd 100644
--- a/allianceauth/authentication/tests/test_middleware.py
+++ b/allianceauth/authentication/tests/test_middleware.py
@@ -1,10 +1,10 @@
-from unittest import mock
-from allianceauth.authentication.middleware import UserSettingsMiddleware
from unittest.mock import Mock
-from django.http import HttpResponse
+from django.http import HttpResponse
from django.test.testcases import TestCase
+from allianceauth.authentication.middleware import UserSettingsMiddleware
+
class TestUserSettingsMiddlewareSaveLang(TestCase):
@@ -39,7 +39,7 @@ class TestUserSettingsMiddlewareSaveLang(TestCase):
of a non-existent (anonymous) user
"""
self.request.user.is_anonymous = True
- response = self.middleware.process_response(
+ self.middleware.process_response(
self.request,
self.response
)
@@ -52,7 +52,7 @@ class TestUserSettingsMiddlewareSaveLang(TestCase):
does the middleware change a language not set in the DB
"""
self.request.user.profile.language = None
- response = self.middleware.process_response(
+ self.middleware.process_response(
self.request,
self.response
)
@@ -64,7 +64,7 @@ class TestUserSettingsMiddlewareSaveLang(TestCase):
"""
Tests the middleware will change a language setting
"""
- response = self.middleware.process_response(
+ self.middleware.process_response(
self.request,
self.response
)
@@ -158,7 +158,7 @@ class TestUserSettingsMiddlewareLoginFlow(TestCase):
tests the middleware will set night_mode if not set
"""
self.request.session = {}
- response = self.middleware.process_response(
+ self.middleware.process_response(
self.request,
self.response
)
@@ -168,7 +168,7 @@ class TestUserSettingsMiddlewareLoginFlow(TestCase):
"""
tests the middleware will set night_mode if set.
"""
- response = self.middleware.process_response(
+ self.middleware.process_response(
self.request,
self.response
)
diff --git a/allianceauth/authentication/tests/test_models.py b/allianceauth/authentication/tests/test_models.py
index 4dca31ff..2f963708 100644
--- a/allianceauth/authentication/tests/test_models.py
+++ b/allianceauth/authentication/tests/test_models.py
@@ -3,12 +3,12 @@ from unittest import mock
from django.contrib.auth.models import User
from django.test import TestCase
-from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo,\
- EveAllianceInfo, EveFactionInfo
-from allianceauth.tests.auth_utils import AuthUtils
from esi.errors import IncompleteResponseError
from esi.models import Token
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo, EveFactionInfo
+from allianceauth.tests.auth_utils import AuthUtils
+
from ..models import CharacterOwnership, State, get_guest_state
from ..tasks import check_character_ownership
diff --git a/allianceauth/authentication/tests/test_signals.py b/allianceauth/authentication/tests/test_signals.py
index 8f7ba716..3336677e 100644
--- a/allianceauth/authentication/tests/test_signals.py
+++ b/allianceauth/authentication/tests/test_signals.py
@@ -1,19 +1,11 @@
+
+from django.db.models.signals import post_save
+from django.test.testcases import TestCase
+
from allianceauth.authentication.models import User, UserProfile
-from allianceauth.eveonline.models import (
- EveCharacter,
- EveCorporationInfo,
- EveAllianceInfo
-)
-from django.db.models.signals import (
- pre_save,
- post_save,
- pre_delete,
- m2m_changed
-)
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo
from allianceauth.tests.auth_utils import AuthUtils
-from django.test.testcases import TestCase
-from unittest.mock import Mock
from . import patch
diff --git a/allianceauth/authentication/tests/test_templatetags.py b/allianceauth/authentication/tests/test_templatetags.py
index 450da33e..7f42f830 100644
--- a/allianceauth/authentication/tests/test_templatetags.py
+++ b/allianceauth/authentication/tests/test_templatetags.py
@@ -9,8 +9,12 @@ from django.core.cache import cache
from django.test import TestCase
from allianceauth.templatetags.admin_status import (
- _current_notifications, _current_version_summary, _fetch_list_from_gitlab,
- _fetch_notification_issues_from_gitlab, _latests_versions, status_overview,
+ _current_notifications,
+ _current_version_summary,
+ _fetch_list_from_gitlab,
+ _fetch_notification_issues_from_gitlab,
+ _latests_versions,
+ status_overview,
)
MODULE_PATH = 'allianceauth.templatetags'
@@ -127,7 +131,7 @@ class TestNotifications(TestCase):
# when
result = _current_notifications()
# then
- self.assertEqual(result['notifications'], list())
+ self.assertEqual(result['notifications'], [])
@patch(MODULE_PATH + '.admin_status.cache')
def test_current_notifications_is_none(self, mock_cache):
@@ -136,7 +140,7 @@ class TestNotifications(TestCase):
# when
result = _current_notifications()
# then
- self.assertEqual(result['notifications'], list())
+ self.assertEqual(result['notifications'], [])
class TestCeleryQueueLength(TestCase):
diff --git a/allianceauth/authentication/tests/test_views.py b/allianceauth/authentication/tests/test_views.py
index ec7601a9..14394938 100644
--- a/allianceauth/authentication/tests/test_views.py
+++ b/allianceauth/authentication/tests/test_views.py
@@ -1,12 +1,13 @@
import json
-import requests_mock
from unittest.mock import patch
+import requests_mock
+
from django.test import RequestFactory, TestCase
-from allianceauth.authentication.views import task_counts, esi_check
-from allianceauth.tests.auth_utils import AuthUtils
from allianceauth.authentication.constants import ESI_ERROR_MESSAGE_OVERRIDES
+from allianceauth.authentication.views import esi_check, task_counts
+from allianceauth.tests.auth_utils import AuthUtils
MODULE_PATH = "allianceauth.authentication.views"
diff --git a/allianceauth/authentication/views.py b/allianceauth/authentication/views.py
index 2e8f4e2c..392a0a44 100644
--- a/allianceauth/authentication/views.py
+++ b/allianceauth/authentication/views.py
@@ -1,11 +1,6 @@
import logging
import requests
-from django_registration.backends.activation.views import (
- REGISTRATION_SALT, ActivationView as BaseActivationView,
- RegistrationView as BaseRegistrationView,
-)
-from django_registration.signals import user_registered
from django.conf import settings
from django.contrib import messages
@@ -18,6 +13,12 @@ from django.shortcuts import redirect, render
from django.template.loader import render_to_string
from django.urls import reverse, reverse_lazy
from django.utils.translation import gettext_lazy as _
+from django_registration.backends.activation.views import (
+ REGISTRATION_SALT,
+ ActivationView as BaseActivationView,
+ RegistrationView as BaseRegistrationView,
+)
+from django_registration.signals import user_registered
from esi.decorators import token_required
from esi.models import Token
@@ -32,7 +33,7 @@ from .models import CharacterOwnership
if 'allianceauth.eveonline.autogroups' in settings.INSTALLED_APPS:
_has_auto_groups = True
- from allianceauth.eveonline.autogroups.models import * # noqa: F401, F403
+ from allianceauth.eveonline.autogroups.models import * # noqa: F403
else:
_has_auto_groups = False
@@ -87,7 +88,7 @@ def dashboard_esi_check(request):
@login_required
def dashboard(request):
- _dash_items = list()
+ _dash_items = []
hooks = get_hooks('dashboard_hook')
items = [fn() for fn in hooks]
items.sort(key=lambda i: i.order)
@@ -164,9 +165,7 @@ def main_character_change(request, token):
request.user.profile.save(update_fields=['main_character'])
messages.success(request, _('Changed main character to %s') % co.character)
logger.info(
- 'Changed user {user} main character to {char}'.format(
- user=request.user, char=co.character
- )
+ f'Changed user {request.user} main character to {co.character}'
)
return redirect("authentication:dashboard")
@@ -176,10 +175,9 @@ def add_character(request, token):
if CharacterOwnership.objects.filter(character__character_id=token.character_id).filter(
owner_hash=token.character_owner_hash).filter(user=request.user).exists():
messages.success(request, _(
- 'Added %(name)s to your account.' % ({'name': token.character_name})))
+ 'Added {name} to your account.'.format(name=token.character_name)))
else:
- messages.error(request, _('Failed to add %(name)s to your account: they already have an account.' % (
- {'name': token.character_name})))
+ messages.error(request, _('Failed to add {name} to your account: they already have an account.'.format(name=token.character_name)))
return redirect('authentication:dashboard')
@@ -294,7 +292,7 @@ class RegistrationView(BaseRegistrationView):
return redirect(settings.LOGIN_URL)
if not getattr(settings, 'REGISTRATION_VERIFY_EMAIL', True):
# Keep the request so the user can be automagically logged in.
- setattr(self, 'request', request)
+ self.request = request
return super().dispatch(request, *args, **kwargs)
def register(self, form):
diff --git a/allianceauth/bin/allianceauth.py b/allianceauth/bin/allianceauth.py
index 20cfb53d..cd400526 100644
--- a/allianceauth/bin/allianceauth.py
+++ b/allianceauth/bin/allianceauth.py
@@ -2,6 +2,7 @@
import os
import shutil
from optparse import OptionParser
+
from django.core.management import call_command
from django.core.management.commands.startproject import Command as BaseStartProject
@@ -43,7 +44,7 @@ def create_project(parser, options, args):
# Call the command with extra context
call_command(StartProject(), *args, **command_options)
- print(f"Success! {args[0]} has been created.") # noqa
+ print(f"Success! {args[0]} has been created.")
def update_settings(parser, options, args):
@@ -62,7 +63,7 @@ def update_settings(parser, options, args):
# next check if given path is to the project, so the app is within it
settings_path = os.path.join(project_path, project_name, 'settings/base.py')
if not os.path.exists(settings_path):
- parser.error("Unable to locate the Alliance Auth project at %s" % project_path)
+ parser.error(f"Unable to locate the Alliance Auth project at {project_path}")
# first find the path to the Alliance Auth template settings
import allianceauth
diff --git a/allianceauth/checks.py b/allianceauth/checks.py
index 704f6e6e..e6d0319d 100644
--- a/allianceauth/checks.py
+++ b/allianceauth/checks.py
@@ -1,12 +1,16 @@
-from django import db
-from django.core.checks import CheckMessage, Error, register, Warning
-from allianceauth.utils.cache import get_redis_client
-from django.utils import timezone
-from packaging.version import InvalidVersion, Version as Pep440Version
-from celery import current_app
-from django.conf import settings
-from sqlite3.dbapi2 import sqlite_version_info
import datetime
+from sqlite3.dbapi2 import sqlite_version_info
+
+from celery import current_app
+from packaging.version import InvalidVersion, Version as Pep440Version
+
+from django import db
+from django.conf import settings
+from django.core.checks import CheckMessage, Error, Warning, register
+from django.utils import timezone
+
+from allianceauth.utils.cache import get_redis_client
+
"""
A = System Packages
B = Configuration
@@ -101,8 +105,7 @@ def system_package_mariadb(app_configs, **kwargs) -> list[CheckMessage]:
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A011"))
elif mariadb_version.major == 11 and mariadb_version.minor == 1:
errors.append(Warning(f"MariaDB {mariadb_version.public} Non LTS", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A019"))
- if timezone.now() > timezone.datetime(year=2024, month=8, day=21, tzinfo=datetime.timezone.utc):
- errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A012"))
+ errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A012"))
elif mariadb_version.major == 11 and mariadb_version.minor in [0, 3]: # Demote versions down here once EOL
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config.", id="allianceauth.checks.A013"))
@@ -168,7 +171,7 @@ def celery_settings(app_configs, **kwargs) -> list[CheckMessage]:
errors.append(Error("Celery Priorities are not set", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/8861ec0a61790eca0261f1adc1cc04ca5f243cbc", id="allianceauth.checks.B003"))
try:
- if current_app.conf.broker_connection_retry_on_startup != True:
+ if current_app.conf.broker_connection_retry_on_startup is not True:
errors.append(Error("Celery broker_connection_retry_on_startup not set correctly", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/380c41400b535447839e5552df2410af35a75280", id="allianceauth.checks.B004"))
except KeyError:
errors.append(Error("Celery broker_connection_retry_on_startup not set", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/380c41400b535447839e5552df2410af35a75280", id="allianceauth.checks.B004"))
diff --git a/allianceauth/context_processors.py b/allianceauth/context_processors.py
index 4feb243e..cbc75a0e 100644
--- a/allianceauth/context_processors.py
+++ b/allianceauth/context_processors.py
@@ -1,4 +1,5 @@
from django.conf import settings
+
from .views import NightModeRedirectView
diff --git a/allianceauth/corputils/admin.py b/allianceauth/corputils/admin.py
index e0cdda66..c0a8de55 100644
--- a/allianceauth/corputils/admin.py
+++ b/allianceauth/corputils/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
-from .models import CorpStats, CorpMember
+from .models import CorpMember, CorpStats
admin.site.register(CorpStats)
admin.site.register(CorpMember)
diff --git a/allianceauth/corputils/auth_hooks.py b/allianceauth/corputils/auth_hooks.py
index 4dd3e8ce..4414898c 100644
--- a/allianceauth/corputils/auth_hooks.py
+++ b/allianceauth/corputils/auth_hooks.py
@@ -1,8 +1,9 @@
-from allianceauth.menu.hooks import MenuItemHook
-from allianceauth.services.hooks import UrlHook
from django.utils.translation import gettext_lazy as _
+
from allianceauth import hooks
from allianceauth.corputils import urls
+from allianceauth.menu.hooks import MenuItemHook
+from allianceauth.services.hooks import UrlHook
class CorpStats(MenuItemHook):
diff --git a/allianceauth/corputils/managers.py b/allianceauth/corputils/managers.py
index 87b2ffdd..f7bca4f9 100644
--- a/allianceauth/corputils/managers.py
+++ b/allianceauth/corputils/managers.py
@@ -1,6 +1,7 @@
-from django.db import models
import logging
+from django.db import models
+
logger = logging.getLogger(__name__)
@@ -8,7 +9,7 @@ class CorpStatsQuerySet(models.QuerySet):
def visible_to(self, user):
# superusers get all visible
if user.is_superuser:
- logger.debug('Returning all corpstats for superuser %s.' % user)
+ logger.debug(f'Returning all corpstats for superuser {user}.')
return self
try:
@@ -36,7 +37,7 @@ class CorpStatsQuerySet(models.QuerySet):
query |= q
return self.filter(query)
except AssertionError:
- logger.debug('User %s has no main character. No corpstats visible.' % user)
+ logger.debug(f'User {user} has no main character. No corpstats visible.')
return self.none()
diff --git a/allianceauth/corputils/migrations/0001_initial.py b/allianceauth/corputils/migrations/0001_initial.py
index 49d71b75..e7439525 100644
--- a/allianceauth/corputils/migrations/0001_initial.py
+++ b/allianceauth/corputils/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# Generated by Django 1.10.1 on 2016-12-14 21:36
-from django.db import migrations, models
import django.db.models.deletion
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/allianceauth/corputils/migrations/0002_migrate_permissions.py b/allianceauth/corputils/migrations/0002_migrate_permissions.py
index fce155e4..cd75c9dc 100644
--- a/allianceauth/corputils/migrations/0002_migrate_permissions.py
+++ b/allianceauth/corputils/migrations/0002_migrate_permissions.py
@@ -66,7 +66,7 @@ def forward(apps, schema_editor):
g.permissions.add(perm_dict['corpstats']['alliance_apis'].pk)
g.permissions.add(perm_dict['corpstats']['view_alliance_corpstats'].pk)
- for name, perm in perm_dict['user'].items():
+ for _name, perm in perm_dict['user'].items():
perm.delete()
diff --git a/allianceauth/corputils/migrations/0004_member_models.py b/allianceauth/corputils/migrations/0004_member_models.py
index b8e2e291..8359669b 100644
--- a/allianceauth/corputils/migrations/0004_member_models.py
+++ b/allianceauth/corputils/migrations/0004_member_models.py
@@ -1,9 +1,10 @@
# Generated by Django 1.10.5 on 2017-03-26 20:13
-from django.db import migrations, models
-import django.db.models.deletion
import json
+import django.db.models.deletion
+from django.db import migrations, models
+
def convert_json_to_members(apps, schema_editor):
CorpStats = apps.get_model('corputils', 'CorpStats')
diff --git a/allianceauth/corputils/models.py b/allianceauth/corputils/models.py
index 7ac03b7e..a98ec5cb 100644
--- a/allianceauth/corputils/models.py
+++ b/allianceauth/corputils/models.py
@@ -1,15 +1,17 @@
import logging
import os
-from allianceauth.authentication.models import CharacterOwnership, UserProfile
from bravado.exception import HTTPForbidden
+
from django.db import models
+
from esi.errors import TokenError
from esi.models import Token
-from allianceauth.eveonline.models import EveCorporationInfo, EveCharacter, EveAllianceInfo
-from allianceauth.notifications import notify
+from allianceauth.authentication.models import CharacterOwnership, UserProfile
from allianceauth.corputils.managers import CorpStatsManager
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo
+from allianceauth.notifications import notify
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
"""
@@ -31,6 +33,7 @@ class CorpStats(models.Model):
corp = models.OneToOneField(EveCorporationInfo, on_delete=models.CASCADE)
last_update = models.DateTimeField(auto_now=True)
+ objects = CorpStatsManager()
class Meta:
permissions = (
('view_corp_corpstats', 'Can view corp stats of their corporation.'),
@@ -40,7 +43,7 @@ class CorpStats(models.Model):
verbose_name = "corp stats"
verbose_name_plural = "corp stats"
- objects = CorpStatsManager()
+
def __str__(self):
return f"{self.__class__.__name__} for {self.corp}"
@@ -76,21 +79,21 @@ class CorpStats(models.Model):
logger.warning(f"{self} failed to update: {e}")
if self.token.user:
notify(
- self.token.user, "%s failed to update with your ESI token." % self,
+ self.token.user, f"{self} failed to update with your ESI token.",
message="Your token has expired or is no longer valid. Please add a new one to create a new CorpStats.",
level="error")
self.delete()
except HTTPForbidden as e:
logger.warning(f"{self} failed to update: {e}")
if self.token.user:
- notify(self.token.user, "%s failed to update with your ESI token." % self, message=f"{e.status_code}: {e.message}", level="error")
+ notify(self.token.user, f"{self} failed to update with your ESI token.", message=f"{e.status_code}: {e.message}", level="error")
self.delete()
except AssertionError:
- logger.warning("%s token character no longer in corp." % self)
+ logger.warning(f"{self} token character no longer in corp.")
if self.token.user:
notify(
- self.token.user, "%s cannot update with your ESI token." % self,
- message="%s cannot update with your ESI token as you have left corp." % self, level="error")
+ self.token.user, f"{self} cannot update with your ESI token.",
+ message=f"{self} cannot update with your ESI token as you have left corp.", level="error")
self.delete()
@property
diff --git a/allianceauth/corputils/tasks.py b/allianceauth/corputils/tasks.py
index 6cc016fa..fda7c5fb 100644
--- a/allianceauth/corputils/tasks.py
+++ b/allianceauth/corputils/tasks.py
@@ -1,4 +1,5 @@
from celery import shared_task
+
from allianceauth.corputils.models import CorpStats
diff --git a/allianceauth/corputils/tests.py b/allianceauth/corputils/tests.py
index 43e1f720..176541b3 100644
--- a/allianceauth/corputils/tests.py
+++ b/allianceauth/corputils/tests.py
@@ -1,14 +1,18 @@
from unittest import mock
-from django.test import TestCase
-from allianceauth.tests.auth_utils import AuthUtils
-from .models import CorpStats, CorpMember
-from allianceauth.eveonline.models import EveCorporationInfo, EveAllianceInfo, EveCharacter
-from esi.models import Token
-from esi.errors import TokenError
from bravado.exception import HTTPForbidden
+
from django.contrib.auth.models import Permission
+from django.test import TestCase
+
+from esi.errors import TokenError
+from esi.models import Token
+
from allianceauth.authentication.models import CharacterOwnership
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo
+from allianceauth.tests.auth_utils import AuthUtils
+
+from .models import CorpMember, CorpStats
class CorpStatsManagerTestCase(TestCase):
diff --git a/allianceauth/corputils/urls.py b/allianceauth/corputils/urls.py
index 5f66c48e..7729d721 100644
--- a/allianceauth/corputils/urls.py
+++ b/allianceauth/corputils/urls.py
@@ -1,4 +1,5 @@
from django.urls import path
+
from . import views
app_name = 'corputils'
diff --git a/allianceauth/corputils/views.py b/allianceauth/corputils/views.py
index 98367aef..d0e62690 100644
--- a/allianceauth/corputils/views.py
+++ b/allianceauth/corputils/views.py
@@ -1,16 +1,19 @@
import os
from bravado.exception import HTTPError
+
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required, user_passes_test
-from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
+from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.db import IntegrityError
-from django.shortcuts import render, redirect, get_object_or_404
+from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import gettext_lazy as _
+
from esi.decorators import token_required
+
from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo
-from .models import CorpStats, CorpMember
+from .models import CorpMember, CorpStats
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
"""
diff --git a/allianceauth/custom_css/admin.py b/allianceauth/custom_css/admin.py
index 093e18e8..e7af932d 100644
--- a/allianceauth/custom_css/admin.py
+++ b/allianceauth/custom_css/admin.py
@@ -3,14 +3,15 @@ Admin classes for custom_css app
"""
# Django
-from django.contrib import admin
-
# Django Solos
from solo.admin import SingletonModelAdmin
+from django.contrib import admin
+
+from allianceauth.custom_css.forms import CustomCSSAdminForm
+
# Alliance Auth Custom CSS
from allianceauth.custom_css.models import CustomCSS
-from allianceauth.custom_css.forms import CustomCSSAdminForm
@admin.register(CustomCSS)
diff --git a/allianceauth/custom_css/forms.py b/allianceauth/custom_css/forms.py
index 6823b204..1b3f5955 100644
--- a/allianceauth/custom_css/forms.py
+++ b/allianceauth/custom_css/forms.py
@@ -3,12 +3,12 @@ Forms for custom_css app
"""
# Alliance Auth Custom CSS
-from allianceauth.custom_css.models import CustomCSS
-from allianceauth.custom_css.widgets import CssEditorWidget
-
# Django
from django import forms
+from allianceauth.custom_css.models import CustomCSS
+from allianceauth.custom_css.widgets import CssEditorWidget
+
class CustomCSSAdminForm(forms.ModelForm):
"""
diff --git a/allianceauth/custom_css/models.py b/allianceauth/custom_css/models.py
index c831cf6b..2b116fb4 100644
--- a/allianceauth/custom_css/models.py
+++ b/allianceauth/custom_css/models.py
@@ -21,7 +21,6 @@ class CustomCSS(SingletonModel):
css = models.TextField(
blank=True,
- null=True,
verbose_name=_("Your custom CSS"),
help_text=_("This CSS will be added to the site after the default CSS."),
)
diff --git a/allianceauth/custom_css/templatetags/custom_css.py b/allianceauth/custom_css/templatetags/custom_css.py
index 3c01602f..1234c587 100644
--- a/allianceauth/custom_css/templatetags/custom_css.py
+++ b/allianceauth/custom_css/templatetags/custom_css.py
@@ -3,7 +3,7 @@ Custom template tags for custom_css app
"""
# Alliance Auth Custom CSS
-from allianceauth.custom_css.models import CustomCSS
+from pathlib import Path
# Django
from django.conf import settings
@@ -11,7 +11,7 @@ from django.template.defaulttags import register
from django.templatetags.static import static
from django.utils.safestring import mark_safe
-from pathlib import Path
+from allianceauth.custom_css.models import CustomCSS
@register.simple_tag
diff --git a/allianceauth/custom_css/widgets.py b/allianceauth/custom_css/widgets.py
index 32ed07dd..1c3a6290 100644
--- a/allianceauth/custom_css/widgets.py
+++ b/allianceauth/custom_css/widgets.py
@@ -6,7 +6,6 @@ Form widgets for custom_css app
from django import forms
# Alliance Auth
-from allianceauth.custom_css.models import CustomCSS
class CssEditorWidget(forms.Textarea):
diff --git a/allianceauth/eveonline/admin.py b/allianceauth/eveonline/admin.py
index e37e8aaa..69d428df 100644
--- a/allianceauth/eveonline/admin.py
+++ b/allianceauth/eveonline/admin.py
@@ -1,12 +1,9 @@
from django import forms
from django.contrib import admin
from django.core.exceptions import ObjectDoesNotExist
-from .providers import ObjectNotFound
-from .models import EveAllianceInfo
-from .models import EveCharacter
-from .models import EveCorporationInfo
-from .models import EveFactionInfo
+from .models import EveAllianceInfo, EveCharacter, EveCorporationInfo, EveFactionInfo
+from .providers import ObjectNotFound
class EveEntityExistsError(forms.ValidationError):
diff --git a/allianceauth/eveonline/autogroups/admin.py b/allianceauth/eveonline/autogroups/admin.py
index 240d4578..e202de92 100644
--- a/allianceauth/eveonline/autogroups/admin.py
+++ b/allianceauth/eveonline/autogroups/admin.py
@@ -1,9 +1,9 @@
-from django.contrib import admin
-from django.db import models
-from .models import AutogroupsConfig, ManagedCorpGroup, ManagedAllianceGroup
-
import logging
+from django.contrib import admin
+from django.db import models
+
+from .models import AutogroupsConfig, ManagedAllianceGroup, ManagedCorpGroup
logger = logging.getLogger(__name__)
diff --git a/allianceauth/eveonline/autogroups/apps.py b/allianceauth/eveonline/autogroups/apps.py
index 69ca1b22..61d4bbe2 100644
--- a/allianceauth/eveonline/autogroups/apps.py
+++ b/allianceauth/eveonline/autogroups/apps.py
@@ -6,4 +6,4 @@ class EveAutogroupsConfig(AppConfig):
label = 'eve_autogroups'
def ready(self):
- import allianceauth.eveonline.autogroups.signals
+ pass
diff --git a/allianceauth/eveonline/autogroups/migrations/0001_initial.py b/allianceauth/eveonline/autogroups/migrations/0001_initial.py
index 33c1ab42..9716d3af 100644
--- a/allianceauth/eveonline/autogroups/migrations/0001_initial.py
+++ b/allianceauth/eveonline/autogroups/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# Generated by Django 1.11.6 on 2017-12-23 04:30
-from django.db import migrations, models
import django.db.models.deletion
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/allianceauth/eveonline/autogroups/models.py b/allianceauth/eveonline/autogroups/models.py
index 88bc3ece..3f28f313 100644
--- a/allianceauth/eveonline/autogroups/models.py
+++ b/allianceauth/eveonline/autogroups/models.py
@@ -1,10 +1,11 @@
import logging
-from django.db import models, transaction
+
from django.contrib.auth.models import Group, User
from django.core.exceptions import ObjectDoesNotExist
+from django.db import models, transaction
from allianceauth.authentication.models import State
-from allianceauth.eveonline.models import EveCorporationInfo, EveAllianceInfo
+from allianceauth.eveonline.models import EveAllianceInfo, EveCorporationInfo
logger = logging.getLogger(__name__)
@@ -80,15 +81,15 @@ class AutogroupsConfig(models.Model):
objects = AutogroupsConfigManager()
+ def __str__(self):
+ return 'States: ' + (' '.join(list(self.states.all().values_list('name', flat=True))) if self.pk else str(None))
+
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def __repr__(self):
return self.__class__.__name__
- def __str__(self):
- return 'States: ' + (' '.join(list(self.states.all().values_list('name', flat=True))) if self.pk else str(None))
-
def update_all_states_group_membership(self):
list(map(self.update_group_membership_for_state, self.states.all()))
@@ -235,7 +236,7 @@ class ManagedGroup(models.Model):
abstract = True
def __str__(self):
- return "Managed Group: %s" % self.group.name
+ return f"Managed Group: {self.group.name}"
class ManagedCorpGroup(ManagedGroup):
corp = models.ForeignKey(EveCorporationInfo, on_delete=models.CASCADE)
diff --git a/allianceauth/eveonline/autogroups/signals.py b/allianceauth/eveonline/autogroups/signals.py
index c2b8c11a..9b920d1b 100644
--- a/allianceauth/eveonline/autogroups/signals.py
+++ b/allianceauth/eveonline/autogroups/signals.py
@@ -1,7 +1,9 @@
import logging
+
+from django.db.models.signals import m2m_changed, post_save, pre_delete, pre_save
from django.dispatch import receiver
-from django.db.models.signals import pre_save, post_save, pre_delete, m2m_changed
-from allianceauth.authentication.models import UserProfile, State
+
+from allianceauth.authentication.models import State, UserProfile
from allianceauth.eveonline.models import EveCharacter
from .models import AutogroupsConfig
diff --git a/allianceauth/eveonline/autogroups/tests/__init__.py b/allianceauth/eveonline/autogroups/tests/__init__.py
index cd1c4d68..8af31c2c 100644
--- a/allianceauth/eveonline/autogroups/tests/__init__.py
+++ b/allianceauth/eveonline/autogroups/tests/__init__.py
@@ -1,7 +1,10 @@
from unittest import mock
-from django.db.models.signals import pre_save, post_save, pre_delete, m2m_changed
+
+from django.db.models.signals import m2m_changed, post_save, pre_delete, pre_save
+
from allianceauth.authentication.models import UserProfile
from allianceauth.authentication.signals import reassess_on_profile_save
+
from .. import signals
from ..models import AutogroupsConfig
diff --git a/allianceauth/eveonline/autogroups/tests/test_managers.py b/allianceauth/eveonline/autogroups/tests/test_managers.py
index e4e42ef0..e3afec8f 100644
--- a/allianceauth/eveonline/autogroups/tests/test_managers.py
+++ b/allianceauth/eveonline/autogroups/tests/test_managers.py
@@ -1,4 +1,5 @@
from django.test import TestCase
+
from allianceauth.tests.auth_utils import AuthUtils
from ..models import AutogroupsConfig
diff --git a/allianceauth/eveonline/autogroups/tests/test_models.py b/allianceauth/eveonline/autogroups/tests/test_models.py
index f9c59389..7b6f8f89 100644
--- a/allianceauth/eveonline/autogroups/tests/test_models.py
+++ b/allianceauth/eveonline/autogroups/tests/test_models.py
@@ -1,15 +1,11 @@
-from django.test import TestCase
from django.contrib.auth.models import Group
-from django.db import transaction
+from django.test import TestCase
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo
from allianceauth.tests.auth_utils import AuthUtils
-from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo, EveAllianceInfo
-
from ..models import AutogroupsConfig, get_users_for_state
-
-
-from . import patch, connect_signals, disconnect_signals
+from . import connect_signals, disconnect_signals, patch
class AutogroupsConfigTestCase(TestCase):
diff --git a/allianceauth/eveonline/autogroups/tests/test_signals.py b/allianceauth/eveonline/autogroups/tests/test_signals.py
index 0ff3aa4c..6911b68c 100644
--- a/allianceauth/eveonline/autogroups/tests/test_signals.py
+++ b/allianceauth/eveonline/autogroups/tests/test_signals.py
@@ -1,13 +1,11 @@
-from django.test import TestCase
from django.contrib.auth.models import User
+from django.test import TestCase
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo
from allianceauth.tests.auth_utils import AuthUtils
-from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo, EveAllianceInfo
-
from ..models import AutogroupsConfig
-
-from . import patch, disconnect_signals, connect_signals
+from . import connect_signals, disconnect_signals, patch
class SignalsTestCase(TestCase):
diff --git a/allianceauth/eveonline/evelinks/dotlan.py b/allianceauth/eveonline/evelinks/dotlan.py
index b782eabd..b067b338 100644
--- a/allianceauth/eveonline/evelinks/dotlan.py
+++ b/allianceauth/eveonline/evelinks/dotlan.py
@@ -1,14 +1,8 @@
# this module generates profile URLs for dotlan
-from urllib.parse import urljoin, quote
-
-from . import (
- _ESI_CATEGORY_ALLIANCE,
- _ESI_CATEGORY_CORPORATION,
- _ESI_CATEGORY_REGION,
- _ESI_CATEGORY_SOLARSYSTEM
-)
+from urllib.parse import quote, urljoin
+from . import _ESI_CATEGORY_ALLIANCE, _ESI_CATEGORY_CORPORATION, _ESI_CATEGORY_REGION, _ESI_CATEGORY_SOLARSYSTEM
_BASE_URL = 'http://evemaps.dotlan.net'
diff --git a/allianceauth/eveonline/evelinks/eveimageserver.py b/allianceauth/eveonline/evelinks/eveimageserver.py
index 172c1bbc..aa0570a2 100644
--- a/allianceauth/eveonline/evelinks/eveimageserver.py
+++ b/allianceauth/eveonline/evelinks/eveimageserver.py
@@ -1,10 +1,4 @@
-from . import (
- _ESI_CATEGORY_ALLIANCE,
- _ESI_CATEGORY_CHARACTER,
- _ESI_CATEGORY_CORPORATION,
- _ESI_CATEGORY_INVENTORYTYPE
-)
-
+from . import _ESI_CATEGORY_ALLIANCE, _ESI_CATEGORY_CHARACTER, _ESI_CATEGORY_CORPORATION, _ESI_CATEGORY_INVENTORYTYPE
_EVE_IMAGE_SERVER_URL = 'https://images.evetech.net'
_DEFAULT_IMAGE_SIZE = 32
@@ -70,10 +64,7 @@ def _eve_entity_image_url(
if variant:
if variant not in categories[category]['variants']:
- raise ValueError('Invalid variant {} for category {}'.format(
- variant,
- category
- ))
+ raise ValueError(f'Invalid variant {variant} for category {category}')
else:
variant = categories[category]['variants'][0]
@@ -81,13 +72,7 @@ def _eve_entity_image_url(
raise ValueError(f'Invalid tenant {tenant}')
# compose result URL
- result = '{}/{}/{}/{}?size={}'.format(
- _EVE_IMAGE_SERVER_URL,
- endpoint,
- entity_id,
- variant,
- size
- )
+ result = f'{_EVE_IMAGE_SERVER_URL}/{endpoint}/{entity_id}/{variant}?size={size}'
if tenant:
result += f'&tenant={tenant}'
diff --git a/allianceauth/eveonline/evelinks/evewho.py b/allianceauth/eveonline/evelinks/evewho.py
index 6fd05b14..52385953 100644
--- a/allianceauth/eveonline/evelinks/evewho.py
+++ b/allianceauth/eveonline/evelinks/evewho.py
@@ -4,11 +4,10 @@ from urllib.parse import urljoin
from . import (
_ESI_CATEGORY_ALLIANCE,
- _ESI_CATEGORY_CORPORATION,
_ESI_CATEGORY_CHARACTER,
+ _ESI_CATEGORY_CORPORATION,
)
-
_BASE_URL = 'https://evewho.com'
diff --git a/allianceauth/eveonline/evelinks/tests/test_evelinks.py b/allianceauth/eveonline/evelinks/tests/test_evelinks.py
index 32f79f05..955854cf 100644
--- a/allianceauth/eveonline/evelinks/tests/test_evelinks.py
+++ b/allianceauth/eveonline/evelinks/tests/test_evelinks.py
@@ -1,8 +1,6 @@
from django.test import TestCase
-from ...models import EveCharacter, EveCorporationInfo, EveAllianceInfo
-from .. import dotlan, zkillboard, evewho, eveimageserver
-from ...templatetags import evelinks
+from .. import dotlan, eveimageserver, evewho, zkillboard
class TestEveWho(TestCase):
diff --git a/allianceauth/eveonline/evelinks/tests/test_templatetags.py b/allianceauth/eveonline/evelinks/tests/test_templatetags.py
index db5c8178..2e96f278 100644
--- a/allianceauth/eveonline/evelinks/tests/test_templatetags.py
+++ b/allianceauth/eveonline/evelinks/tests/test_templatetags.py
@@ -1,8 +1,8 @@
from django.test import TestCase
-from ...models import EveCharacter, EveCorporationInfo, EveAllianceInfo
-from .. import eveimageserver, evewho, dotlan, zkillboard
+from ...models import EveAllianceInfo, EveCharacter, EveCorporationInfo
from ...templatetags import evelinks
+from .. import dotlan, eveimageserver, evewho, zkillboard
class TestTemplateTags(TestCase):
diff --git a/allianceauth/eveonline/evelinks/zkillboard.py b/allianceauth/eveonline/evelinks/zkillboard.py
index 3bba9833..4ce84bb2 100644
--- a/allianceauth/eveonline/evelinks/zkillboard.py
+++ b/allianceauth/eveonline/evelinks/zkillboard.py
@@ -4,13 +4,12 @@ from urllib.parse import urljoin
from . import (
_ESI_CATEGORY_ALLIANCE,
- _ESI_CATEGORY_CORPORATION,
_ESI_CATEGORY_CHARACTER,
+ _ESI_CATEGORY_CORPORATION,
_ESI_CATEGORY_REGION,
- _ESI_CATEGORY_SOLARSYSTEM
+ _ESI_CATEGORY_SOLARSYSTEM,
)
-
_BASE_URL = 'https://zkillboard.com'
diff --git a/allianceauth/eveonline/managers.py b/allianceauth/eveonline/managers.py
index 5e849edc..eff9b31e 100644
--- a/allianceauth/eveonline/managers.py
+++ b/allianceauth/eveonline/managers.py
@@ -1,6 +1,7 @@
import logging
from django.db import models
+
from . import providers
logger = logging.getLogger(__name__)
diff --git a/allianceauth/eveonline/migrations/0001_initial.py b/allianceauth/eveonline/migrations/0001_initial.py
index a647ca0b..d45d329c 100644
--- a/allianceauth/eveonline/migrations/0001_initial.py
+++ b/allianceauth/eveonline/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# Generated by Django 1.10.1 on 2016-09-05 21:39
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/allianceauth/eveonline/migrations/0003_auto_20161026_0149.py b/allianceauth/eveonline/migrations/0003_auto_20161026_0149.py
index 0dda48fa..9cfdef65 100644
--- a/allianceauth/eveonline/migrations/0003_auto_20161026_0149.py
+++ b/allianceauth/eveonline/migrations/0003_auto_20161026_0149.py
@@ -1,8 +1,8 @@
# Generated by Django 1.10.2 on 2016-10-26 01:49
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/allianceauth/eveonline/migrations/0009_on_delete.py b/allianceauth/eveonline/migrations/0009_on_delete.py
index d47b068b..668ca3da 100644
--- a/allianceauth/eveonline/migrations/0009_on_delete.py
+++ b/allianceauth/eveonline/migrations/0009_on_delete.py
@@ -1,7 +1,7 @@
# Generated by Django 1.11.5 on 2017-09-28 02:16
-from django.db import migrations, models
import django.db.models.deletion
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/allianceauth/eveonline/models.py b/allianceauth/eveonline/models.py
index 85993cbd..6c9e621d 100644
--- a/allianceauth/eveonline/models.py
+++ b/allianceauth/eveonline/models.py
@@ -1,8 +1,8 @@
import logging
-from typing import Union
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
+
from esi.models import Token
from allianceauth.notifications import notify
@@ -80,7 +80,8 @@ class EveAllianceInfo(models.Model):
class Meta:
indexes = [models.Index(fields=['executor_corp_id',])]
-
+ def __str__(self):
+ return self.alliance_name
def populate_alliance(self):
alliance = self.provider.get_alliance(self.alliance_id)
for corp_id in alliance.corp_ids:
@@ -100,8 +101,7 @@ class EveAllianceInfo(models.Model):
self.save()
return self
- def __str__(self):
- return self.alliance_name
+
@staticmethod
def generic_logo_url(
@@ -152,7 +152,8 @@ class EveCorporationInfo(models.Model):
class Meta:
indexes = [models.Index(fields=['ceo_id',]),]
-
+ def __str__(self):
+ return self.corporation_name
def update_corporation(self, corp: providers.Corporation = None):
if corp is None:
corp = self.provider.get_corporation(self.corporation_id)
@@ -165,8 +166,7 @@ class EveCorporationInfo(models.Model):
self.save()
return self
- def __str__(self):
- return self.corporation_name
+
@staticmethod
def generic_logo_url(
@@ -209,10 +209,10 @@ class EveCharacter(models.Model):
corporation_name = models.CharField(max_length=254)
corporation_ticker = models.CharField(max_length=5)
alliance_id = models.PositiveIntegerField(blank=True, null=True, default=None)
- alliance_name = models.CharField(max_length=254, blank=True, null=True, default='')
- alliance_ticker = models.CharField(max_length=5, blank=True, null=True, default='')
- faction_id = models.PositiveIntegerField(blank=True, null=True, default=None)
- faction_name = models.CharField(max_length=254, blank=True, null=True, default='')
+ alliance_name = models.CharField(max_length=254, blank=True, default='')
+ alliance_ticker = models.CharField(max_length=5, blank=True, default='')
+ faction_id = models.PositiveIntegerField(blank=True, default=None)
+ faction_name = models.CharField(max_length=254, blank=True, default='')
objects = EveCharacterManager()
provider = EveCharacterProviderManager()
diff --git a/allianceauth/eveonline/providers.py b/allianceauth/eveonline/providers.py
index d8c30604..9ba2db92 100644
--- a/allianceauth/eveonline/providers.py
+++ b/allianceauth/eveonline/providers.py
@@ -1,16 +1,16 @@
import logging
import os
-from bravado.exception import HTTPNotFound, HTTPUnprocessableEntity, HTTPError
+from bravado.exception import HTTPError, HTTPNotFound, HTTPUnprocessableEntity
from jsonschema.exceptions import RefResolutionError
from django.conf import settings
+
from esi.clients import esi_client_factory
from allianceauth import __version__
from allianceauth.utils.django import StartupCommand
-
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'swagger.json'
)
diff --git a/allianceauth/eveonline/tasks.py b/allianceauth/eveonline/tasks.py
index ce2b4219..e753ab93 100644
--- a/allianceauth/eveonline/tasks.py
+++ b/allianceauth/eveonline/tasks.py
@@ -2,9 +2,8 @@ import logging
from celery import shared_task
-from .models import EveAllianceInfo, EveCharacter, EveCorporationInfo
from . import providers
-
+from .models import EveAllianceInfo, EveCharacter, EveCorporationInfo
logger = logging.getLogger(__name__)
diff --git a/allianceauth/eveonline/templatetags/evelinks.py b/allianceauth/eveonline/templatetags/evelinks.py
index e5f44440..4ca6b022 100644
--- a/allianceauth/eveonline/templatetags/evelinks.py
+++ b/allianceauth/eveonline/templatetags/evelinks.py
@@ -14,8 +14,8 @@
from django import template
-from ..models import EveCharacter, EveCorporationInfo, EveAllianceInfo
-from ..evelinks import eveimageserver, evewho, dotlan, zkillboard
+from ..evelinks import dotlan, eveimageserver, evewho, zkillboard
+from ..models import EveAllianceInfo, EveCharacter, EveCorporationInfo
register = template.Library()
@@ -30,7 +30,7 @@ def _generic_character_url(
eve_obj: EveCharacter
) -> str:
"""returns character URL for given provider and object"""
- my_func = getattr(provider, 'character_url')
+ my_func = provider.character_url
if isinstance(eve_obj, EveCharacter):
return my_func(getattr(eve_obj, obj_prop))
@@ -47,8 +47,8 @@ def _generic_corporation_url(
eve_obj: object
) -> str:
"""returns corporation URL for given provider and object"""
- my_func = getattr(provider, 'corporation_url')
- if isinstance(eve_obj, (EveCharacter, EveCorporationInfo)):
+ my_func = provider.corporation_url
+ if isinstance(eve_obj, EveCharacter | EveCorporationInfo):
return my_func(getattr(eve_obj, obj_prop))
elif eve_obj is None:
@@ -64,7 +64,7 @@ def _generic_alliance_url(
eve_obj: object
) -> str:
"""returns alliance URL for given provider and object"""
- my_func = getattr(provider, 'alliance_url')
+ my_func = provider.alliance_url
if isinstance(eve_obj, EveCharacter):
if eve_obj.alliance_id:
diff --git a/allianceauth/eveonline/tests/esi_client_stub.py b/allianceauth/eveonline/tests/esi_client_stub.py
index 1eadfbd3..9382355c 100644
--- a/allianceauth/eveonline/tests/esi_client_stub.py
+++ b/allianceauth/eveonline/tests/esi_client_stub.py
@@ -10,7 +10,7 @@ class BravadoResponseStub:
self.reason = reason
self.status_code = status_code
self.text = text
- self.headers = headers if headers else dict()
+ self.headers = headers if headers else {}
self.raw_bytes = raw_bytes
def __str__(self):
diff --git a/allianceauth/eveonline/tests/test_managers.py b/allianceauth/eveonline/tests/test_managers.py
index 5bab0771..61512ae5 100644
--- a/allianceauth/eveonline/tests/test_managers.py
+++ b/allianceauth/eveonline/tests/test_managers.py
@@ -2,8 +2,8 @@ from unittest import mock
from django.test import TestCase
-from ..models import EveCharacter, EveCorporationInfo, EveAllianceInfo
-from ..providers import Character, Corporation, Alliance
+from ..models import EveAllianceInfo, EveCharacter, EveCorporationInfo
+from ..providers import Alliance, Character, Corporation
class EveCharacterProviderManagerTestCase(TestCase):
@@ -58,7 +58,7 @@ class EveCharacterManagerTestCase(TestCase):
@mock.patch('allianceauth.eveonline.managers.providers.provider')
def test_update_character(self, provider):
# Also covers Model.update_character
- existing = EveCharacter.objects.create(
+ EveCharacter.objects.create(
character_id=1234,
character_name='character.name',
corporation_id=23457,
diff --git a/allianceauth/eveonline/tests/test_models.py b/allianceauth/eveonline/tests/test_models.py
index 94c9614a..e4124718 100644
--- a/allianceauth/eveonline/tests/test_models.py
+++ b/allianceauth/eveonline/tests/test_models.py
@@ -2,6 +2,7 @@ from unittest.mock import Mock, patch
from django.core.exceptions import ObjectDoesNotExist
from django.test import TestCase
+
from esi.models import Token
from allianceauth.tests.auth_utils import AuthUtils
@@ -62,7 +63,7 @@ class EveCharacterTestCase(TestCase):
)
with self.assertRaises(EveCorporationInfo.DoesNotExist):
- character.corporation
+ _ = character.corporation
def test_alliance_prop(self):
"""
@@ -111,7 +112,7 @@ class EveCharacterTestCase(TestCase):
)
with self.assertRaises(EveAllianceInfo.DoesNotExist):
- character.alliance
+ _ = character.alliance
def test_alliance_prop_none(self):
"""
@@ -169,7 +170,7 @@ class EveCharacterTestCase(TestCase):
)
with self.assertRaises(EveFactionInfo.DoesNotExist):
- character.faction
+ _ = character.faction
def test_faction_prop_none(self):
"""
diff --git a/allianceauth/eveonline/tests/test_providers.py b/allianceauth/eveonline/tests/test_providers.py
index 95f4f069..3110979f 100644
--- a/allianceauth/eveonline/tests/test_providers.py
+++ b/allianceauth/eveonline/tests/test_providers.py
@@ -6,20 +6,20 @@ from jsonschema.exceptions import RefResolutionError
from django.test import TestCase
-from . import set_logger
-from .esi_client_stub import EsiClientStub
from ..providers import (
- ObjectNotFound,
- Entity,
+ Alliance,
AllianceMixin,
- FactionMixin,
Character,
Corporation,
- Alliance,
- ItemType,
+ Entity,
EveProvider,
- EveSwaggerProvider
+ EveSwaggerProvider,
+ FactionMixin,
+ ItemType,
+ ObjectNotFound,
)
+from . import set_logger
+from .esi_client_stub import EsiClientStub
MODULE_PATH = 'allianceauth.eveonline.providers'
SWAGGER_OLD_SPEC_PATH = os.path.join(os.path.dirname(
@@ -544,7 +544,7 @@ class TestEveSwaggerProvider(TestCase):
}
mock_result = Mock()
if isinstance(characters, list):
- characters_result = list()
+ characters_result = []
for character_id in characters:
if character_id in character_data:
characters_result.append(character_data[character_id])
diff --git a/allianceauth/fleetactivitytracking/admin.py b/allianceauth/fleetactivitytracking/admin.py
index 6ac8ca30..88d3d8f4 100644
--- a/allianceauth/fleetactivitytracking/admin.py
+++ b/allianceauth/fleetactivitytracking/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
-from allianceauth.fleetactivitytracking.models import Fatlink, Fat
+from allianceauth.fleetactivitytracking.models import Fat, Fatlink
admin.site.register(Fatlink)
admin.site.register(Fat)
diff --git a/allianceauth/fleetactivitytracking/auth_hooks.py b/allianceauth/fleetactivitytracking/auth_hooks.py
index fc5821b2..57b0362d 100644
--- a/allianceauth/fleetactivitytracking/auth_hooks.py
+++ b/allianceauth/fleetactivitytracking/auth_hooks.py
@@ -1,9 +1,11 @@
-from allianceauth.menu.hooks import MenuItemHook
-from . import urls
from django.utils.translation import gettext_lazy as _
+
from allianceauth import hooks
+from allianceauth.menu.hooks import MenuItemHook
from allianceauth.services.hooks import UrlHook
+from . import urls
+
@hooks.register('menu_item_hook')
def register_menu():
diff --git a/allianceauth/fleetactivitytracking/migrations/0002_auto_20160905_2220.py b/allianceauth/fleetactivitytracking/migrations/0002_auto_20160905_2220.py
index 813a7f84..5241d390 100644
--- a/allianceauth/fleetactivitytracking/migrations/0002_auto_20160905_2220.py
+++ b/allianceauth/fleetactivitytracking/migrations/0002_auto_20160905_2220.py
@@ -1,6 +1,7 @@
# Generated by Django 1.10.1 on 2016-09-05 22:20
import datetime
+
from django.db import migrations, models
diff --git a/allianceauth/fleetactivitytracking/migrations/0003_auto_20160906_2354.py b/allianceauth/fleetactivitytracking/migrations/0003_auto_20160906_2354.py
index 435f0a9a..cc14b7ea 100644
--- a/allianceauth/fleetactivitytracking/migrations/0003_auto_20160906_2354.py
+++ b/allianceauth/fleetactivitytracking/migrations/0003_auto_20160906_2354.py
@@ -1,7 +1,7 @@
# Generated by Django 1.10.1 on 2016-09-06 23:54
-from django.db import migrations, models
import django.utils.timezone
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/allianceauth/fleetactivitytracking/models.py b/allianceauth/fleetactivitytracking/models.py
index 3cbd3d63..b4041efc 100644
--- a/allianceauth/fleetactivitytracking/models.py
+++ b/allianceauth/fleetactivitytracking/models.py
@@ -29,4 +29,4 @@ class Fat(models.Model):
unique_together = (('character', 'fatlink'),)
def __str__(self):
- return "Fat-link for %s" % self.character.character_name
+ return f"Fat-link for {self.character.character_name}"
diff --git a/allianceauth/fleetactivitytracking/urls.py b/allianceauth/fleetactivitytracking/urls.py
index 41603150..e38f9154 100644
--- a/allianceauth/fleetactivitytracking/urls.py
+++ b/allianceauth/fleetactivitytracking/urls.py
@@ -1,6 +1,7 @@
from django.urls import path
from . import views
+
app_name = 'fleetactivitytracking'
urlpatterns = [
diff --git a/allianceauth/fleetactivitytracking/views.py b/allianceauth/fleetactivitytracking/views.py
index 232fa456..d7c3ee07 100644
--- a/allianceauth/fleetactivitytracking/views.py
+++ b/allianceauth/fleetactivitytracking/views.py
@@ -2,24 +2,23 @@ import datetime
import logging
import os
-from allianceauth.authentication.models import CharacterOwnership
from django.contrib import messages
-from django.contrib.auth.decorators import login_required
-from django.contrib.auth.decorators import permission_required
+from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.auth.models import User
-from django.core.exceptions import ValidationError, ObjectDoesNotExist
-from django.shortcuts import render, redirect, get_object_or_404, Http404
+from django.core.exceptions import ObjectDoesNotExist, ValidationError
+from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
-from django.utils.translation import gettext_lazy as _
-from esi.decorators import token_required
-from allianceauth.eveonline.providers import provider
-from .forms import FatlinkForm
-from .models import Fatlink, Fat
from django.utils.crypto import get_random_string
+from django.utils.translation import gettext_lazy as _
-from allianceauth.eveonline.models import EveAllianceInfo
-from allianceauth.eveonline.models import EveCharacter
-from allianceauth.eveonline.models import EveCorporationInfo
+from esi.decorators import token_required
+
+from allianceauth.authentication.models import CharacterOwnership
+from allianceauth.eveonline.models import EveAllianceInfo, EveCharacter, EveCorporationInfo
+from allianceauth.eveonline.providers import provider
+
+from .forms import FatlinkForm
+from .models import Fat, Fatlink
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
"""
@@ -50,7 +49,7 @@ class CorpStat:
try:
return "%.2f" % (float(self.n_fats) / float(self.corp.member_count))
except ZeroDivisionError:
- return "%.2f" % 0
+ return f"{0:.2f}"
class MemberStat:
@@ -72,7 +71,7 @@ class MemberStat:
try:
return "%.2f" % (float(self.n_fats) / float(self.n_chars))
except ZeroDivisionError:
- return "%.2f" % 0
+ return f"{0:.2f}"
def first_day_of_next_month(year, month):
@@ -95,7 +94,7 @@ def fatlink_view(request):
# If the user has the right privileges the site will also show the latest fatlinks with the options to add VIPs and
# manually add players.
user = request.user
- logger.debug("fatlink_view called by user %s" % request.user)
+ logger.debug(f"fatlink_view called by user {request.user}")
latest_fats = Fat.objects.select_related('character', 'fatlink').filter(user=user).order_by('-id')[:5]
if user.has_perm('auth.fleetactivitytracking'):
@@ -182,7 +181,7 @@ def fatlink_personal_statistics_view(request, year=datetime.date.today().year):
logger.debug("Personal statistics view for year %i called by %s" % (year, request.user))
user = request.user
- logger.debug("fatlink_personal_statistics_view called by user %s" % request.user)
+ logger.debug(f"fatlink_personal_statistics_view called by user {request.user}")
personal_fats = Fat.objects.select_related('fatlink').filter(user=user).order_by('id')
@@ -227,7 +226,7 @@ def fatlink_monthly_personal_statistics_view(request, year, month, char_id=None)
personal_fats = Fat.objects.filter(user=user)\
.filter(fatlink__fatdatetime__gte=start_of_month).filter(fatlink__fatdatetime__lt=start_of_next_month)
- ship_statistics = dict()
+ ship_statistics = {}
n_fats = 0
for fat in personal_fats:
ship_statistics[fat.shiptype] = ship_statistics.setdefault(fat.shiptype, 0) + 1
@@ -300,7 +299,7 @@ def click_fatlink_view(request, token, fat_hash=None):
except ValidationError as e:
err_messages = []
- for errorname, message in e.message_dict.items():
+ for _errorname, message in e.message_dict.items():
err_messages.append(message[0])
messages.error(request, ' '.join(err_messages))
@@ -330,12 +329,12 @@ def click_fatlink_view(request, token, fat_hash=None):
@login_required
@permission_required('auth.fleetactivitytracking')
def create_fatlink_view(request):
- logger.debug("create_fatlink_view called by user %s" % request.user)
+ logger.debug(f"create_fatlink_view called by user {request.user}")
if request.method == 'POST':
- logger.debug("Post request to create_fatlink_view by user %s" % request.user)
+ logger.debug(f"Post request to create_fatlink_view by user {request.user}")
form = FatlinkForm(request.POST)
if 'submit_fat' in request.POST:
- logger.debug("Submitting fleetactivitytracking by user %s" % request.user)
+ logger.debug(f"Submitting fleetactivitytracking by user {request.user}")
if form.is_valid():
fatlink = Fatlink()
fatlink.fleet = form.cleaned_data["fleet"]
@@ -349,7 +348,7 @@ def create_fatlink_view(request):
except ValidationError as e:
form = FatlinkForm()
messages = []
- for errorname, message in e.message_dict.items():
+ for _errorname, message in e.message_dict.items():
messages.append(message[0].decode())
context = {'form': form, 'errormessages': messages}
return render(request, 'fleetactivitytracking/fatlinkcreate.html', context=context)
@@ -361,7 +360,7 @@ def create_fatlink_view(request):
else:
form = FatlinkForm()
- logger.debug("Returning empty form to user %s" % request.user)
+ logger.debug(f"Returning empty form to user {request.user}")
context = {'form': form}
@@ -371,7 +370,7 @@ def create_fatlink_view(request):
@login_required
@permission_required('auth.fleetactivitytracking')
def modify_fatlink_view(request, fat_hash=None):
- logger.debug("modify_fatlink_view called by user %s" % request.user)
+ logger.debug(f"modify_fatlink_view called by user {request.user}")
fatlink = get_object_or_404(Fatlink, hash=fat_hash)
if request.GET.get('removechar', None):
@@ -382,7 +381,7 @@ def modify_fatlink_view(request, fat_hash=None):
Fat.objects.filter(fatlink=fatlink).filter(character=character).delete()
if request.GET.get('deletefat', None):
- logger.debug("Removing fleetactivitytracking %s" % fatlink)
+ logger.debug(f"Removing fleetactivitytracking {fatlink}")
fatlink.delete()
return redirect('fatlink:view')
diff --git a/allianceauth/framework/api/evecharacter.py b/allianceauth/framework/api/evecharacter.py
index d6a77f05..539f326b 100644
--- a/allianceauth/framework/api/evecharacter.py
+++ b/allianceauth/framework/api/evecharacter.py
@@ -2,7 +2,6 @@
Alliance Auth Evecharacter API
"""
-from typing import Optional
from django.contrib.auth.models import User
diff --git a/allianceauth/framework/api/user.py b/allianceauth/framework/api/user.py
index e1597e72..1be7fbd4 100644
--- a/allianceauth/framework/api/user.py
+++ b/allianceauth/framework/api/user.py
@@ -2,7 +2,6 @@
Alliance Auth User API
"""
-from typing import Optional
from django.contrib.auth.models import User
diff --git a/allianceauth/framework/tests/test_api_user.py b/allianceauth/framework/tests/test_api_user.py
index 1b43b75c..47398063 100644
--- a/allianceauth/framework/tests/test_api_user.py
+++ b/allianceauth/framework/tests/test_api_user.py
@@ -10,9 +10,9 @@ from django.test import TestCase
# Alliance Auth
from allianceauth.framework.api.user import (
- get_sentinel_user,
get_main_character_from_user,
- get_main_character_name_from_user
+ get_main_character_name_from_user,
+ get_sentinel_user,
)
from allianceauth.tests.auth_utils import AuthUtils
diff --git a/allianceauth/groupmanagement/admin.py b/allianceauth/groupmanagement/admin.py
index d51cf7d2..90d83506 100644
--- a/allianceauth/groupmanagement/admin.py
+++ b/allianceauth/groupmanagement/admin.py
@@ -1,16 +1,9 @@
from django.apps import apps
from django.contrib import admin
-
from django.contrib.auth.models import Group as BaseGroup, Permission, User
from django.db.models import Count, Exists, OuterRef
from django.db.models.functions import Lower
-from django.db.models.signals import (
- m2m_changed,
- post_delete,
- post_save,
- pre_delete,
- pre_save
-)
+from django.db.models.signals import m2m_changed, post_delete, post_save, pre_delete, pre_save
from django.dispatch import receiver
from .forms import GroupAdminForm, ReservedGroupNameAdminForm
@@ -172,7 +165,7 @@ class GroupAdmin(admin.ModelAdmin):
return obj.has_leader or obj.has_leader_groups
def _properties(self, obj):
- properties = list()
+ properties = []
if _has_auto_groups and (obj.is_autogroup_corp or obj.is_autogroup_alliance):
properties.append('Auto Group')
elif obj.authgroup.internal:
diff --git a/allianceauth/groupmanagement/auth_hooks.py b/allianceauth/groupmanagement/auth_hooks.py
index 318d2095..1d46e64e 100644
--- a/allianceauth/groupmanagement/auth_hooks.py
+++ b/allianceauth/groupmanagement/auth_hooks.py
@@ -1,8 +1,8 @@
from django.utils.translation import gettext_lazy as _
-from allianceauth.menu.hooks import MenuItemHook
-from allianceauth.services.hooks import UrlHook
from allianceauth import hooks
+from allianceauth.menu.hooks import MenuItemHook
+from allianceauth.services.hooks import UrlHook
from . import urls
from .managers import GroupManager
diff --git a/allianceauth/groupmanagement/managers.py b/allianceauth/groupmanagement/managers.py
index ad8db92e..93e7789f 100644
--- a/allianceauth/groupmanagement/managers.py
+++ b/allianceauth/groupmanagement/managers.py
@@ -4,8 +4,8 @@ from django.contrib.auth.models import Group, User
from django.db.models import Q, QuerySet
from allianceauth.authentication.models import State
-from .models import GroupRequest
+from .models import GroupRequest
logger = logging.getLogger(__name__)
diff --git a/allianceauth/groupmanagement/migrations/0001_initial.py b/allianceauth/groupmanagement/migrations/0001_initial.py
index c6112559..00ca959b 100644
--- a/allianceauth/groupmanagement/migrations/0001_initial.py
+++ b/allianceauth/groupmanagement/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# Generated by Django 1.10.1 on 2016-09-05 21:39
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/allianceauth/groupmanagement/migrations/0002_auto_20160906_2354.py b/allianceauth/groupmanagement/migrations/0002_auto_20160906_2354.py
index 76cef366..74574d76 100644
--- a/allianceauth/groupmanagement/migrations/0002_auto_20160906_2354.py
+++ b/allianceauth/groupmanagement/migrations/0002_auto_20160906_2354.py
@@ -1,7 +1,7 @@
# Generated by Django 1.10.1 on 2016-09-06 23:54
-from django.db import migrations, models
import django.db.models.deletion
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/allianceauth/groupmanagement/migrations/0003_default_groups.py b/allianceauth/groupmanagement/migrations/0003_default_groups.py
index afe1bed0..84472518 100644
--- a/allianceauth/groupmanagement/migrations/0003_default_groups.py
+++ b/allianceauth/groupmanagement/migrations/0003_default_groups.py
@@ -1,7 +1,7 @@
# Generated by Django 1.10.1 on 2016-09-09 23:22
from django.db import migrations
-from django.conf import settings
+
class Migration(migrations.Migration):
diff --git a/allianceauth/groupmanagement/migrations/0004_authgroup.py b/allianceauth/groupmanagement/migrations/0004_authgroup.py
index e3c8848e..9aacb71f 100644
--- a/allianceauth/groupmanagement/migrations/0004_authgroup.py
+++ b/allianceauth/groupmanagement/migrations/0004_authgroup.py
@@ -1,9 +1,9 @@
# Generated by Django 1.10.2 on 2016-12-04 10:25
-from django.conf import settings
-from django.db import migrations, models
-from django.core.exceptions import ObjectDoesNotExist
import django.db.models.deletion
+from django.conf import settings
+from django.core.exceptions import ObjectDoesNotExist
+from django.db import migrations, models
def internal_group(group):
diff --git a/allianceauth/groupmanagement/migrations/0006_request_groups_perm.py b/allianceauth/groupmanagement/migrations/0006_request_groups_perm.py
index 69544c9c..83a4a554 100644
--- a/allianceauth/groupmanagement/migrations/0006_request_groups_perm.py
+++ b/allianceauth/groupmanagement/migrations/0006_request_groups_perm.py
@@ -1,12 +1,9 @@
# Generated by Django 1.10.5 on 2017-02-04 07:17
-from django.db import migrations
-from django.conf import settings
-from django.core.exceptions import ObjectDoesNotExist
-from django.contrib.auth.management import create_permissions
-
import logging
+from django.db import migrations
+
logger = logging.getLogger(__name__)
diff --git a/allianceauth/groupmanagement/migrations/0009_requestlog.py b/allianceauth/groupmanagement/migrations/0009_requestlog.py
index aaff4927..d81d4ae4 100644
--- a/allianceauth/groupmanagement/migrations/0009_requestlog.py
+++ b/allianceauth/groupmanagement/migrations/0009_requestlog.py
@@ -1,8 +1,8 @@
# Generated by Django 2.0.6 on 2018-06-04 02:45
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/allianceauth/groupmanagement/migrations/0011_requestlog_date.py b/allianceauth/groupmanagement/migrations/0011_requestlog_date.py
index fbe535ce..23f8157c 100644
--- a/allianceauth/groupmanagement/migrations/0011_requestlog_date.py
+++ b/allianceauth/groupmanagement/migrations/0011_requestlog_date.py
@@ -1,6 +1,7 @@
# Generated by Django 2.0.8 on 2018-12-07 08:56
import datetime
+
from django.db import migrations, models
diff --git a/allianceauth/groupmanagement/migrations/0018_reservedgroupname.py b/allianceauth/groupmanagement/migrations/0018_reservedgroupname.py
index 0349b9e2..0d0aa83e 100644
--- a/allianceauth/groupmanagement/migrations/0018_reservedgroupname.py
+++ b/allianceauth/groupmanagement/migrations/0018_reservedgroupname.py
@@ -1,7 +1,7 @@
# Generated by Django 3.2.9 on 2021-11-25 18:38
-from django.db import migrations, models
import django.utils.timezone
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/allianceauth/groupmanagement/models.py b/allianceauth/groupmanagement/models.py
index 19e15c72..23bba04b 100644
--- a/allianceauth/groupmanagement/models.py
+++ b/allianceauth/groupmanagement/models.py
@@ -1,4 +1,4 @@
-from typing import Set
+
from django.conf import settings
from django.contrib.auth.models import Group, User
@@ -52,6 +52,9 @@ class RequestLog(models.Model):
request_actor = models.ForeignKey(User, on_delete=models.CASCADE)
date = models.DateTimeField(auto_now_add=True)
+ def __str__(self):
+ return self.pk
+
def requestor(self):
return self.request_info.split(":")[0]
@@ -176,7 +179,7 @@ class AuthGroup(models.Model):
permissions = (
("request_groups", _("Can request non-public groups")),
)
- default_permissions = tuple()
+ default_permissions = ()
def __str__(self):
return self.group.name
diff --git a/allianceauth/groupmanagement/signals.py b/allianceauth/groupmanagement/signals.py
index 60bbeb80..951e9980 100644
--- a/allianceauth/groupmanagement/signals.py
+++ b/allianceauth/groupmanagement/signals.py
@@ -1,6 +1,7 @@
import logging
+
from django.contrib.auth.models import Group
-from django.db.models.signals import pre_save, post_save
+from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
from allianceauth.authentication.signals import state_changed
diff --git a/allianceauth/groupmanagement/tests/__init__.py b/allianceauth/groupmanagement/tests/__init__.py
index 1446ef49..aa4816f5 100644
--- a/allianceauth/groupmanagement/tests/__init__.py
+++ b/allianceauth/groupmanagement/tests/__init__.py
@@ -3,9 +3,6 @@ from django.urls import reverse
def get_admin_change_view_url(obj: object) -> str:
return reverse(
- 'admin:{}_{}_change'.format(
- obj._meta.app_label,
- type(obj).__name__.lower()
- ),
+ f'admin:{obj._meta.app_label}_{type(obj).__name__.lower()}_change',
args=(obj.pk,)
)
diff --git a/allianceauth/groupmanagement/tests/test_admin.py b/allianceauth/groupmanagement/tests/test_admin.py
index 3b9605a1..0f7a1ed1 100644
--- a/allianceauth/groupmanagement/tests/test_admin.py
+++ b/allianceauth/groupmanagement/tests/test_admin.py
@@ -10,7 +10,9 @@ from django.test import Client, RequestFactory, TestCase, override_settings
from allianceauth.authentication.models import CharacterOwnership, State
from allianceauth.eveonline.models import (
- EveAllianceInfo, EveCharacter, EveCorporationInfo,
+ EveAllianceInfo,
+ EveCharacter,
+ EveCorporationInfo,
)
from allianceauth.tests.auth_utils import AuthUtils
diff --git a/allianceauth/groupmanagement/tests/test_managers.py b/allianceauth/groupmanagement/tests/test_managers.py
index f656d99e..2e7ddcb9 100644
--- a/allianceauth/groupmanagement/tests/test_managers.py
+++ b/allianceauth/groupmanagement/tests/test_managers.py
@@ -1,14 +1,14 @@
from django.contrib.auth.models import Group, User
from django.test import TestCase
-from allianceauth.eveonline.models import EveCorporationInfo, EveAllianceInfo
+from allianceauth.eveonline.models import EveAllianceInfo, EveCorporationInfo
from allianceauth.tests.auth_utils import AuthUtils
-from ..models import GroupRequest
from ..managers import GroupManager
+from ..models import GroupRequest
-class MockUserNotAuthenticated():
+class MockUserNotAuthenticated:
def __init__(self):
self.is_authenticated = False
diff --git a/allianceauth/groupmanagement/tests/test_signals.py b/allianceauth/groupmanagement/tests/test_signals.py
index efa35dda..f398f288 100644
--- a/allianceauth/groupmanagement/tests/test_signals.py
+++ b/allianceauth/groupmanagement/tests/test_signals.py
@@ -1,11 +1,10 @@
+from django.contrib.auth.models import Group, User
from django.test import TestCase
-from django.contrib.auth.models import User, Group
-from allianceauth.eveonline.models import EveCorporationInfo
from allianceauth.eveonline.autogroups.models import AutogroupsConfig
+from allianceauth.eveonline.models import EveCorporationInfo
from allianceauth.tests.auth_utils import AuthUtils
-
from ..models import ReservedGroupName
diff --git a/allianceauth/groupmanagement/urls.py b/allianceauth/groupmanagement/urls.py
index 5b27821b..a2d78830 100644
--- a/allianceauth/groupmanagement/urls.py
+++ b/allianceauth/groupmanagement/urls.py
@@ -1,4 +1,5 @@
from django.urls import path
+
from . import views
app_name = "groupmanagement"
diff --git a/allianceauth/groupmanagement/views.py b/allianceauth/groupmanagement/views.py
index 1d1bba87..1c736573 100644
--- a/allianceauth/groupmanagement/views.py
+++ b/allianceauth/groupmanagement/views.py
@@ -21,7 +21,7 @@ logger = logging.getLogger(__name__)
@login_required
@user_passes_test(GroupManager.can_manage_groups)
def group_management(request):
- logger.debug("group_management called by user %s" % request.user)
+ logger.debug(f"group_management called by user {request.user}")
acceptrequests = []
leaverequests = []
@@ -40,8 +40,7 @@ def group_management(request):
else:
acceptrequests.append(grouprequest)
- logger.debug("Providing user {} with {} acceptrequests and {} leaverequests.".format(
- request.user, len(acceptrequests), len(leaverequests)))
+ logger.debug(f"Providing user {request.user} with {len(acceptrequests)} acceptrequests and {len(leaverequests)} leaverequests.")
show_leave_tab = (
getattr(settings, 'GROUPMANAGEMENT_AUTO_LEAVE', False)
@@ -60,7 +59,7 @@ def group_management(request):
@login_required
@user_passes_test(GroupManager.can_manage_groups)
def group_membership(request):
- logger.debug("group_membership called by user %s" % request.user)
+ logger.debug(f"group_membership called by user {request.user}")
# Get all open and closed groups
if GroupManager.has_management_permission(request.user):
# Full access
@@ -79,7 +78,7 @@ def group_membership(request):
@login_required
@user_passes_test(GroupManager.can_manage_groups)
def group_membership_audit(request, group_id):
- logger.debug("group_management_audit called by user %s" % request.user)
+ logger.debug(f"group_management_audit called by user {request.user}")
group = get_object_or_404(Group, id=group_id)
try:
# Check its a joinable group i.e. not corp or internal
@@ -101,8 +100,8 @@ def group_membership_audit(request, group_id):
@user_passes_test(GroupManager.can_manage_groups)
def group_membership_list(request, group_id):
logger.debug(
- "group_membership_list called by user %s "
- "for group id %s" % (request.user, group_id)
+ f"group_membership_list called by user {request.user} "
+ f"for group id {group_id}"
)
group = get_object_or_404(Group, id=group_id)
try:
@@ -113,8 +112,8 @@ def group_membership_list(request, group_id):
or not GroupManager.can_manage_group(request.user, group)
):
logger.warning(
- "User %s attempted to view the membership of group %s "
- "but permission was denied" % (request.user, group_id)
+ f"User {request.user} attempted to view the membership of group {group_id} "
+ "but permission was denied"
)
raise PermissionDenied
@@ -122,7 +121,7 @@ def group_membership_list(request, group_id):
raise Http404("Group does not exist")
group_leaders = group.authgroup.group_leaders.all()
- members = list()
+ members = []
for member in \
group.user_set\
.all()\
@@ -190,20 +189,18 @@ def group_accept_request(request, group_request_id):
log = RequestLog(request_type=group_request.leave_request,group=group,request_info=group_request.__str__(),action=1,request_actor=request.user)
log.save()
group_request.delete()
- logger.info("User {} accepted group request from user {} to group {}".format(
- request.user, group_request.user, group_request.group.name))
+ logger.info(f"User {request.user} accepted group request from user {group_request.user} to group {group_request.group.name}")
notify(group_request.user, "Group Application Accepted", level="success",
- message="Your application to %s has been accepted." % group_request.group)
+ message=f"Your application to {group_request.group} has been accepted.")
messages.success(request,
_('Accepted application from %(mainchar)s to %(group)s.') % {"mainchar": group_request.main_char, "group": group_request.group})
except PermissionDenied as p:
logger.warning(f"User {request.user} attempted to accept group join request {group_request_id} but permission was denied")
raise p
- except:
+ except Exception:
messages.error(request, _('An unhandled error occurred while processing the application from %(mainchar)s to %(group)s.') % {"mainchar": group_request.main_char, "group": group_request.group})
- logger.exception("Unhandled exception occurred while user {} attempting to accept grouprequest id {}.".format(
- request.user, group_request_id))
+ logger.exception(f"Unhandled exception occurred while user {request.user} attempting to accept grouprequest id {group_request_id}.")
pass
return redirect("groupmanagement:management")
@@ -219,22 +216,20 @@ def group_reject_request(request, group_request_id):
raise PermissionDenied
if group_request:
- logger.info("User {} rejected group request from user {} to group {}".format(
- request.user, group_request.user, group_request.group.name))
+ logger.info(f"User {request.user} rejected group request from user {group_request.user} to group {group_request.group.name}")
log = RequestLog(request_type=group_request.leave_request,group=group_request.group,request_info=group_request.__str__(),action=0,request_actor=request.user)
log.save()
group_request.delete()
- notify(group_request.user, "Group Application Rejected", level="danger", message="Your application to %s has been rejected." % group_request.group)
+ notify(group_request.user, "Group Application Rejected", level="danger", message=f"Your application to {group_request.group} has been rejected.")
messages.success(request,
_('Rejected application from %(mainchar)s to %(group)s.') % {"mainchar": group_request.main_char, "group": group_request.group})
except PermissionDenied as p:
logger.warning(f"User {request.user} attempted to reject group join request {group_request_id} but permission was denied")
raise p
- except:
+ except Exception:
messages.error(request, _('An unhandled error occurred while processing the application from %(mainchar)s to %(group)s.') % {"mainchar": group_request.main_char, "group": group_request.group})
- logger.exception("Unhandled exception occurred while user {} attempting to reject group request id {}".format(
- request.user, group_request_id))
+ logger.exception(f"Unhandled exception occurred while user {request.user} attempting to reject group request id {group_request_id}")
pass
return redirect("groupmanagement:management")
@@ -256,20 +251,18 @@ def group_leave_accept_request(request, group_request_id):
log = RequestLog(request_type=group_request.leave_request,group=group_request.group,request_info=group_request.__str__(),action=1,request_actor=request.user)
log.save()
group_request.delete()
- logger.info("User {} accepted group leave request from user {} to group {}".format(
- request.user, group_request.user, group_request.group.name))
+ logger.info(f"User {request.user} accepted group leave request from user {group_request.user} to group {group_request.group.name}")
notify(group_request.user, "Group Leave Request Accepted", level="success",
- message="Your request to leave %s has been accepted." % group_request.group)
+ message=f"Your request to leave {group_request.group} has been accepted.")
messages.success(request,
_('Accepted application from %(mainchar)s to leave %(group)s.') % {"mainchar": group_request.main_char, "group": group_request.group})
except PermissionDenied as p:
logger.warning(f"User {request.user} attempted to accept group leave request {group_request_id} but permission was denied")
raise p
- except:
+ except Exception:
messages.error(request, _('An unhandled error occurred while processing the application from %(mainchar)s to leave %(group)s.') % {
"mainchar": group_request.main_char, "group": group_request.group})
- logger.exception("Unhandled exception occurred while user {} attempting to accept group leave request id {}".format(
- request.user, group_request_id))
+ logger.exception(f"Unhandled exception occurred while user {request.user} attempting to accept group leave request id {group_request_id}")
pass
return redirect("groupmanagement:management")
@@ -289,19 +282,17 @@ def group_leave_reject_request(request, group_request_id):
log = RequestLog(request_type=group_request.leave_request,group=group_request.group,request_info=group_request.__str__(),action=0,request_actor=request.user)
log.save()
group_request.delete()
- logger.info("User {} rejected group leave request from user {} for group {}".format(
- request.user, group_request.user, group_request.group.name))
- notify(group_request.user, "Group Leave Request Rejected", level="danger", message="Your request to leave %s has been rejected." % group_request.group)
+ logger.info(f"User {request.user} rejected group leave request from user {group_request.user} for group {group_request.group.name}")
+ notify(group_request.user, "Group Leave Request Rejected", level="danger", message=f"Your request to leave {group_request.group} has been rejected.")
messages.success(request, _('Rejected application from %(mainchar)s to leave %(group)s.') % {
"mainchar": group_request.main_char, "group": group_request.group})
except PermissionDenied as p:
logger.warning(f"User {request.user} attempted to reject group leave request {group_request_id} but permission was denied")
raise p
- except:
+ except Exception:
messages.error(request, _('An unhandled error occurred while processing the application from %(mainchar)s to leave %(group)s.') % {
"mainchar": group_request.main_char, "group": group_request.group})
- logger.exception("Unhandled exception occurred while user {} attempting to reject group leave request id {}".format(
- request.user, group_request_id))
+ logger.exception(f"Unhandled exception occurred while user {request.user} attempting to reject group leave request id {group_request_id}")
pass
return redirect("groupmanagement:management")
@@ -309,7 +300,7 @@ def group_leave_reject_request(request, group_request_id):
@login_required
def groups_view(request):
- logger.debug("groups_view called by user %s" % request.user)
+ logger.debug(f"groups_view called by user {request.user}")
groups_qs = GroupManager.get_joinable_groups_for_user(
request.user, include_hidden=False
diff --git a/allianceauth/hooks.py b/allianceauth/hooks.py
index 0a91942b..7262f53e 100644
--- a/allianceauth/hooks.py
+++ b/allianceauth/hooks.py
@@ -30,13 +30,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Based on https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailcore/hooks.py
"""
+import logging
from importlib import import_module
from django.apps import apps
from django.utils.module_loading import module_has_submodule
-import logging
-
logger = logging.getLogger(__name__)
_hooks = {} # Dict of Name: Fn's of registered hooks
@@ -64,7 +63,7 @@ def register(name, fn=None):
"""
def _hook_add(func):
if name not in _hooks:
- logger.debug("Creating new hook %s" % name)
+ logger.debug(f"Creating new hook {name}")
_hooks[name] = []
logger.debug(f'Registering hook {name} for function {fn}')
@@ -110,7 +109,7 @@ def register_all_hooks():
if not _all_hooks_registered:
logger.debug("Searching for hooks")
hooks = list(get_app_submodules('auth_hooks'))
- logger.debug("Got %s hooks" % len(hooks))
+ logger.debug(f"Got {len(hooks)} hooks")
_all_hooks_registered = True
@@ -133,6 +132,6 @@ class DashboardItemHook:
try:
logger.debug(f"Rendering {self.view_function} to dashboard")
return self.view_function(request)
- except Exception as e:
+ except Exception:
logger.exception(f"Rendering {self.view_function} failed!")
return ""
diff --git a/allianceauth/hrapplications/admin.py b/allianceauth/hrapplications/admin.py
index f1075da7..3381da0f 100644
--- a/allianceauth/hrapplications/admin.py
+++ b/allianceauth/hrapplications/admin.py
@@ -1,7 +1,13 @@
from django.contrib import admin
-from .models import Application, ApplicationChoice, ApplicationComment, ApplicationForm, ApplicationQuestion, \
- ApplicationResponse
+from .models import (
+ Application,
+ ApplicationChoice,
+ ApplicationComment,
+ ApplicationForm,
+ ApplicationQuestion,
+ ApplicationResponse,
+)
class ChoiceInline(admin.TabularInline):
diff --git a/allianceauth/hrapplications/managers.py b/allianceauth/hrapplications/managers.py
index 7c518520..4e41e5c9 100644
--- a/allianceauth/hrapplications/managers.py
+++ b/allianceauth/hrapplications/managers.py
@@ -1,6 +1,6 @@
+
from django.contrib.auth.models import User
from django.db import models
-from typing import Optional
class ApplicationManager(models.Manager):
diff --git a/allianceauth/hrapplications/migrations/0001_initial.py b/allianceauth/hrapplications/migrations/0001_initial.py
index 466e8b18..7b094c65 100644
--- a/allianceauth/hrapplications/migrations/0001_initial.py
+++ b/allianceauth/hrapplications/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# Generated by Django 1.10.1 on 2016-09-05 21:39
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/allianceauth/hrapplications/migrations/0002_choices_for_questions.py b/allianceauth/hrapplications/migrations/0002_choices_for_questions.py
index 4687a7d6..01815ff7 100644
--- a/allianceauth/hrapplications/migrations/0002_choices_for_questions.py
+++ b/allianceauth/hrapplications/migrations/0002_choices_for_questions.py
@@ -1,7 +1,7 @@
# Generated by Django 1.11.4 on 2017-08-23 19:46
-from django.db import migrations, models
import django.db.models.deletion
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/allianceauth/hrapplications/migrations/0005_sorted_questions.py b/allianceauth/hrapplications/migrations/0005_sorted_questions.py
index 7e32e458..5eabae54 100644
--- a/allianceauth/hrapplications/migrations/0005_sorted_questions.py
+++ b/allianceauth/hrapplications/migrations/0005_sorted_questions.py
@@ -1,9 +1,10 @@
# Generated by Django 1.10.5 on 2017-03-27 03:29
-from django.db import migrations
import sortedm2m.fields
from sortedm2m.operations import AlterSortedManyToManyField
+from django.db import migrations
+
class Migration(migrations.Migration):
diff --git a/allianceauth/hrapplications/models.py b/allianceauth/hrapplications/models.py
index 4767ec7f..2b3414d6 100644
--- a/allianceauth/hrapplications/models.py
+++ b/allianceauth/hrapplications/models.py
@@ -1,6 +1,7 @@
+from sortedm2m.fields import SortedManyToManyField
+
from django.contrib.auth.models import User
from django.db import models
-from sortedm2m.fields import SortedManyToManyField
from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo
@@ -9,7 +10,7 @@ from .managers import ApplicationManager
class ApplicationQuestion(models.Model):
title = models.CharField(max_length=254, verbose_name='Question')
- help_text = models.CharField(max_length=254, blank=True, null=True)
+ help_text = models.CharField(max_length=254, blank=True)
multi_select = models.BooleanField(default=False)
def __str__(self):
@@ -42,8 +43,6 @@ class Application(models.Model):
objects = ApplicationManager()
- def __str__(self):
- return str(self.user) + " Application To " + str(self.form)
class Meta:
permissions = (
@@ -51,6 +50,9 @@ class Application(models.Model):
('view_apis', 'Can view applicant APIs'),)
unique_together = ('form', 'user')
+ def __str__(self):
+ return str(self.user) + " Application To " + str(self.form)
+
@property
def main_character(self):
return self.user.profile.main_character
@@ -73,12 +75,12 @@ class ApplicationResponse(models.Model):
question = models.ForeignKey(ApplicationQuestion, on_delete=models.CASCADE)
application = models.ForeignKey(Application, on_delete=models.CASCADE, related_name='responses')
answer = models.TextField()
-
+ class Meta:
+ unique_together = ('question', 'application')
def __str__(self):
return str(self.application) + " Answer To " + str(self.question)
- class Meta:
- unique_together = ('question', 'application')
+
class ApplicationComment(models.Model):
diff --git a/allianceauth/hrapplications/tests.py b/allianceauth/hrapplications/tests.py
index 7dab4cd1..b9b8ff1e 100644
--- a/allianceauth/hrapplications/tests.py
+++ b/allianceauth/hrapplications/tests.py
@@ -4,7 +4,7 @@ from django.test import TestCase
from allianceauth.eveonline.models import EveCorporationInfo
from allianceauth.tests.auth_utils import AuthUtils
-from .models import Application, ApplicationForm, ApplicationQuestion, ApplicationChoice
+from .models import Application, ApplicationChoice, ApplicationForm, ApplicationQuestion
class TestApplicationManagersPendingRequestsCountForUser(TestCase):
diff --git a/allianceauth/hrapplications/views.py b/allianceauth/hrapplications/views.py
index 789428e2..2102b663 100644
--- a/allianceauth/hrapplications/views.py
+++ b/allianceauth/hrapplications/views.py
@@ -1,18 +1,13 @@
import logging
-from django.contrib.auth.decorators import login_required
-from django.contrib.auth.decorators import permission_required
-from django.contrib.auth.decorators import user_passes_test
-from django.shortcuts import render, get_object_or_404, redirect, Http404
+from django.contrib.auth.decorators import login_required, permission_required, user_passes_test
from django.db.models import Q
-from .models import Application
-from .models import ApplicationComment
-from .models import ApplicationForm
-from .models import ApplicationResponse
+from django.shortcuts import Http404, get_object_or_404, redirect, render
+
from allianceauth.notifications import notify
-from .forms import HRApplicationCommentForm
-from .forms import HRApplicationSearchForm
+from .forms import HRApplicationCommentForm, HRApplicationSearchForm
+from .models import Application, ApplicationComment, ApplicationForm, ApplicationResponse
logger = logging.getLogger(__name__)
@@ -23,7 +18,7 @@ def create_application_test(user):
@login_required
def hr_application_management_view(request):
- logger.debug("hr_application_management_view called by user %s" % request.user)
+ logger.debug(f"hr_application_management_view called by user {request.user}")
corp_applications = []
finished_corp_applications = []
main_char = request.user.profile.main_character
@@ -38,8 +33,7 @@ def hr_application_management_view(request):
corp_applications = base_app_query.filter(form=app_form).filter(approved=None).order_by('-created')
finished_corp_applications = base_app_query.filter(form=app_form).filter(
approved__in=[True, False]).order_by('-created')
- logger.debug("Retrieved {} personal, {} corp applications for {}".format(
- len(request.user.applications.all()), len(corp_applications), request.user))
+ logger.debug(f"Retrieved {len(request.user.applications.all())} personal, {len(corp_applications)} corp applications for {request.user}")
context = {
'personal_apps': request.user.applications.all(),
'applications': corp_applications,
@@ -122,7 +116,7 @@ def hr_application_view(request, app_id):
if request.method == 'POST':
if request.user.has_perm('hrapplications.add_applicationcomment'):
form = HRApplicationCommentForm(request.POST)
- logger.debug("Request type POST contains form valid: %s" % form.is_valid())
+ logger.debug(f"Request type POST contains form valid: {form.is_valid()}")
if form.is_valid():
comment = ApplicationComment()
comment.application = app
@@ -132,7 +126,7 @@ def hr_application_view(request, app_id):
logger.info(f"Saved comment by user {request.user} to {app}")
return redirect('hrapplications:view', app_id)
else:
- logger.warning("User %s does not have permission to add ApplicationComments" % request.user)
+ logger.warning(f"User {request.user} does not have permission to add ApplicationComments")
return redirect('hrapplications:view', app_id)
else:
logger.debug("Returning blank HRApplication comment form.")
@@ -155,7 +149,7 @@ def hr_application_remove(request, app_id):
app = get_object_or_404(Application, pk=app_id)
logger.info(f"User {request.user} deleting {app}")
app.delete()
- notify(app.user, "Application Deleted", message="Your application to %s was deleted." % app.form.corp)
+ notify(app.user, "Application Deleted", message=f"Your application to {app.form.corp} was deleted.")
return redirect('hrapplications:index')
@@ -169,7 +163,7 @@ def hr_application_approve(request, app_id):
logger.info(f"User {request.user} approving {app}")
app.approved = True
app.save()
- notify(app.user, "Application Accepted", message="Your application to %s has been approved." % app.form.corp, level="success")
+ notify(app.user, "Application Accepted", message=f"Your application to {app.form.corp} has been approved.", level="success")
else:
logger.warning(f"User {request.user} not authorized to approve {app}")
return redirect('hrapplications:index')
@@ -185,7 +179,7 @@ def hr_application_reject(request, app_id):
logger.info(f"User {request.user} rejecting {app}")
app.approved = False
app.save()
- notify(app.user, "Application Rejected", message="Your application to %s has been rejected." % app.form.corp, level="danger")
+ notify(app.user, "Application Rejected", message=f"Your application to {app.form.corp} has been rejected.", level="danger")
else:
logger.warning(f"User {request.user} not authorized to reject {app}")
return redirect('hrapplications:index')
@@ -194,10 +188,10 @@ def hr_application_reject(request, app_id):
@login_required
@permission_required('auth.human_resources')
def hr_application_search(request):
- logger.debug("hr_application_search called by user %s" % request.user)
+ logger.debug(f"hr_application_search called by user {request.user}")
if request.method == 'POST':
form = HRApplicationSearchForm(request.POST)
- logger.debug("Request type POST contains form valid: %s" % form.is_valid())
+ logger.debug(f"Request type POST contains form valid: {form.is_valid()}")
if form.is_valid():
searchstring = form.cleaned_data['search_string'].lower()
applications = set()
@@ -209,7 +203,7 @@ def hr_application_search(request):
form__corp__corporation_id=request.user.profile.main_character.corporation_id)
except AttributeError:
logger.warning(
- "User %s missing main character model: unable to filter applications to search" % request.user)
+ f"User {request.user} missing main character model: unable to filter applications to search")
applications = app_list.filter(
Q(user__profile__main_character__character_name__icontains=searchstring) |
@@ -225,12 +219,12 @@ def hr_application_search(request):
return render(request, 'hrapplications/searchview.html', context=context)
else:
- logger.debug("Form invalid - returning for user %s to retry." % request.user)
+ logger.debug(f"Form invalid - returning for user {request.user} to retry.")
context = {'applications': None, 'search_form': form}
return render(request, 'hrapplications/searchview.html', context=context)
else:
- logger.debug("Returning empty search form for user %s" % request.user)
+ logger.debug(f"Returning empty search form for user {request.user}")
return redirect("hrapplications:view")
diff --git a/allianceauth/menu/admin.py b/allianceauth/menu/admin.py
index 7df1c250..381fb206 100644
--- a/allianceauth/menu/admin.py
+++ b/allianceauth/menu/admin.py
@@ -1,6 +1,5 @@
"""Admin site for menu app."""
-from typing import Optional
from django.contrib import admin
from django.http import HttpRequest, HttpResponse
diff --git a/allianceauth/menu/core/menu_item_hooks.py b/allianceauth/menu/core/menu_item_hooks.py
index 2114569e..c0d26e5b 100644
--- a/allianceauth/menu/core/menu_item_hooks.py
+++ b/allianceauth/menu/core/menu_item_hooks.py
@@ -1,7 +1,7 @@
"""Logic for handling MenuItemHook objects."""
import hashlib
-from typing import List, NamedTuple, Optional
+from typing import NamedTuple
from allianceauth.menu.hooks import MenuItemHook
diff --git a/allianceauth/menu/hooks.py b/allianceauth/menu/hooks.py
index 9341415c..8a1fe5d9 100644
--- a/allianceauth/menu/hooks.py
+++ b/allianceauth/menu/hooks.py
@@ -1,6 +1,5 @@
"""Menu item hooks."""
-from typing import List, Optional
from django.template.loader import render_to_string
diff --git a/allianceauth/menu/migrations/0001_initial.py b/allianceauth/menu/migrations/0001_initial.py
index 1594566b..bf25eebb 100644
--- a/allianceauth/menu/migrations/0001_initial.py
+++ b/allianceauth/menu/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# Generated by Django 4.2.9 on 2024-02-15 00:01
-from django.db import migrations, models
import django.db.models.deletion
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/allianceauth/menu/models.py b/allianceauth/menu/models.py
index b2984842..40c91aab 100644
--- a/allianceauth/menu/models.py
+++ b/allianceauth/menu/models.py
@@ -48,8 +48,13 @@ class MenuItem(models.Model):
# app related properties
hook_hash = models.CharField(
- max_length=64, default=None, null=True, unique=True, editable=False
- ) # hash of a menu item hook. Must be nullable for unique comparison.
+ max_length=64,
+ default=None,
+ null=True,
+ unique=True,
+ editable=False,
+ help_text="hash of a menu item hook. Must be nullable for unique comparison."
+ )
# user defined properties
classes = models.CharField(
diff --git a/allianceauth/menu/templatetags/menu_menu_items.py b/allianceauth/menu/templatetags/menu_menu_items.py
index 2049e56d..6f93b9fb 100644
--- a/allianceauth/menu/templatetags/menu_menu_items.py
+++ b/allianceauth/menu/templatetags/menu_menu_items.py
@@ -24,7 +24,6 @@ which is used to render the complete menu.
"""
from dataclasses import dataclass, field
-from typing import Dict, List, Optional
from django import template
from django.db.models import QuerySet
diff --git a/allianceauth/menu/tests/templatetags/test_menu_menu_items.py b/allianceauth/menu/tests/templatetags/test_menu_menu_items.py
index ff48a49a..beae2da4 100644
--- a/allianceauth/menu/tests/templatetags/test_menu_menu_items.py
+++ b/allianceauth/menu/tests/templatetags/test_menu_menu_items.py
@@ -1,4 +1,4 @@
-from typing import List, NamedTuple, Optional
+from typing import NamedTuple
from unittest.mock import patch
from bs4 import BeautifulSoup
diff --git a/allianceauth/notifications/admin.py b/allianceauth/notifications/admin.py
index 3fb3242a..b2afd02b 100644
--- a/allianceauth/notifications/admin.py
+++ b/allianceauth/notifications/admin.py
@@ -1,4 +1,5 @@
from django.contrib import admin
+
from .models import Notification
diff --git a/allianceauth/notifications/handlers.py b/allianceauth/notifications/handlers.py
index b42aa09f..34d15da5 100644
--- a/allianceauth/notifications/handlers.py
+++ b/allianceauth/notifications/handlers.py
@@ -5,8 +5,9 @@ logger = logging.getLogger(__name__)
class NotificationHandler(logging.Handler):
def emit(self, record):
- from django.contrib.auth.models import User, Permission
+ from django.contrib.auth.models import Permission, User
from django.db.models import Q
+
from . import notify
from .models import Notification
diff --git a/allianceauth/notifications/managers.py b/allianceauth/notifications/managers.py
index 3798428e..42bbc01e 100644
--- a/allianceauth/notifications/managers.py
+++ b/allianceauth/notifications/managers.py
@@ -1,9 +1,9 @@
import logging
from django.conf import settings
+from django.contrib.auth.models import User
from django.core.cache import cache
from django.db import models
-from django.contrib.auth.models import User
logger = logging.getLogger(__name__)
diff --git a/allianceauth/notifications/migrations/0001_initial.py b/allianceauth/notifications/migrations/0001_initial.py
index 867ca680..21cdcf0e 100644
--- a/allianceauth/notifications/migrations/0001_initial.py
+++ b/allianceauth/notifications/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# Generated by Django 1.10.1 on 2016-09-05 21:40
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/allianceauth/notifications/models.py b/allianceauth/notifications/models.py
index dd77d0ff..6d75ff43 100644
--- a/allianceauth/notifications/models.py
+++ b/allianceauth/notifications/models.py
@@ -1,7 +1,7 @@
import logging
-from django.db import models
from django.contrib.auth.models import User
+from django.db import models
from django.utils.translation import gettext_lazy as _
from .managers import NotificationManager
@@ -73,7 +73,7 @@ class Notification(models.Model):
def mark_viewed(self) -> None:
"""Mark notification as viewed."""
- logger.info("Marking notification as viewed: %s" % self)
+ logger.info(f"Marking notification as viewed: {self}")
self.viewed = True
self.save()
diff --git a/allianceauth/notifications/templatetags/auth_notifications.py b/allianceauth/notifications/templatetags/auth_notifications.py
index 6ebce070..dcdf35ea 100644
--- a/allianceauth/notifications/templatetags/auth_notifications.py
+++ b/allianceauth/notifications/templatetags/auth_notifications.py
@@ -12,7 +12,6 @@ from django.contrib.auth.models import User
from allianceauth.notifications.models import Notification
-
logger = logging.getLogger(__name__)
register = template.Library()
diff --git a/allianceauth/notifications/tests/test_handlers.py b/allianceauth/notifications/tests/test_handlers.py
index f90a4726..aa3c0bc3 100644
--- a/allianceauth/notifications/tests/test_handlers.py
+++ b/allianceauth/notifications/tests/test_handlers.py
@@ -1,7 +1,8 @@
-from logging import LogRecord, DEBUG
+from logging import DEBUG, LogRecord
-from django.contrib.auth.models import Permission, Group, User
+from django.contrib.auth.models import Group, Permission, User
from django.test import TestCase
+
from allianceauth.tests.auth_utils import AuthUtils
from ..handlers import NotificationHandler
diff --git a/allianceauth/notifications/tests/test_init.py b/allianceauth/notifications/tests/test_init.py
index e09e1ee7..3cab1ed7 100644
--- a/allianceauth/notifications/tests/test_init.py
+++ b/allianceauth/notifications/tests/test_init.py
@@ -1,4 +1,5 @@
from django.test import TestCase
+
from allianceauth.tests.auth_utils import AuthUtils
from .. import notify
diff --git a/allianceauth/notifications/tests/test_managers.py b/allianceauth/notifications/tests/test_managers.py
index a74ca2b9..e21c6aa2 100644
--- a/allianceauth/notifications/tests/test_managers.py
+++ b/allianceauth/notifications/tests/test_managers.py
@@ -5,8 +5,8 @@ from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from allianceauth.tests.auth_utils import AuthUtils
-from ..models import Notification
+from ..models import Notification
MODULE_PATH = 'allianceauth.notifications.models'
diff --git a/allianceauth/notifications/tests/test_models.py b/allianceauth/notifications/tests/test_models.py
index b291f2c8..320a3c45 100644
--- a/allianceauth/notifications/tests/test_models.py
+++ b/allianceauth/notifications/tests/test_models.py
@@ -1,11 +1,11 @@
from unittest.mock import patch
from django.test import TestCase
+
from allianceauth.tests.auth_utils import AuthUtils
from ..models import Notification
-
MODULE_PATH = 'allianceauth.notifications.models'
diff --git a/allianceauth/notifications/tests/test_templatetags.py b/allianceauth/notifications/tests/test_templatetags.py
index 587970be..f31a9a45 100644
--- a/allianceauth/notifications/tests/test_templatetags.py
+++ b/allianceauth/notifications/tests/test_templatetags.py
@@ -1,11 +1,10 @@
-from unittest.mock import patch, Mock
+from unittest.mock import patch
from django.test import TestCase, override_settings
from allianceauth.tests.auth_utils import AuthUtils
-from ..templatetags.auth_notifications import (
- user_unread_notification_count, notifications_refresh_time
-)
+
+from ..templatetags.auth_notifications import notifications_refresh_time, user_unread_notification_count
MODULE_PATH = 'allianceauth.notifications.templatetags.auth_notifications'
diff --git a/allianceauth/notifications/tests/test_views.py b/allianceauth/notifications/tests/test_views.py
index 7fa95bc8..ca6212f4 100644
--- a/allianceauth/notifications/tests/test_views.py
+++ b/allianceauth/notifications/tests/test_views.py
@@ -1,15 +1,13 @@
import json
+from unittest.mock import patch
-from unittest.mock import patch, Mock
-
-from django.test import TestCase, RequestFactory
+from django.test import RequestFactory, TestCase
from django.urls import reverse
from allianceauth.tests.auth_utils import AuthUtils
from ..views import user_notifications_count
-
MODULE_PATH = 'allianceauth.notifications.views'
diff --git a/allianceauth/notifications/urls.py b/allianceauth/notifications/urls.py
index 694a700b..be8f7073 100644
--- a/allianceauth/notifications/urls.py
+++ b/allianceauth/notifications/urls.py
@@ -1,4 +1,5 @@
from django.urls import path
+
from . import views
app_name = 'notifications'
diff --git a/allianceauth/notifications/views.py b/allianceauth/notifications/views.py
index 40bc88f5..3d3a586f 100644
--- a/allianceauth/notifications/views.py
+++ b/allianceauth/notifications/views.py
@@ -1,9 +1,9 @@
import logging
-from django.contrib.auth.decorators import login_required
from django.contrib import messages
+from django.contrib.auth.decorators import login_required
from django.http import JsonResponse
-from django.shortcuts import render, get_object_or_404, redirect
+from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import gettext_lazy as _
from .models import Notification
@@ -13,7 +13,7 @@ logger = logging.getLogger(__name__)
@login_required
def notification_list(request):
- logger.debug("notification_list called by user %s" % request.user)
+ logger.debug(f"notification_list called by user {request.user}")
notifications_qs = Notification.objects.filter(user=request.user).order_by("-timestamp")
new_notifs = notifications_qs.filter(viewed=False)
old_notifs = notifications_qs.filter(viewed=True)
diff --git a/allianceauth/optimer/auth_hooks.py b/allianceauth/optimer/auth_hooks.py
index b14a41b5..e0fefb16 100644
--- a/allianceauth/optimer/auth_hooks.py
+++ b/allianceauth/optimer/auth_hooks.py
@@ -1,8 +1,10 @@
+from django.utils.translation import gettext_lazy as _
+
+from allianceauth import hooks
from allianceauth.menu.hooks import MenuItemHook
from allianceauth.optimer.views import dashboard_ops
from allianceauth.services.hooks import UrlHook
-from django.utils.translation import gettext_lazy as _
-from allianceauth import hooks
+
from . import urls
diff --git a/allianceauth/optimer/form_widgets.py b/allianceauth/optimer/form_widgets.py
index e639e18b..b52dad0e 100644
--- a/allianceauth/optimer/form_widgets.py
+++ b/allianceauth/optimer/form_widgets.py
@@ -18,7 +18,7 @@ class DataListWidget(forms.TextInput):
self._name = name
self._list = data_list
- self.attrs.update({"list": "list__%s" % self._name})
+ self.attrs.update({"list": f"list__{self._name}"})
def render(self, name, value, attrs=None, renderer=None):
"""
@@ -36,10 +36,10 @@ class DataListWidget(forms.TextInput):
"""
text_html = super().render(name, value, attrs=attrs)
- data_list = '