mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
[CHANGE] Django Upgrade checks applied
This commit is contained in:
parent
b2d540c010
commit
7075ccdf7a
@ -7,12 +7,33 @@ repos:
|
|||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.4.0
|
rev: v4.4.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-case-conflict
|
# Identify invalid files
|
||||||
- id: check-json
|
- id: check-ast
|
||||||
- id: check-xml
|
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
|
- id: check-json
|
||||||
|
- id: check-toml
|
||||||
|
- id: check-xml
|
||||||
|
|
||||||
|
# git checks
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-added-large-files
|
||||||
|
args: [ --maxkb=1000 ]
|
||||||
|
- id: detect-private-key
|
||||||
|
- id: check-case-conflict
|
||||||
|
|
||||||
|
# Python checks
|
||||||
|
# - id: check-docstring-first
|
||||||
|
- id: debug-statements
|
||||||
|
# - id: requirements-txt-fixer
|
||||||
|
- id: fix-encoding-pragma
|
||||||
|
args: [ --remove ]
|
||||||
- id: fix-byte-order-marker
|
- id: fix-byte-order-marker
|
||||||
|
|
||||||
|
# General quality checks
|
||||||
|
- id: mixed-line-ending
|
||||||
|
args: [ --fix=lf ]
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
|
args: [ --markdown-linebreak-ext=md ]
|
||||||
exclude: |
|
exclude: |
|
||||||
(?x)(
|
(?x)(
|
||||||
\.min\.css|
|
\.min\.css|
|
||||||
@ -21,6 +42,7 @@ repos:
|
|||||||
\.mo|
|
\.mo|
|
||||||
swagger\.json
|
swagger\.json
|
||||||
)
|
)
|
||||||
|
# - id: check-executables-have-shebangs
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
exclude: |
|
exclude: |
|
||||||
(?x)(
|
(?x)(
|
||||||
@ -30,13 +52,9 @@ repos:
|
|||||||
\.mo|
|
\.mo|
|
||||||
swagger\.json
|
swagger\.json
|
||||||
)
|
)
|
||||||
- id: mixed-line-ending
|
|
||||||
args: [ '--fix=lf' ]
|
|
||||||
- id: fix-encoding-pragma
|
|
||||||
args: [ '--remove' ]
|
|
||||||
|
|
||||||
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
|
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
|
||||||
rev: 2.7.1
|
rev: 2.7.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: editorconfig-checker
|
- id: editorconfig-checker
|
||||||
exclude: |
|
exclude: |
|
||||||
@ -48,8 +66,14 @@ repos:
|
|||||||
swagger\.json
|
swagger\.json
|
||||||
)
|
)
|
||||||
|
|
||||||
|
- repo: https://github.com/adamchainz/django-upgrade
|
||||||
|
rev: 1.14.0
|
||||||
|
hooks:
|
||||||
|
- id: django-upgrade
|
||||||
|
args: [ --target-version=4.0 ]
|
||||||
|
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v3.3.1
|
rev: v3.10.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [ --py38-plus ]
|
args: [ --py38-plus ]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import Callable, Iterable, Optional
|
from typing import Callable, Iterable, Optional
|
||||||
|
|
||||||
from django.conf.urls import include
|
from django.urls import include
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required, user_passes_test
|
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
from django.conf.urls import include
|
|
||||||
|
|
||||||
from allianceauth.authentication import views
|
from allianceauth.authentication import views
|
||||||
from django.urls import re_path
|
from django.urls import include, re_path, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('activate/complete/', views.activation_complete, name='registration_activation_complete'),
|
path('activate/complete/', views.activation_complete, name='registration_activation_complete'),
|
||||||
|
@ -14,6 +14,7 @@ def sync_user_groups(modeladmin, request, queryset):
|
|||||||
agc.update_all_states_group_membership()
|
agc.update_all_states_group_membership()
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(AutogroupsConfig)
|
||||||
class AutogroupsConfigAdmin(admin.ModelAdmin):
|
class AutogroupsConfigAdmin(admin.ModelAdmin):
|
||||||
formfield_overrides = {
|
formfield_overrides = {
|
||||||
models.CharField: {'strip': False}
|
models.CharField: {'strip': False}
|
||||||
@ -36,6 +37,5 @@ class AutogroupsConfigAdmin(admin.ModelAdmin):
|
|||||||
return actions
|
return actions
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(AutogroupsConfig, AutogroupsConfigAdmin)
|
|
||||||
admin.site.register(ManagedCorpGroup)
|
admin.site.register(ManagedCorpGroup)
|
||||||
admin.site.register(ManagedAllianceGroup)
|
admin.site.register(ManagedAllianceGroup)
|
||||||
|
@ -10,6 +10,7 @@ class ChoiceInline(admin.TabularInline):
|
|||||||
verbose_name_plural = 'Choices (optional)'
|
verbose_name_plural = 'Choices (optional)'
|
||||||
verbose_name= 'Choice'
|
verbose_name= 'Choice'
|
||||||
|
|
||||||
|
@admin.register(ApplicationQuestion)
|
||||||
class QuestionAdmin(admin.ModelAdmin):
|
class QuestionAdmin(admin.ModelAdmin):
|
||||||
fieldsets = [
|
fieldsets = [
|
||||||
(None, {'fields': ['title', 'help_text', 'multi_select']}),
|
(None, {'fields': ['title', 'help_text', 'multi_select']}),
|
||||||
@ -18,6 +19,5 @@ class QuestionAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
admin.site.register(Application)
|
admin.site.register(Application)
|
||||||
admin.site.register(ApplicationComment)
|
admin.site.register(ApplicationComment)
|
||||||
admin.site.register(ApplicationQuestion, QuestionAdmin)
|
|
||||||
admin.site.register(ApplicationForm)
|
admin.site.register(ApplicationForm)
|
||||||
admin.site.register(ApplicationResponse)
|
admin.site.register(ApplicationResponse)
|
||||||
|
@ -1,3 +1 @@
|
|||||||
from .core import notify # noqa: F401
|
from .core import notify # noqa: F401
|
||||||
|
|
||||||
default_app_config = 'allianceauth.notifications.apps.NotificationsConfig'
|
|
||||||
|
@ -15,18 +15,22 @@ class NotificationAdmin(admin.ModelAdmin):
|
|||||||
ordering = ("-timestamp", )
|
ordering = ("-timestamp", )
|
||||||
search_fields = ["user__username", "user__profile__main_character__character_name"]
|
search_fields = ["user__username", "user__profile__main_character__character_name"]
|
||||||
|
|
||||||
|
@admin.display(
|
||||||
|
ordering="user__profile__main_character__character_name"
|
||||||
|
)
|
||||||
def _main(self, obj):
|
def _main(self, obj):
|
||||||
try:
|
try:
|
||||||
return obj.user.profile.main_character
|
return obj.user.profile.main_character
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return obj.user
|
return obj.user
|
||||||
|
|
||||||
_main.admin_order_field = "user__profile__main_character__character_name"
|
|
||||||
|
|
||||||
|
@admin.display(
|
||||||
|
ordering="user__profile__state__name"
|
||||||
|
)
|
||||||
def _state(self, obj):
|
def _state(self, obj):
|
||||||
return obj.user.profile.state
|
return obj.user.profile.state
|
||||||
|
|
||||||
_state.admin_order_field = "user__profile__state__name"
|
|
||||||
|
|
||||||
def has_change_permission(self, request, obj=None):
|
def has_change_permission(self, request, obj=None):
|
||||||
return False
|
return False
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
from django.conf.urls import include
|
|
||||||
from allianceauth import urls
|
from allianceauth import urls
|
||||||
from django.urls import re_path
|
from django.urls import include, path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
re_path(r'', include(urls)),
|
path('', include(urls)),
|
||||||
]
|
]
|
||||||
|
|
||||||
handler500 = 'allianceauth.views.Generic500Redirect'
|
handler500 = 'allianceauth.views.Generic500Redirect'
|
||||||
|
@ -66,6 +66,8 @@ class NameFormatConfigAdmin(admin.ModelAdmin):
|
|||||||
form = NameFormatConfigForm
|
form = NameFormatConfigForm
|
||||||
list_display = ('service_name', 'get_state_display_string')
|
list_display = ('service_name', 'get_state_display_string')
|
||||||
|
|
||||||
|
@admin.display(
|
||||||
|
description='States'
|
||||||
|
)
|
||||||
def get_state_display_string(self, obj):
|
def get_state_display_string(self, obj):
|
||||||
return ', '.join([state.name for state in obj.states.all()])
|
return ', '.join([state.name for state in obj.states.all()])
|
||||||
get_state_display_string.short_description = 'States'
|
|
||||||
|
@ -2,10 +2,9 @@ from string import Formatter
|
|||||||
from typing import Iterable, Optional
|
from typing import Iterable, Optional
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import include
|
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.urls import re_path
|
from django.urls import include, re_path
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
from allianceauth.hooks import get_hooks
|
from allianceauth.hooks import get_hooks
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
app_name = 'example'
|
app_name = 'example'
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@ from django.contrib import admin
|
|||||||
from .models import Ips4User
|
from .models import Ips4User
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Ips4User)
|
||||||
class Ips4UserAdmin(admin.ModelAdmin):
|
class Ips4UserAdmin(admin.ModelAdmin):
|
||||||
list_display = ('user', 'username', 'id')
|
list_display = ('user', 'username', 'id')
|
||||||
search_fields = ('user__username', 'username', 'id')
|
search_fields = ('user__username', 'username', 'id')
|
||||||
|
|
||||||
admin.site.register(Ips4User, Ips4UserAdmin)
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -36,10 +36,12 @@ class AuthTSgroupAdmin(admin.ModelAdmin):
|
|||||||
kwargs['queryset'] = TSgroup.objects.exclude(ts_group_name__in=ReservedGroupName.objects.values_list('name', flat=True))
|
kwargs['queryset'] = TSgroup.objects.exclude(ts_group_name__in=ReservedGroupName.objects.values_list('name', flat=True))
|
||||||
return super().formfield_for_manytomany(db_field, request, **kwargs)
|
return super().formfield_for_manytomany(db_field, request, **kwargs)
|
||||||
|
|
||||||
|
@admin.display(
|
||||||
|
description='ts groups'
|
||||||
|
)
|
||||||
def _ts_group(self, obj):
|
def _ts_group(self, obj):
|
||||||
return [x for x in obj.ts_group.all().order_by('ts_group_id')]
|
return [x for x in obj.ts_group.all().order_by('ts_group_id')]
|
||||||
|
|
||||||
_ts_group.short_description = 'ts groups'
|
|
||||||
# _ts_group.admin_order_field = 'profile__state'
|
# _ts_group.admin_order_field = 'profile__state'
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include, path
|
||||||
from django.urls import path
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from django.conf.urls import include
|
from django.urls import include
|
||||||
from allianceauth.hooks import get_hooks
|
from allianceauth.hooks import get_hooks
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user