-
Notifications
You must be signed in to change notification settings - Fork 2
Display the active language's instrument labels in the first row in the instrument page #437
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
base: develop
Are you sure you want to change the base?
Conversation
| context["active_language"] = ( | ||
| Language.objects.get(en_label=active_language_en) | ||
| if active_language_en | ||
| else Language.objects.get(en_label="English") # default in English | ||
| ) | ||
|
|
||
| # Get the instrument label in the active language | ||
| # Get the instrument label in the active language and moving it to the top of label_aliases_dict | ||
| # Set label to the first instrument name added in the language if there is no "umil_label" set | ||
| active_labels = instrument_names.filter(language=context["active_language"]) | ||
| active_lang = context["active_language"] |
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.
Rather than adding this to the context and then getting it, probably clearer to set the variable first and then add to context:
| active_lang = context["active_language"] | |
| active_lang = ( | |
| Language.objects.get(en_label=active_language_en) | |
| if active_language_en | |
| else Language.objects.get(en_label="English") # default in English | |
| ) | |
| # Get the instrument label in the active language and moving it to the top of label_aliases_dict | |
| # Set label to the first instrument name added in the language if there is no "umil_label" set | |
| context["active_language"] = active_lang |
|
I noticed this is still happening. If applicable, could you please reference the issue directly in the commit message following conventional commits, not only in the PR description? This will make it much more useful for future tracking and context. |
b07244d to
2a8519b
Compare
|
There’s still room for improvement in the commit messages and the effort to keep the Git history clean is very much appreciated::
|
2a8519b to
6b47543
Compare
|
Minor improvements:
Otherwise, I believe this is good to go. |
|
Thank you for your review and help. In general, when the review is completed, should I squash my commits into a single one before merging, or should I keep them separate? |
|
It depends. The author can decide based on what makes the codebase easier to understand and maintain for future developers. |
6b47543 to
f69305f
Compare
|
The PR description still uses github keyword. And the first commit is not linking the related issue correctly. Otherwise, this looks good to me. |
…page - The active language's label is moved to the top of the label list so users see their expected language first. refs: #410
- Cleaned up unused import that was accidentally left in the previous commit
f69305f to
f2bea0c
Compare
| active_language_en = self.request.session.get("active_language_en", None) | ||
| context["active_language"] = ( | ||
| active_lang = ( | ||
| Language.objects.get(en_label=active_language_en) | ||
| if active_language_en | ||
| else Language.objects.get(en_label="English") # default in English | ||
| ) |
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.
| active_language_en = self.request.session.get("active_language_en", None) | |
| context["active_language"] = ( | |
| active_lang = ( | |
| Language.objects.get(en_label=active_language_en) | |
| if active_language_en | |
| else Language.objects.get(en_label="English") # default in English | |
| ) | |
| active_language_en = self.request.session.get("active_language_en", "English") | |
| active_lang = Language.objects.get(en_label=active_language_en) |
| umil_label = active_labels.filter(umil_label=True) | ||
| if umil_label.exists(): | ||
| context["active_instrument_label"] = umil_label.first() | ||
|
|
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.
I'm wondering if ordering your query of instrument names above wouldn't make all of this a lot simpler?
If you order by active language first, and then by umil_label = True, and then by date of creation (or pk), then I think your resulting queryset will be in the order you want, without all of this post-processing.
You could even go a step further and do the aggregation that is currently being done in python with your query, but at the very least, I think the ordering could be more clearly done in query.
|
I would suggest to highlight the first row by a different background color to show the user that this line is out of the order on purpose. But why are we ordering by creation time? Did we agree on order by alphabetical order? |
The list of labels on the instrument page is ordered by creation time. The label for the active language is prioritized by placing it at the top of the list.
refs: #410