Skip to content
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

Conversation

dmitry-viskov
Copy link
Contributor

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):

courseware/tab_courseware.html 
courseware/tab_info.html 
courseware/tab_discussion.html 
courseware/tab_wiki.html 
courseware/tab_progress.html
courseware/tab_instructor.html

@singingwolfboy
Copy link
Contributor

@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 edx/master and then cherry-pick the one non-merge commit that you have in this pull request, and then force-push to update the pull request.

This page might also be helpful: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request

@openedx-webhooks
Copy link

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:

  • supporting documentation
  • edx-code email threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

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.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U needs triage waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels Dec 28, 2015
@dmitry-viskov dmitry-viskov force-pushed the render-lms-main-navigation-with-template branch from 02a463e to 1179c82 Compare December 28, 2015 19:31
@dmitry-viskov
Copy link
Contributor Author

@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)"><%
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.)

Copy link
Contributor Author

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).

@openedx-webhooks openedx-webhooks added engineering review and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Dec 28, 2015
@dmitry-viskov
Copy link
Contributor Author

@singingwolfboy @dpowell I've updated the pull requests according to your comments. About fallback argument - I've left it without changes.

@dmitry-viskov dmitry-viskov force-pushed the render-lms-main-navigation-with-template branch from 8d616c5 to 5bfa11b Compare December 29, 2015 15:01
@@ -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)
Copy link
Contributor

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)

Copy link
Contributor Author

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 :-)

@dmitry-viskov dmitry-viskov force-pushed the render-lms-main-navigation-with-template branch from 5bfa11b to bad82a6 Compare December 31, 2015 11:21
@jbarciauskas
Copy link
Contributor

@nedbat FYI - not sure if this should go to you or someone else, just FYI

@dpowell
Copy link
Contributor

dpowell commented Jan 13, 2016

What are the next steps on this pull request?

@jbarciauskas
Copy link
Contributor

@dpowell Since DB has left, we just need to figure out who the right person is to pick up this review. It might be @nedbat but he's pretty heavily involved in getting Dogwood out the door at the moment.

@nedbat
Copy link
Contributor

nedbat commented Jan 27, 2016

We should give this to T&L.

@cahrens
Copy link

cahrens commented Jan 28, 2016

As I indicated in the JIRA ticket, I think this PR should be reviewed by @mattdrayer on the Solutions team.

@mattdrayer
Copy link
Contributor

@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):
Copy link
Contributor

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>

@ziafazal
Copy link
Contributor

@mattdrayer @strannikk this PR lacks test coverage in specially with course tab overrides.

@dmitry-viskov
Copy link
Contributor Author

@ziafazal I've already created the test "test_optional_include_mako_with_fallback": https://github.com/edx/edx-platform/pull/11076/files#diff-63196f493f5c1eaf461be34d34bf5320R18
Or do you mean that there will be needed tests in case of overriding course tabs instead of each single tab?

@ziafazal
Copy link
Contributor

@strannikk yeah tests for tab overrides.

@mattdrayer
Copy link
Contributor

@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" />
Copy link
Contributor

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.

Copy link
Contributor Author

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

@dmitry-viskov
Copy link
Contributor Author

@mattdrayer @saleem-latif @ziafazal @jbarciauskas What are the next steps with this PR?

@nedbat
Copy link
Contributor

nedbat commented Feb 11, 2016

jenkins run all

@ziafazal
Copy link
Contributor

jenkins run bokchoy

@ziafazal
Copy link
Contributor

jenkins run all

@dmitry-viskov
Copy link
Contributor Author

@ziafazal I've updated the PR according your comments but now the test:

./manage.py lms test --verbosity=2 lms/djangoapps/courseware/tests/test_microsites.py:TestMicrosites.test_microsite_course_custom_tabs --settings=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:

paver test_bokchoy -t discussion/test_discussion.py:DiscussionHomePageTest --fasttest

but because of this I had to move <ol> </ol> tags from the tabs.html template

@dmitry-viskov dmitry-viskov force-pushed the render-lms-main-navigation-with-template branch from f5c80f0 to bd0af7f Compare February 15, 2016 13:16
@dmitry-viskov dmitry-viskov force-pushed the render-lms-main-navigation-with-template branch from bd0af7f to d532f8d Compare February 16, 2016 14:30
@dmitry-viskov
Copy link
Contributor Author

@ziafazal I've rebased the PR with the last master (with your get_template_path fix). Could you please run tests again ?

@mattdrayer
Copy link
Contributor

jenkins run all

@mattdrayer mattdrayer closed this Feb 16, 2016
@mattdrayer mattdrayer reopened this Feb 16, 2016
@openedx-webhooks
Copy link

Hello @strannikk: We are unable to continue with review of your submission at this time. Please see the associated JIRA ticket for more explanation.

@mattdrayer
Copy link
Contributor

jenkins run all

@mattdrayer mattdrayer reopened this Feb 16, 2016
@benpatterson
Copy link
Contributor

jenkins ok to test

@benpatterson
Copy link
Contributor

jenkins add to whitelist

@dmitry-viskov
Copy link
Contributor Author

@mattdrayer @saleem-latif @ziafazal @jbarciauskas @benpatterson all tests are green. Is there anything else I can do with this PR?

@jbarciauskas
Copy link
Contributor

@strannikk I'll put this back into awaiting review. @mattdrayer @ziafazal who will give the final thumbs up on this?

@mattdrayer
Copy link
Contributor

I'll leave the final thumbs up to @ziafazal on this one -- he has the most context at this point.

@ziafazal
Copy link
Contributor

LGTM 👍

@jbarciauskas
Copy link
Contributor

k, who's going to click the green button? :) @ziafazal @mattdrayer

ziafazal added a commit that referenced this pull request Feb 18, 2016
…ion-with-template

Render lms main navigation (tabs) with template
@ziafazal ziafazal merged commit e8ccc2f into openedx:master Feb 18, 2016
@dmitry-viskov dmitry-viskov deleted the render-lms-main-navigation-with-template branch May 19, 2017 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting prioritization open-source-contribution PR author is not from Axim or 2U waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.