Updated sorting for issue and landing page - exclude inquiry category

main
Domen Kosmač 2022-12-23 13:27:11 +01:00
parent a351ad52df
commit ef2eb4c9d3
4 changed files with 10 additions and 2 deletions

View File

@ -154,6 +154,12 @@ class Issue(models.Model):
else: else:
return self.articles.all() return self.articles.all()
def get_ordered_articles(self):
if self.published:
return self.articles.filter(published=True).exclude(category__slug='inquiry').order_by('featured__order_on_homepage')
else:
return self.articles.all()
# Use h2 or h3 in footer depending on the length of the title. # Use h2 or h3 in footer depending on the length of the title.
def get_title_header(self): def get_title_header(self):
if len(self.title) > 30: if len(self.title) > 30:

View File

@ -69,7 +69,7 @@ def view_article(request, slug):
# If there are other languages, add the main article (for English). # If there are other languages, add the main article (for English).
translations.append(article) translations.append(article)
articles = article.issue.get_articles().filter(published=True).order_by('featured__order_on_homepage') articles = article.issue.get_ordered_articles()
context = { context = {
'translations': translations, 'translations': translations,
'article': article, 'article': article,

View File

@ -52,7 +52,7 @@
</div> </div>
<br /> <br />
<div class="ui three column stackable grid" style="padding-left:15px"> <div class="ui three column stackable grid" style="padding-left:15px">
{% for article in issue.get_articles %} {% for article in issue.get_ordered_articles %}
<div class="column"> <div class="column">
{% include 'article_thumb.html' with article=article only %} {% include 'article_thumb.html' with article=article only %}
</div> </div>

View File

@ -27,6 +27,7 @@
<div class="ui basic segment"> <div class="ui basic segment">
<div class="ui stackable grid"> <div class="ui stackable grid">
<div class="thirteen wide column"> <div class="thirteen wide column">
<br>
<h1 class="ui header"> <h1 class="ui header">
{{ page.title }} {{ page.title }}
<div class="sub header"> <div class="sub header">
@ -38,6 +39,7 @@
</div> </div>
</div> </div>
<div class="three wide column"> <div class="three wide column">
<br><br>
{% include "ads.html" %} {% include "ads.html" %}
</div> </div>
</div> </div>