feat(static): improve static files handling and permissions in Docker
- Add script to set correct permissions on static files after collectstatic - Introduce collectstatic command in entrypoint with permission fixing - Add WhiteNoise middleware for efficient static file serving without DB access - Configure WhiteNoise static files storage backend in settings - Set STATIC_ROOT path properly for Docker container environment - Add fallback static files serving in Django urls for production without nginx - Enhance inventory_detail.html scripts to log errors if JS files or components fail to load - Add whitenoise package to requirements for static file serving support
This commit is contained in:
@@ -284,12 +284,25 @@
|
||||
{% endif %}
|
||||
|
||||
<!-- Подключаем JavaScript -->
|
||||
<script src="{% static 'products/js/product-search-picker.js' %}"></script>
|
||||
<script src="{% static 'inventory/js/inventory_detail.js' %}"></script>
|
||||
<script src="{% static 'products/js/product-search-picker.js' %}" onerror="console.error('Failed to load product-search-picker.js');"></script>
|
||||
<script src="{% static 'inventory/js/inventory_detail.js' %}" onerror="console.error('Failed to load inventory_detail.js');"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Проверка загрузки ProductSearchPicker
|
||||
if (typeof ProductSearchPicker === 'undefined') {
|
||||
console.error('ProductSearchPicker is not defined. Check if product-search-picker.js loaded correctly.');
|
||||
console.error('Script URL: {% static "products/js/product-search-picker.js" %}');
|
||||
return;
|
||||
}
|
||||
|
||||
// Инициализация компонента поиска товаров
|
||||
{% if inventory.status != 'completed' %}
|
||||
const pickerElement = document.querySelector('#inventory-product-picker');
|
||||
if (!pickerElement) {
|
||||
console.error('Picker container #inventory-product-picker not found');
|
||||
return;
|
||||
}
|
||||
|
||||
const picker = ProductSearchPicker.init('#inventory-product-picker', {
|
||||
onAddSelected: function(product, instance) {
|
||||
if (product) {
|
||||
@@ -298,6 +311,10 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!picker) {
|
||||
console.error('Failed to initialize ProductSearchPicker');
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
// Инициализация обработчиков
|
||||
|
||||
Reference in New Issue
Block a user