← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands-website/fix_news into lp:widelands-website

 

kaputtnik has proposed merging lp:~widelands-dev/widelands-website/fix_news into lp:widelands-website.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1661555 in Widelands Website: "News: New posts with publish 'today' and 'now' aren't shown"
  https://bugs.launchpad.net/widelands-website/+bug/1661555

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands-website/fix_news/+merge/316401

This fixes the bug 1661555

I do not understand exactly why the bug appears... but the django class based views do automatically take care for posts which are published in future, so calling the manager isn't needed here. In fact, when a new post get added, the manager isn't called in the views.

This fix is tested for all views and tested also for posts where date of publish is in future, they didn't show up until the date to publish is reached.

Make the header of a post a link to the post itself. So clicking on the header in a news on the mainpage opens the news itself.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/fix_news into lp:widelands-website.
=== modified file 'news/views.py'
--- news/views.py	2016-12-13 18:28:51 +0000
+++ news/views.py	2017-02-05 11:24:24 +0000
@@ -6,13 +6,12 @@
     YearArchiveView, \
     MonthArchiveView, \
     DateDetailView
-import datetime
 
 
 class NewsList(ArchiveIndexView):
 
     template_name = 'news/category_posts.html'
-    queryset = Post.objects.published()
+    model = Post
     date_field = 'publish'
 
     def get_context_data(self, **kwargs):
@@ -25,7 +24,7 @@
 
 class YearNews(YearArchiveView):
 
-    queryset = Post.objects.published()
+    model = Post
     template_name = 'news/post_archive_year.html'
     date_field = 'publish'
     make_object_list = True
@@ -33,14 +32,14 @@
 
 class MonthNews(MonthArchiveView):
 
-    queryset = Post.objects.published()
+    model = Post
     template_name = 'news/post_archive_month.html'
     date_field = 'publish'
 
 
 class NewsDetail(DateDetailView):
 
-    queryset = Post.objects.published()
+    model = Post
     template_name = 'news/post_detail.html'
     date_field = 'publish'
 

=== modified file 'templates/news/inlines/post_detail.html'
--- templates/news/inlines/post_detail.html	2016-11-20 11:55:39 +0000
+++ templates/news/inlines/post_detail.html	2017-02-05 11:24:24 +0000
@@ -20,7 +20,7 @@
 		</div>
     {% endif %}
 	
-	<h2>{{ object.title }}</h2>
+	<h2><a href="{{ object.get_absolute_url }}" style="color: inherit;">{{ object.title }}</a></h2>
 	
 	{{ object.body|wl_markdown }}
 	


Follow ups