diff --git a/Makefile b/Makefile index b29fb9c..fdf1b23 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ shell: # target: collectstatic - Run collectstatic collectstatic: - python manage.py collectstatic --noinput + python src/manage.py collectstatic --noinput clean_temp: diff --git a/src/commons/templatetags/my_tags.py b/src/commons/templatetags/my_tags.py index f22fad0..b18ffc8 100644 --- a/src/commons/templatetags/my_tags.py +++ b/src/commons/templatetags/my_tags.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os +from hashlib import md5 from django import template from django.conf import settings @@ -63,3 +64,14 @@ def to_float(value): else: result = value return result + + +@register.simple_tag +def file_version(path): + """Вернуть md5-хэш от статического файла.""" + full_path = os.path.join(settings.STATIC_ROOT, path) + print(full_path) + try: + return md5(open(full_path, 'rb').read()).hexdigest() + except IOError: + return '' diff --git a/src/dokumentor/templates/base.html b/src/dokumentor/templates/base.html index a013809..d6509ae 100644 --- a/src/dokumentor/templates/base.html +++ b/src/dokumentor/templates/base.html @@ -1,5 +1,5 @@ {# spaceless #} -{% load static cms_tags sekizai_tags menu_tags pytils_numeral %} +{% load static cms_tags sekizai_tags menu_tags pytils_numeral my_tags %} {% url 'myauth_login' as myauth_login %} {% url 'myauth_register' as myauth_register %} @@ -10,7 +10,7 @@ - + {% render_block "css" %} @@ -131,11 +131,11 @@ - + - - - + + + {% include 'autocomplete_light/static.html' %} - - + + + - - + + {% include 'hbs/bank-tpl.html' %} diff --git a/src/dokumentor/templates/docs/_base/base_add.html b/src/dokumentor/templates/docs/_base/base_add.html index ffeadb9..34eb037 100644 --- a/src/dokumentor/templates/docs/_base/base_add.html +++ b/src/dokumentor/templates/docs/_base/base_add.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load static %} +{% load static my_tags %} {% block title %}Добавить {{ padeji.vinit }}{% endblock %} @@ -20,10 +20,10 @@ {% endblock %} {% block js %} - - + + - + {% include 'hbs/bank-tpl.html' %} {% include form_template_js %} {% endblock %} diff --git a/src/dokumentor/templates/docs/_base/base_edit.html b/src/dokumentor/templates/docs/_base/base_edit.html index 67da8a3..ec7bff5 100644 --- a/src/dokumentor/templates/docs/_base/base_edit.html +++ b/src/dokumentor/templates/docs/_base/base_edit.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load static %} +{% load static my_tags %} {% block title %}Редактировать {{ padeji.vinit }}{% endblock %} @@ -23,10 +23,10 @@ {% endblock %} {% block js %} - - + + - + {% include 'hbs/bank-tpl.html' %} {% include form_template_js %} {% endblock %}