mirror of
https://github.com/EDeev/deev.space.git
synced 2026-10-07 20:49:59 +03:00
«Обо мне»: исправлена ссылка на несуществующую картинку-заглушку
Без загруженного фото владельца страница падала с 500 (в манифесте статики нет
images/hero.png). Теперь используется static/img/hero.jpg; добавлен тест, который
проверяет, что все {% static %} в шаблонах указывают на существующие файлы.
This commit is contained in:
parent
794fceece5
commit
268652505a
2 changed files with 18 additions and 1 deletions
|
|
@ -44,3 +44,20 @@ def test_visitor_cookie_is_signed_and_httponly(client):
|
|||
@pytest.mark.django_db
|
||||
def test_unknown_page_returns_404(client):
|
||||
assert client.get('/no-such-page/', HTTP_USER_AGENT=UA).status_code == 404
|
||||
|
||||
|
||||
def test_all_static_references_exist():
|
||||
"""Каждый {% static %} в шаблонах указывает на существующий файл (иначе 500 в бою)."""
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
pattern = re.compile(r"{% static '([^']+)' %}")
|
||||
missing = [
|
||||
f'{tpl.name}: {ref}'
|
||||
for tpl in Path(settings.BASE_DIR, 'templates').rglob('*.html')
|
||||
for ref in pattern.findall(tpl.read_text(encoding='utf-8'))
|
||||
if not Path(settings.BASE_DIR, 'static', ref).exists()
|
||||
]
|
||||
assert not missing
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
{% if site_settings.owner_photo %}
|
||||
<img src="{{ site_settings.owner_photo.url }}" alt="{{ site_settings.owner_name }}">
|
||||
{% else %}
|
||||
<img src="{% static 'images/hero.png' %}" alt="{{ site_settings.owner_name }}">
|
||||
<img src="{% static 'img/hero.jpg' %}" alt="{{ site_settings.owner_name }}">
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="about-bio-info">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue