Skip to content

Commit

Permalink
Merge pull request #3207 from rsk2/issue-3187
Browse files Browse the repository at this point in the history
Hide "year in the books" for newly registered users
  • Loading branch information
hughrun authored Jan 30, 2024
2 parents 193aeff + ef6fd60 commit 21a8570
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit 21a8570

Please sign in to comment.