add related articles to detail views

This commit is contained in:
Tobias Brunner 2025-06-06 15:22:02 +02:00
parent b456816035
commit 18e9156683
No known key found for this signature in database
8 changed files with 140 additions and 0 deletions

View file

@ -94,6 +94,50 @@
</ul>
</div>
{% endif %}
<!-- Related Articles about Service -->
{% if service_articles %}
<div class="mb-40">
<h3 class="fw-semibold mb-12">Articles about {{ offering.service.name }}</h3>
<ul class="list-unstyled space-y-12 fs-19 ps-0">
{% for article in service_articles %}
<li>
<a class="d-flex align-items-center text-gray-500 h-32 lh-32" href="{{ article.get_absolute_url }}">
<span class="pr-10">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-text" viewBox="0 0 16 16">
<path d="M5 4a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm-.5 2.5A.5.5 0 0 1 5 6h6a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5M5 8a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z" fill="#9A63EC"/>
<path d="M2 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2zm10-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1z" fill="#9A63EC"/>
</svg>
</span>
<span>{{ article.title }}</span>
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<!-- Related Articles about Provider -->
{% if provider_articles %}
<div class="mb-40">
<h3 class="fw-semibold mb-12">Articles about {{ offering.cloud_provider.name }}</h3>
<ul class="list-unstyled space-y-12 fs-19 ps-0">
{% for article in provider_articles %}
<li>
<a class="d-flex align-items-center text-gray-500 h-32 lh-32" href="{{ article.get_absolute_url }}">
<span class="pr-10">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-text" viewBox="0 0 16 16">
<path d="M5 4a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm-.5 2.5A.5.5 0 0 1 5 6h6a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5M5 8a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z" fill="#9A63EC"/>
<path d="M2 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2zm10-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1z" fill="#9A63EC"/>
</svg>
</span>
<span>{{ article.title }}</span>
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
</div>
@ -402,4 +446,6 @@
</div>
</div>
</section>
{% endblock %}

View file

@ -119,6 +119,28 @@
</ul>
</div>
{% endif %}
<!-- Related Articles -->
{% if related_articles %}
<div class="mb-40">
<h3 class="fw-semibold mb-12">Related Articles</h3>
<ul class="list-unstyled space-y-12 fs-19 ps-0">
{% for article in related_articles %}
<li>
<a class="d-flex align-items-center text-gray-500 h-32 lh-32" href="{{ article.get_absolute_url }}">
<span class="pr-10">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-text" viewBox="0 0 16 16">
<path d="M5 4a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm-.5 2.5A.5.5 0 0 1 5 6h6a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5M5 8a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z" fill="#9A63EC"/>
<path d="M2 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2zm10-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1z" fill="#9A63EC"/>
</svg>
</span>
<span>{{ article.title }}</span>
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
</div>

View file

@ -119,6 +119,28 @@
</ul>
</div>
{% endif %}
<!-- Related Articles -->
{% if related_articles %}
<div class="mb-40">
<h3 class="fw-semibold mb-12">Related Articles</h3>
<ul class="list-unstyled space-y-12 fs-19 ps-0">
{% for article in related_articles %}
<li>
<a class="d-flex align-items-center text-gray-500 h-32 lh-32" href="{{ article.get_absolute_url }}">
<span class="pr-10">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-text" viewBox="0 0 16 16">
<path d="M5 4a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm-.5 2.5A.5.5 0 0 1 5 6h6a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5M5 8a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z" fill="#9A63EC"/>
<path d="M2 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2zm10-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1z" fill="#9A63EC"/>
</svg>
</span>
<span>{{ article.title }}</span>
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
</div>

View file

@ -93,6 +93,28 @@
</ul>
</div>
{% endif %}
<!-- Related Articles -->
{% if related_articles %}
<div class="mb-40">
<h3 class="fw-semibold mb-12">Related Articles</h3>
<ul class="list-unstyled space-y-12 fs-19 ps-0">
{% for article in related_articles %}
<li>
<a class="d-flex align-items-center text-gray-500 h-32 lh-32" href="{{ article.get_absolute_url }}">
<span class="pr-10">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-text" viewBox="0 0 16 16">
<path d="M5 4a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm-.5 2.5A.5.5 0 0 1 5 6h6a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5M5 8a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z" fill="#9A63EC"/>
<path d="M2 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2zm10-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1z" fill="#9A63EC"/>
</svg>
</span>
<span>{{ article.title }}</span>
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
</div>

View file

@ -129,10 +129,20 @@ def offering_detail(request, provider_slug, service_slug):
except VSHNAppCatPrice.DoesNotExist:
pass
# Get related articles for both cloud provider and service
provider_articles = offering.cloud_provider.articles.filter(
is_published=True
).order_by("-created_at")[:3]
service_articles = offering.service.articles.filter(is_published=True).order_by(
"-created_at"
)[:3]
context = {
"offering": offering,
"pricing_data_by_group_and_service_level": pricing_data_by_group_and_service_level,
"price_calculator_enabled": price_calculator_enabled,
"provider_articles": provider_articles,
"service_articles": service_articles,
}
return render(request, "services/offering_detail.html", context)

View file

@ -84,8 +84,14 @@ def partner_detail(request, slug):
slug=slug,
)
# Get related articles for this partner
related_articles = partner.articles.filter(is_published=True).order_by(
"-created_at"
)[:3]
context = {
"partner": partner,
"services": partner.services.all(),
"related_articles": related_articles,
}
return render(request, "services/partner_detail.html", context)

View file

@ -64,9 +64,15 @@ def provider_detail(request, slug):
)
)
# Get related articles for this cloud provider
related_articles = provider.articles.filter(is_published=True).order_by(
"-created_at"
)[:3]
context = {
"provider": provider,
"services": services,
"ordered_offerings": ordered_offerings,
"related_articles": related_articles,
}
return render(request, "services/provider_detail.html", context)

View file

@ -153,7 +153,13 @@ def service_detail(request, slug):
slug=slug,
)
# Get related articles for this service
related_articles = service.articles.filter(is_published=True).order_by(
"-created_at"
)[:3]
context = {
"service": service,
"related_articles": related_articles,
}
return render(request, "services/service_detail.html", context)