-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Just a couple of little things to fix and a suggestion to make it a little more specific.
I'd like to help you out and add a test for this. Would that be alright with you? I'll probably try to create a PR that merges into your branch. :) |
bookwyrm/views/feed.py
Outdated
@@ -66,6 +72,7 @@ def get(self, request, tab, filters_applied=False): | |||
"path": f"/{tab['key']}", | |||
"annual_summary_year": get_annual_summary_year(), | |||
"has_tour": True, | |||
"has_read_throughs": len(readthroughs) > 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are filtering on the date as well, can we name this property "has_summary_read_throughs"
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That does actually make sense and will avoid potential confusion in future.
I've also just realised the value could simply be len(readthroughs)
because 0
is falsy.
@rsk2 do you mind making those two small changes? Then we'll stop bike-shedding this and I'll pull it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, done!
@bSolt Thanks :) |
Need to get better familiarized with the tests and patterns used here myself, actually. I am also new to the project and I had some trouble with how to test this specific feature. Getting this merged to fix the bug sooner is probably a better priority IMO. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you would like a primer on the tests anyway, but this is looking fine to me for now. Thanks!
I'm planning to add some info to the docs about writing and updating tests, as it can be very confusing for people new to the project and/or Django (as I know from my own experience!) There have been some fairly urgent other things to resolve recently but I'll try to get back to that soon. |
Hmm, I think I have led you astray here with |
Ok @rsk2 sorry about this, I gave you some bad advice.
So that's why the test is failing: because you can't make a date with a year value of However, you can fix this reasonably easily because we only need to know whether the 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 []
) |
@hughrun no worries. Thanks for the fix. |
Fixes #3187