Skip to content

Commit

Permalink
Merge branch 'master' into docs/update-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Kristian Losvik committed Mar 12, 2019
2 parents 2883533 + 57c1159 commit 8306557
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions norwegian_ehealth/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ class HomePage(BasePage):

def get_context(self, request, *args, **kwargs):
context = super().get_context(request, *args, **kwargs)
latest_articles = NewsPage.objects.live().public().order_by('-publication_date')
context['article_top'] = latest_articles[0]
context['articles_row_1'] = latest_articles[1:4]
context['articles_row_2'] = latest_articles[4:7]
context['featured_row_1'] = self.featured_pages.all()[:3]
context['featured_row_2'] = self.featured_pages.all()[3:6]

if NewsPage.objects.live().public().count() >= 1 :
latest_articles = NewsPage.objects.live().public().order_by('-publication_date')
context['article_top'] = latest_articles[0]

if NewsPage.objects.live().public().count() >= 7 :
context['articles_row_1'] = latest_articles[1:4]
context['articles_row_2'] = latest_articles[4:7]
context['featured_row_1'] = self.featured_pages.all()[:3]
context['featured_row_2'] = self.featured_pages.all()[3:6]

return context

0 comments on commit 8306557

Please sign in to comment.