2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Merge branch 'master' of https://github.com/inventree/InvenTree into matmair/issue6281

This commit is contained in:
Matthias Mair
2024-04-12 00:04:58 +02:00
32 changed files with 94 additions and 33 deletions

View File

@ -285,6 +285,29 @@ QUERYCOUNT = {
'RESPONSE_HEADER': 'X-Django-Query-Count',
}
ADMIN_SHELL_ENABLE = False
ADMIN_SHELL_IMPORT_DJANGO = False
ADMIN_SHELL_IMPORT_MODELS = False
# In DEBUG mode, add support for django-admin-shell
# Ref: https://github.com/djk2/django-admin-shell
if (
DEBUG
and INVENTREE_ADMIN_ENABLED
and get_boolean_setting('INVENTREE_DEBUG_SHELL', 'debug_shell', False)
): # noqa
try:
import django_admin_shell
INSTALLED_APPS.append('django_admin_shell')
ADMIN_SHELL_ENABLE = True
logger.warning('Admin shell is enabled')
except ModuleNotFoundError:
logger.warning(
'django-admin-shell is not installed - Admin shell is not enabled'
)
AUTHENTICATION_BACKENDS = CONFIG.get(
'authentication_backends',
[

View File

@ -434,7 +434,11 @@ classic_frontendpatterns = [
urlpatterns = []
if settings.INVENTREE_ADMIN_ENABLED:
admin_url = (settings.INVENTREE_ADMIN_URL,)
admin_url = settings.INVENTREE_ADMIN_URL
if settings.ADMIN_SHELL_ENABLE: # noqa
urlpatterns += [path(f'{admin_url}/shell/', include('django_admin_shell.urls'))]
urlpatterns += [
path(f'{admin_url}/error_log/', include('error_report.urls')),
path(f'{admin_url}/', admin.site.urls, name='inventree-admin'),

View File

@ -258,6 +258,13 @@ class UserSettingsList(SettingsList):
common.models.InvenTreeUserSetting.build_default_values(user=request.user)
return super().list(request, *args, **kwargs)
def get_queryset(self):
"""Return prefetched queryset."""
queryset = super().get_queryset()
queryset = queryset.prefetch_related('user')
return queryset
def filter_queryset(self, queryset):
"""Only list settings which apply to the current user."""
try:

View File

@ -64,6 +64,7 @@ class TestSerialNumberMigration(MigratorTestCase):
big_ref_item.serial,
'9999999999999999999999999999999999999999999999999999999999999',
)
self.assertEqual(big_ref_item.serial_int, 0x7FFFFFFF)

View File

@ -2,6 +2,7 @@
-c requirements.txt
coverage[toml] # Unit test coverage
coveralls==2.1.2 # Coveralls linking (for tracking coverage) # PINNED 2022-06-28 - Old version needed for correct upload
django-admin-shell # Remote shell access
django-querycount # Display number of URL queries for requests
django-slowtests # Show which unit tests are running slowly
django-test-migrations # Unit testing for database migrations

View File

@ -24,7 +24,10 @@ cryptography==42.0.5
distlib==0.3.8
# via virtualenv
django==4.2.11
# via django-slowtests
# via
# django-admin-shell
# django-slowtests
django-admin-shell==2.0.1
django-querycount==0.8.3
django-slowtests==1.1.1
django-test-migrations==1.3.0

View File

@ -268,7 +268,7 @@ pyyaml==6.0.1
# tablib
qrcode[pil]==7.4.2
# via django-allauth
rapidfuzz==3.6.2
rapidfuzz==3.8.1
redis==5.0.3
# via django-redis
referencing==0.34.0