diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 5630adf282..206b4a697b 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -197,7 +197,18 @@ if DBBACKUP_STORAGE_OPTIONS is None: 'location': config.get_backup_dir(), } -# Application definition +INVENTREE_ADMIN_ENABLED = get_boolean_setting( + 'INVENTREE_ADMIN_ENABLED', + config_key='admin_enabled', + default_value=True +) + +# Base URL for admin pages (default="admin") +INVENTREE_ADMIN_URL = get_setting( + 'INVENTREE_ADMIN_URL', + config_key='admin_url', + default_value='admin' +) INSTALLED_APPS = [ # Admin site integration @@ -378,14 +389,6 @@ if DEBUG: INSTALLED_APPS.append('sslserver') # InvenTree URL configuration - -# Base URL for admin pages (default="admin") -INVENTREE_ADMIN_URL = get_setting( - 'INVENTREE_ADMIN_URL', - config_key='admin_url', - default_value='admin' -) - ROOT_URLCONF = 'InvenTree.urls' TEMPLATES = [ diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 742848c328..b55bf78fbb 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -209,11 +209,14 @@ classic_frontendpatterns = [ new_frontendpatterns = platform_urls -urlpatterns = [ - # admin sites - re_path(f'^{settings.INVENTREE_ADMIN_URL}/error_log/', include('error_report.urls')), - re_path(f'^{settings.INVENTREE_ADMIN_URL}/', admin.site.urls, name='inventree-admin'), -] +urlpatterns = [] + +if settings.INVENTREE_ADMIN_ENABLED: + admin_url = settings.INVENTREE_ADMIN_URL, + urlpatterns += [ + path(f'{admin_url}/error_log/', include('error_report.urls')), + path(f'{admin_url}/', admin.site.urls, name='inventree-admin'), + ] urlpatterns += backendpatterns diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index 2f1ea421b6..3eb50e1270 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -29,10 +29,9 @@ src="{% static 'img/blank_image.png' %}" {% block actions %} -{% if user.is_staff and roles.build.change %} -{% url 'admin:build_build_change' build.pk as url %} +{% admin_url user "build.build" build.pk as url %} {% include "admin_button.html" with url=url %} -{% endif %} + {% if barcodes %}
diff --git a/InvenTree/company/templates/company/company_base.html b/InvenTree/company/templates/company/company_base.html index 7953635671..238c53847e 100644 --- a/InvenTree/company/templates/company/company_base.html +++ b/InvenTree/company/templates/company/company_base.html @@ -14,10 +14,9 @@ {% block actions %} -{% if user.is_staff and perms.company.change_company %} -{% url 'admin:company_company_change' company.pk as url %} +{% admin_url user "company.company" company.pk as url %} {% include "admin_button.html" with url=url %} -{% endif %} + {% if company.is_supplier and roles.purchase_order.add %} diff --git a/InvenTree/templates/admin_button.html b/InvenTree/templates/admin_button.html index abc3d2d91c..9f0e8acfbc 100644 --- a/InvenTree/templates/admin_button.html +++ b/InvenTree/templates/admin_button.html @@ -3,7 +3,7 @@ {% inventree_customize 'hide_admin_link' as hidden %} -{% if not hidden and user.is_staff %} +{% if url and not hidden and user.is_staff %}