Merge pull request #3207 from rsk2/issue-3187

Hide "year in the books" for newly registered users
This commit is contained in:
Hugh Rundle 2024-01-31 07:03:43 +11:00 committed by GitHub
commit 21a8570035
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -41,7 +41,7 @@
</section> </section>
{% endif %} {% 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 }}"> <section class="block is-hidden" data-hide="hide_annual_summary_{{ annual_summary_year }}">
{% include 'feed/summary_card.html' with year=annual_summary_year %} {% include 'feed/summary_card.html' with year=annual_summary_year %}
<hr> <hr>

View file

@ -1,4 +1,5 @@
""" non-interactive pages """ """ non-interactive pages """
from datetime import date
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.db.models import Q from django.db.models import Q
@ -52,6 +53,19 @@ class Feed(View):
suggestions = suggested_users.get_suggestions(request.user) 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 = { data = {
**feed_page_data(request.user), **feed_page_data(request.user),
**{ **{
@ -66,6 +80,7 @@ class Feed(View):
"path": f"/{tab['key']}", "path": f"/{tab['key']}",
"annual_summary_year": get_annual_summary_year(), "annual_summary_year": get_annual_summary_year(),
"has_tour": True, "has_tour": True,
"has_summary_read_throughs": len(readthroughs),
}, },
} }
return TemplateResponse(request, "feed/feed.html", data) return TemplateResponse(request, "feed/feed.html", data)