if no input, all posts are shown

This commit is contained in:
2024-01-30 18:15:10 +00:00
parent ec3c11467f
commit 99b06b78a5

View File

@@ -42,25 +42,9 @@ def index(request):
form.cleaned_data["fet_meeting_only"], form.cleaned_data["fet_meeting_only"],
) )
else: else:
last_year = Post.objects.get_queryset().first() # If no input, all posts are shown.
if last_year: form = PostSearchForm()
last_post_year = last_year.date.year posts = Post.objects.date_filtered_list(public_only)
now_year = timezone.now().year
# if the last post is a year old or more, then set year to it
if last_post_year < now_year:
year = last_post_year
else:
year = now_year
else:
year = None
data = {
"year": year,
}
form = PostSearchForm(data)
posts = Post.objects.date_filtered_list(public_only, data["year"])
context = { context = {
"formset": form, "formset": form,