Fix a bug in archive generator due to factorization

Filter posts for new year adding published and front page criteria
This commit is contained in:
Grégory Soutadé 2013-01-03 10:19:37 +01:00
parent bf86e7a81b
commit 7ea8fd9280
3 changed files with 3 additions and 6 deletions

View File

@ -65,13 +65,10 @@ class Archive(Index):
my_post.append(posts[i])
else:
# Last post
my_post.append(post)
my_post.append(posts[i])
if nb_post != 1 and posts[i].creation_date.year != posts[i-1].creation_date.year:
self.cur_year = int(posts[i].creation_date.year)
if len(my_post) != 0:
self.createArchives(src, output, dom, self.hooks, my_post)
if not self.somethingWrote:
self.addReport('Nothing changed')

View File

@ -359,7 +359,7 @@ class Index(DynastieGenerator):
posts = Post.objects.filter(creation_date__year=cur_year, published=True, front_page=True).order_by('-creation_date')
if posts.count() < self.posts_per_page:
posts = Post.objects.all().order_by('-creation_date')[:self.posts_per_page]
posts = Post.objects.filter(published=True, front_page=True).order_by('-creation_date')[:self.posts_per_page]
self.dirname = ''
self.generatePages(dom, posts, src, output, 'index')

View File

@ -18,7 +18,7 @@ import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dynastie.settings")
dynastie_root = '/home/soutade/dynastie/'
dynastie_root = '/home/soutade/Projets_Perso/dynastie2/dynastie/'
if dynastie_root not in sys.path:
sys.path.append(dynastie_root)
dynastie_root += 'dynastie/'