-
Notifications
You must be signed in to change notification settings - Fork 12
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
Adds filtering by post author's native languages to post list (#140) #421
base: main
Are you sure you want to change the base?
Adds filtering by post author's native languages to post list (#140) #421
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.
Recording.2024-01-18.150627.mp4
We have a couple of issues:
Posts do not filter correctly when lang_code is None
See video.
http://127.0.0.1:8000/journals/?mode=teach&author_native_lang_code=ja&lang_code=None
def get_lang_code(self):
return self.request.GET.get("lang_code", None)
What's happening here is that language code will evaluate to the string "None"
which is a truthy value. So, we will either need to update the conditionals or explicitly check for this and return None
:
def get_lang_code(self):
code = self.request.GET.get("lang_code", None)
if code == "None"
return None
return code
I would also look into your get_author_native_lang_code
method.
Incorrect post counts when both the native language and language codes are selected
See video. The count is displayed is 12
, but the actual count is 14
.
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.
The issue comes from how we're setting the query params from the frontend. In get_context_data
, we return the result of these getters, which in Python are None
. These get passed back as selected_lang_code
, which we use to create the url in post_list.html
, and end up making the url look like ?mode=teach&author_native_lang_code=all&lang_code=None
If we modify the getters to just default to the value "all", then we won't receive "None" in the query params.
def get_lang_code(self):
return self.request.GET.get("lang_code", "all")
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.
Need to look into incorrect post counts, should look for discrepancy btwn posts/views.py
and posts/helpers.py
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.
Also, right now the native language counts are a subset of the original language code (i.e it should always be less than or equal to the count of the original language code). This make it a little confusing if you try to set the original language code after first setting the native language code. Not sure what the best solution is -- maybe for consistency, the count should always reflect the posts that would be shown as a result of applying that filter? In which case we'd have to update the original one to take into account the native language filter. Do you agree?
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.
From my observations, the native speaking language filter seems to always be off by one (lower)
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.
... If we modify the getters to just default to the value "all", then we won't receive "None" in the query params.
I like your solution 💯
Not sure what the best solution is -- maybe for consistency, the count should always reflect the posts that would be shown as a result of applying that filter? In which case we'd have to update the original one to take into account the native language filter. Do you agree?
Good point -- let's make it consistent. I'm not sure where else that function is currently being used, so we would need to make sure it doesn't break elsewhere.
Let me get back to you about the logo (icon) and mobile responsiveness! There's a PR (#403) about setting up mock data. You can check it out and run the |
@alexcjwei I'm just checking in. Do you have any questions or need any help? |
Adds additional dropdown to filter posts by the author's native language with test.
data-link
accordinglyLooking for any feedback, from code cleanliness and best practices, better ideas for logos for clarity, and suggestions to improve mobile if any.
Examples from local browser below: