add searching for posts by date
This commit is contained in:
@@ -25,6 +25,38 @@ class PostManager(models.Manager):
|
||||
|
||||
return posts
|
||||
|
||||
def get_date_filtered_list(self, year=None, month=None, fet_meeting_only=None):
|
||||
post_list = []
|
||||
|
||||
if not fet_meeting_only:
|
||||
posts = self.get_visible_articles().filter(~Q(post_type="N"))
|
||||
else:
|
||||
posts = self.get_visible_articles().filter(post_type="F")
|
||||
|
||||
if year:
|
||||
posts = posts.filter(event_start__year=year)
|
||||
if month:
|
||||
posts = posts.filter(event_start__month=month)
|
||||
|
||||
for post in posts:
|
||||
post_list.append((post, post.event_start.date()))
|
||||
|
||||
if not fet_meeting_only:
|
||||
posts = self.get_visible_articles().filter(post_type="N")
|
||||
|
||||
if year:
|
||||
posts = posts.filter(public_date__year=year)
|
||||
if month:
|
||||
posts = posts.filter(public_date__month=month)
|
||||
|
||||
for post in posts:
|
||||
post_list.append((post, post.public_date))
|
||||
|
||||
result = sorted(post_list, key=lambda x: x[1], reverse=True)
|
||||
posts = [x[0] for x in result]
|
||||
|
||||
return posts
|
||||
|
||||
def get_last_months_posts(self):
|
||||
date_today = timezone.now().date()
|
||||
return self.get_visible_articles().filter(
|
||||
|
||||
Reference in New Issue
Block a user