-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Render lms main navigation (tabs) with template #11076
Render lms main navigation (tabs) with template #11076
Conversation
@strannikk: we use a rebase workflow with the Open edX codebase, not a merge workflow. You have three merge commits in this pull request. Can you take them out? The easiest way to do that would probably be to reset your branch to the tip of This page might also be helpful: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request |
Thanks for the pull request, @strannikk! I've created OSPR-1044 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams. Feel free to add as much of the following information to the ticket:
All technical communication about the code itself will still be done via the GitHub pull request interface. As a reminder, our process documentation is here. We can't start reviewing your pull request until you've submitted a signed contributor agreement or indicated your institutional affiliation. You haven't added yourself to the AUTHORS file for this repo. Please create a new pull request to do so! Please see the CONTRIBUTING file for more information. |
02a463e
to
1179c82
Compare
@singingwolfboy I've removed merge commits, please check |
@@ -99,3 +99,18 @@ | |||
else: | |||
tmpl.render_context(context) | |||
%></%def> | |||
|
|||
<%def name="optional_include_mako_with_fallback(file, fallback, with_microsite=False, **kwargs)"><% |
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.
Why not just fold this functionality into the optional_include_mako
function that already exists? If the file isn't found, check and see if a fallback was specified. If so, try to use it; if not, pass.
Also, what happens if the template author wants to define a list of fallbacks?
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.
@singingwolfboy do you suggest to extend optional_include_mako function with fallback and kwargs params? It seemed that in slack discussion you first offered to create separated function like optional_include_mako_with_fallback with additional arguments.
Ok I will extend existed function with new arguments.
Also, what happens if the template author wants to define a list of fallbacks?
Do you suggest to provide fallback param as a list of pathes to templates? I can do it but I think that one fallback template will be sufficient for the 99% cases.
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.
You're right that I suggested that in chat, but I was throwing out a suggestion without really considering the implications. Now that I see the code, I think it would be better to fold this improvement into the original function. (Sometimes my off-the-cuff suggestions are wrong. Sorry! 😜)
You're right that one fallback template will probably be sufficient in many cases, but probably not all cases. We should consider how we want to handle those other cases. I'm open to suggestions -- maybe we should optimize for the "one fallback" case, and have a separate argument that is used for multiple fallbacks. Maybe we shouldn't handle multiple fallbacks at all, and let the template author write the logic into the template. But I suspect there's something we can do to make it at least a little bit cleaner.
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.
As for me there are two possible variants: 1. shouldn't handle multiple fallbacks at all (template author should provide provide the logic into his template), 2. to consider fallback argument as a list of templates.
The variant with two separate arguments (one for the first fallback and one for the others) looks strange. Also we could consider fallback param as one fallback if it was passed as a string and as a group of fallbacks if it was passed as a list. But I think this variant strange and non-intuitive as well.
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.
FWIW, I like the solution of the fallback argument being either a string or a list of strings (which could of course have a single element.)
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.
@dpowell string_or_list argument could be a solution but for me it looks like a little bit unpythonic. The philosophy of python is based on the couple of principles. "Explicit is better than implicit" one of them. So as for my opinion if function always expects an argument as a list it is more explicit (even this list consists of only one element).
@singingwolfboy @dpowell I've updated the pull requests according to your comments. About fallback argument - I've left it without changes. |
8d616c5
to
5bfa11b
Compare
@@ -86,21 +86,11 @@ | |||
<ol class="course-tabs"> | |||
% for tab in get_course_tab_list(request, course): | |||
<% | |||
tab_is_active = (tab.tab_id == active_page) or (tab.tab_id == default_tab) | |||
tab_is_active = (tab.tab_id == active_page) or (tab.tab_id == default_tab) |
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.
Nitpick: this can be shortened to:
tab_is_active = tab.tab_id in (active_page, default_tab)
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, I'll change this string. But this behavior was before my pull request :-)
5bfa11b
to
bad82a6
Compare
@nedbat FYI - not sure if this should go to you or someone else, just FYI |
What are the next steps on this pull request? |
We should give this to T&L. |
As I indicated in the JIRA ticket, I think this PR should be reviewed by @mattdrayer on the Solutions team. |
@ziafazal @saleem-latif -- please take a look at this PR when you have a moment |
@@ -86,21 +86,11 @@ | |||
<ol class="course-tabs"> | |||
% for tab in get_course_tab_list(request, course): |
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 think we need to simply things. We should provide ability to override all course tabs instead of each single tab with a separate template file.
we can include a tabs file here like this
<%static:optional_include_mako file="courseware/tabs.html" >
Then inside tabs.html
we should handle rendering of tabs like this
<ol class="course-tabs">
% for tab in get_course_tab_list(request, course):
...................
...................
...................
</ol>
@mattdrayer @strannikk this PR lacks test coverage in specially with course tab overrides. |
@ziafazal I've already created the test "test_optional_include_mako_with_fallback": https://github.com/edx/edx-platform/pull/11076/files#diff-63196f493f5c1eaf461be34d34bf5320R18 |
@strannikk yeah tests for tab overrides. |
@strannikk looks like you need a rebase as well |
tabs_tmpl = '/' + base_tabs_tpl | ||
tab_list = get_course_tab_list(request, course) | ||
%> | ||
<%include file="${tabs_tmpl}" args="tab_list=tab_list,active_page=active_page,default_tab=default_tab,tab_image=tab_image" /> |
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.
@strannikk I don't think you need to pass everything in args
. courseware/tabs.html
should have the same context as the container template.
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.
@ziafazal it doesn't work.
Exception 'Undefined' object is not iterable will always be raised.
As I could see the same approach used in many templates in edx. Example:
https://github.com/edx/edx-platform/blob/90f2fb868e0646733fad8ec615af2d2dec11801e/cms/templates/base.html#L59
@mattdrayer @saleem-latif @ziafazal @jbarciauskas What are the next steps with this PR? |
jenkins run all |
jenkins run bokchoy |
jenkins run all |
55335c5
to
f5c80f0
Compare
@ziafazal I've updated the PR according your comments but now the test:
is always failed. So I'm waiting for your fix WL-320. As soon as it will be in master, I'll rebase it with my branch and this test will be set right. Also I'm fixed the failed DiscussionHomePageTest:
but because of this I had to move |
f5c80f0
to
bd0af7f
Compare
…or a specific list item
bd0af7f
to
d532f8d
Compare
@ziafazal I've rebased the PR with the last master (with your |
jenkins run all |
Hello @strannikk: We are unable to continue with review of your submission at this time. Please see the associated JIRA ticket for more explanation. |
jenkins run all |
jenkins ok to test |
jenkins add to whitelist |
@mattdrayer @saleem-latif @ziafazal @jbarciauskas @benpatterson all tests are green. Is there anything else I can do with this PR? |
@strannikk I'll put this back into awaiting review. @mattdrayer @ziafazal who will give the final thumbs up on this? |
I'll leave the final thumbs up to @ziafazal on this one -- he has the most context at this point. |
LGTM 👍 |
k, who's going to click the green button? :) @ziafazal @mattdrayer |
…ion-with-template Render lms main navigation (tabs) with template
The reason for this pull requests is the conversation with @singingwolfboy in Slack:
https://openedx.slack.com/archives/theming/p1449519743000017
Someone wants to rename the “Courseware” tab in the LMS navigation and for now there is no ability to make it easy (only one way to do it is to override the entire template).
With this little improvement every tab could be redefined (for example in microsite theme) with adding specific template (by default courseware/tab_default.html will be taken):