mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	Add debug mode and database backend as info to the "stats" dialog
This commit is contained in:
		@@ -1,7 +1,14 @@
 | 
				
			|||||||
 | 
					# -*- coding: utf-8 -*-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
""" This module provides template tags for extra functionality
 | 
					""" This module provides template tags for extra functionality
 | 
				
			||||||
over and above the built-in Django tags.
 | 
					over and above the built-in Django tags.
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					import django
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from django.utils.translation import ugettext_lazy as _
 | 
				
			||||||
 | 
					from django.conf import settings as djangosettings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from django import template
 | 
					from django import template
 | 
				
			||||||
from django.urls import reverse
 | 
					from django.urls import reverse
 | 
				
			||||||
@@ -67,6 +74,23 @@ def part_allocation_count(build, part, *args, **kwargs):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    return InvenTree.helpers.decimal2string(build.getAllocatedQuantity(part))
 | 
					    return InvenTree.helpers.decimal2string(build.getAllocatedQuantity(part))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@register.simple_tag()
 | 
				
			||||||
 | 
					def inventree_in_debug_mode(*args, **kwargs):
 | 
				
			||||||
 | 
					    """ Return True if the server is running in DEBUG mode """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return djangosettings.DEBUG
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@register.simple_tag()
 | 
				
			||||||
 | 
					def inventree_db_engine(*args, **kwargs):
 | 
				
			||||||
 | 
					    """ Return the InvenTree database backend e.g. 'postgresql' """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    db = djangosettings.DATABASES['default']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    engine = db.get('ENGINE', _('Unknown database'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    engine = engine.replace('django.db.backends.', '')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return engine
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@register.simple_tag()
 | 
					@register.simple_tag()
 | 
				
			||||||
def inventree_instance_name(*args, **kwargs):
 | 
					def inventree_instance_name(*args, **kwargs):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,19 @@
 | 
				
			|||||||
        <td>{% trans "Instance Name" %}</td>
 | 
					        <td>{% trans "Instance Name" %}</td>
 | 
				
			||||||
        <td>{% inventree_instance_name %}</td>
 | 
					        <td>{% inventree_instance_name %}</td>
 | 
				
			||||||
    </tr>
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td><span class='fas fa-database'></span></td>
 | 
				
			||||||
 | 
					        <td>{% trans "Database" %}</td>
 | 
				
			||||||
 | 
					        <td>{% inventree_db_engine %}</td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    {% inventree_in_debug_mode as debug_mode %}
 | 
				
			||||||
 | 
					    {% if debug_mode %}
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td><span class='fas fa-laptop-code'></span></td>
 | 
				
			||||||
 | 
					        <td>{% trans "Debug Mode" %}</td>
 | 
				
			||||||
 | 
					        <td>{% trans "Server is running in debug mode" %}</td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    {% endif %}
 | 
				
			||||||
    {% if user.is_staff %}
 | 
					    {% if user.is_staff %}
 | 
				
			||||||
    <tr>
 | 
					    <tr>
 | 
				
			||||||
        <td><span class='fas fa-server'></span></td>
 | 
					        <td><span class='fas fa-server'></span></td>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user