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

#157 Serve Catalog Page from Wagtail #411

Merged
merged 1 commit into from
Jun 5, 2019

Conversation

ahmed-arbisoft
Copy link
Contributor

@ahmed-arbisoft ahmed-arbisoft commented May 30, 2019

Pre-Flight checklist

  • Migrations
    • Migration is backwards-compatible with current production code
  • Testing
    • Changes have been manually tested

What are the relevant tickets?

Closes #157
Closes #378

What's this PR do?

Simplifies catalog page structure. Removes extraneous html markup. Configures wagtail to server the catalog page.

How should this be manually tested?

Go to the catalog page by clicking the link in the header or going to the path /catalog/ in your deployment. The page should appear as per specifications.

@odlbot odlbot temporarily deployed to xpro-ci-pr-411 May 30, 2019 13:54 Inactive
@asadiqbal08
Copy link
Contributor

@ahmed-arbisoft you need to rebase it. I have looked into the PR, it looks good me. 👍

@codecov-io
Copy link

codecov-io commented May 30, 2019

Codecov Report

Merging #411 into master will increase coverage by 0.02%.
The diff coverage is 89.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #411      +/-   ##
==========================================
+ Coverage   94.32%   94.35%   +0.02%     
==========================================
  Files         202      202              
  Lines        6560     7105     +545     
  Branches      370      439      +69     
==========================================
+ Hits         6188     6704     +516     
- Misses        301      323      +22     
- Partials       71       78       +7
Impacted Files Coverage Δ
mitxpro/urls.py 78.57% <ø> (-1.43%) ⬇️
cms/factories.py 100% <100%> (ø) ⬆️
cms/models.py 94.95% <87.5%> (+0.73%) ⬆️
courses/views.py 84.21% <0%> (-15.79%) ⬇️
courses/models.py 91.11% <0%> (-2.97%) ⬇️
...ic/js/containers/pages/admin/BulkEnrollmentPage.js 93.33% <0%> (-1.67%) ⬇️
ecommerce/views.py 99.5% <0%> (-0.5%) ⬇️
static/js/lib/ecommerce.js 100% <0%> (ø) ⬆️
static/js/lib/ecommerce_test.js 100% <0%> (ø) ⬆️
static/js/components/forms/EmailForm.js 100% <0%> (ø) ⬆️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf2b3e5...74ab561. Read the comment docs.

@gsidebo
Copy link
Contributor

gsidebo commented May 31, 2019

@pdpinch Do we need to be able to link directly to the programs or courses tab in the catalog? To put it another way: If a user is on the course catalog with the "Programs" tab selected and reloads the page, is it important that the user remain on the "Programs" tab? If so, do you have any strong opinions about what the path should be, e.g.: /programs/ or /catalog/?tab=programs?

Copy link
Contributor

@gsidebo gsidebo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

courses.views.CourseCatalogView should be removed, shouldn't it?

cms/models.py Outdated
"HUBSPOT_NEW_COURSES_FORM_GUID"
),
)
return context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you can remove the super() call on the first line, and this return can be changed to:

        return dict(
            **super().get_context(request),
            **get_js_settings_context(request),
            program_pages=program_pages,
            course_pages=course_pages,
            default_image_path=DEFAULT_COURSE_IMG_PATH,
            hubspot_portal_id=settings.HUBSPOT_CONFIG.get("HUBSPOT_PORTAL_ID"),
            hubspot_new_courses_form_guid=settings.HUBSPOT_CONFIG.get(
                "HUBSPOT_NEW_COURSES_FORM_GUID"
            ),
        )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

</div>
</div>
<div class="bottom">
<input type="checkbox" class="toggle" id="collapsible_{{ tab }}_{{ object_type }}_{{ courseware_page.pk }}" data-target="#collapse-{{ tab }}-{{ object_type }}-{{ courseware_page.pk }}" data-toggle="collapse" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we should use the 'with' templatetag to define these complex id's rather than redefining them. Also, wouldn't it be sufficient just to define them as something like collapsible_{{ courseware_page.pk }}? Shouldn't the pk value be unique for each object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating to collapsible_{{ tab}}_{{ coursewate_page.pk }} as the same page can appear in another tab and we don't want to be toggling in both tabs at once.

<ul class="program-course-links">
{% for course_page in courseware_page.course_pages %}
<li>
<a href="{% pageurl course_page %}" target="_blank">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a requirement that these links open in a new tab? Same comment for the link at line 82

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, it was requested by @asadiqbal08 do you want me to remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM, I just went ahead and removed it, was creating too many tabs anyway.

course=CourseFactory.create(program=program, live=True)
)
course_page_no_program = CoursePageFactory.create(
course=CourseFactory.create(no_program=True, live=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good change, but I think the create calls can be simplified:

   course_page_in_program = CoursePageFactory.create(
      course__program=program, course__live=True
   )
   course_page_no_program = CoursePageFactory.create(
       course__no_program=True, course__live=True
   )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

ProgramPageFactory.create(program=program)
CoursePageFactory.create(course=course_in_program)
CoursePageFactory.create(course=course_no_program)
program_page = ProgramPageFactory.create(program=program)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

catalog_page = CatalogPage(title="Catalog", slug="catalog")
catalog_page = Site.objects.get(is_default_site=True).root_page.add_child(
catalog_page, "last-child"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a fixture for (a) the root page (Site.objects.get(is_default_site=True).root_page), and (b) the catalog page (lines 210 to here). The catalog page fixture would user the root page fixture, then this test case would use the catalog page fixture. You can just define them at the top of this module

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1,12 +1,7 @@
"""Tests for URLs"""

from unittest import TestCase
from django.urls import reverse


class URLTests(TestCase):
"""URL tests"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole file can be deleted. It's not doing anything for us

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@pdpinch
Copy link
Member

pdpinch commented Jun 3, 2019

@gsidebo asked:

Do we need to be able to link directly to the programs or courses tab in the catalog? To put it another way: If a user is on the course catalog with the "Programs" tab selected and reloads the page, is it important that the user remain on the "Programs" tab? If so, do you have any strong opinions about what the path should be, e.g.: /programs/ or /catalog/?tab=programs?

I think the current implementation, with one /catalog/ URL, is fine, unless it's somehow simpler to create unique URLs for each tab.

Copy link
Contributor

@gsidebo gsidebo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last thing

</div>
<div class="bottom">
{% with page_id=courseware_page.pk|stringformat:"i" %}
{% with collapse_id="collapsible_"|add:tab|add:"_"|add:page_id|add:page_id collapse_input_id="collapse_"|add:tab|add:page_id %}
Copy link
Contributor

@gsidebo gsidebo Jun 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Looks like you're adding page_id twice to the first var: add:page_id|add:page_id
  2. The collapse_input_id value should have an underscore between tab and page_id
  3. Any reason we can't combine these definitions with the page_id definition above to make one with block instead of 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. That' a typo, will fix it in the next commit
  2. Will update.
  3. The tab variable is string and courseware_page.pk is an int. Using both in the same chain of add filter does not play nice with string concatenation so we have to convert it to a string before we can use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Contributor

@gsidebo gsidebo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 👍

Missed change
Rebase and Migration Fixes
Feedback
collapsible tags fix
Fix typo and feedback
@ahmed-arbisoft ahmed-arbisoft force-pushed the ahmedbelal/157-serve-catalog-page-wagtail branch from 6073c32 to 74ab561 Compare June 5, 2019 14:37
@ahmed-arbisoft ahmed-arbisoft merged commit 7eb87d0 into master Jun 5, 2019
@ahmed-arbisoft ahmed-arbisoft deleted the ahmedbelal/157-serve-catalog-page-wagtail branch June 5, 2019 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Course Catalog: Long program description gets cut off Serve course catalog page from Wagtail
7 participants