Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide "year in the books" for newly registered users #3207

Merged
merged 9 commits into from
Jan 30, 2024
2 changes: 1 addition & 1 deletion bookwyrm/templates/feed/feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h1 class="title">
</section>
{% endif %}

{% if annual_summary_year and tab.key == 'home' %}
{% if annual_summary_year and tab.key == 'home' and has_summary_read_throughs %}
<section class="block is-hidden" data-hide="hide_annual_summary_{{ annual_summary_year }}">
{% include 'feed/summary_card.html' with year=annual_summary_year %}
<hr>
Expand Down
15 changes: 15 additions & 0 deletions bookwyrm/views/feed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" non-interactive pages """
from datetime import date
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
from django.db.models import Q
Expand Down Expand Up @@ -52,6 +53,19 @@ def get(self, request, tab, filters_applied=False):

suggestions = suggested_users.get_suggestions(request.user)

cutoff = (
date(get_annual_summary_year(), 12, 31)
if get_annual_summary_year()
else None
)
readthroughs = (
models.ReadThrough.objects.filter(
user=request.user, finish_date__lte=cutoff
)
if get_annual_summary_year()
else []
)

data = {
**feed_page_data(request.user),
**{
Expand All @@ -66,6 +80,7 @@ def get(self, request, tab, filters_applied=False):
"path": f"/{tab['key']}",
"annual_summary_year": get_annual_summary_year(),
"has_tour": True,
"has_summary_read_throughs": len(readthroughs),
},
}
return TemplateResponse(request, "feed/feed.html", data)
Expand Down
Loading