add show tags of last months only
This commit is contained in:
@@ -7,13 +7,14 @@ from posts.models import Post, FetMeeting, Event
|
||||
|
||||
def index(request):
|
||||
posts = deque(Post.articles.get_visible_articles())
|
||||
posts_for_tags = deque(Post.objects.get_last_months_posts())
|
||||
|
||||
def get_tags(lst):
|
||||
for p in lst:
|
||||
for t in list(p.tags.names()):
|
||||
yield "#" + t
|
||||
|
||||
t = set(t for t in get_tags(posts))
|
||||
t = set(t for t in get_tags(posts_for_tags))
|
||||
|
||||
# set the pinned post
|
||||
featured_post = Post.articles.get_pinned_article()
|
||||
|
||||
@@ -2,6 +2,8 @@ from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.utils import timezone
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
class PostManager(models.Manager):
|
||||
def get_queryset(self):
|
||||
@@ -10,7 +12,11 @@ class PostManager(models.Manager):
|
||||
def get_visible_articles(self):
|
||||
return self.get_queryset().filter(is_hidden=False)
|
||||
|
||||
def all_post_with_date(self):
|
||||
def get_last_months_posts(self):
|
||||
date_today = timezone.now().date()
|
||||
return self.get_visible_articles().filter(public_date__gt=date_today - timedelta(days=365))
|
||||
|
||||
def get_all_posts_with_date(self):
|
||||
return (
|
||||
self.get_queryset()
|
||||
.filter(Q(event_start__isnull=False) & Q(event_end__isnull=False))
|
||||
|
||||
@@ -34,7 +34,7 @@ def index(request):
|
||||
|
||||
def calendar(request):
|
||||
"Kalender Ansicht ICS zur Verknüpfung mit Outlook"
|
||||
events = deque(Post.objects.all_post_with_date().all())
|
||||
events = deque(Post.objects.get_all_posts_with_date())
|
||||
|
||||
return render(
|
||||
request,
|
||||
|
||||
Reference in New Issue
Block a user