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

Checkout on Otto #11503

Merged
merged 1 commit into from
Feb 17, 2016
Merged

Checkout on Otto #11503

merged 1 commit into from
Feb 17, 2016

Conversation

vkaracic
Copy link
Contributor

Introducing a new CommerceConfiguration. When it's enabled all the checkout functionality will be forwarded to Otto.

@mattdrayer @clintonb can you review this please?
@mjfrey

@openedx-webhooks
Copy link

Thanks for the pull request, @vkaracic! It looks like you're a member of a company that does contract work for edX. If you're doing this work as part of a paid contract with edX, you should talk to edX about who will review this pull request. If this work is not part of a paid contract with edX, then you should ensure that there is an OSPR issue to track this work in JIRA, so that we don't lose track of your pull request.

To automatically create an OSPR issue for this pull request, just visit this link: https://openedx-webhooks.herokuapp.com/github/process_pr?number=11503&repo=edx%2Fedx-platform

@@ -39,7 +38,7 @@ class ChooseModeView(View):
"""

@method_decorator(transaction.non_atomic_requests)
def dispatch(self, *args, **kwargs): # pylint: disable=missing-docstring
def dispatch(self, *args, **kwargs): # pylint: disable=missing-docstring
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to add a docstring for this method and remove the pylint override?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not completely sure about all the use-cases for this view so I'm going to place a general description for this code.

@mattdrayer
Copy link
Contributor

@vkaracic done with my first pass -- let me know when you're ready for another.

@mattdrayer
Copy link
Contributor

Also it looks like you have a quality violation to address

@vkaracic
Copy link
Contributor Author

@mattdrayer thanks for doing the review! I've addressed most of the comments, the ones with theming methods are left (I have a question for it: https://github.com/edx/edx-platform/pull/11503#discussion_r52730366) and the CommerceConfiguration comments, which I'm waiting for @clintonb to weigh in.

@vkaracic
Copy link
Contributor Author

@mattdrayer I believe I have addressed the 'microsite2theming' comments with this commit: edx/edx-platform@e0b2d3f

Aside from the CommerceConfiguration comments I believe the PR is ready for another look.

@mattdrayer
Copy link
Contributor

LGTM @vkaracic! 👍 aside from the open issue regarding Site tie-in which we are looking to @clintonb for some advice -- please remember to squash commits prior to merging

@vkaracic
Copy link
Contributor Author

@bderusha this is the PR that I've mentioned. Please take a look.

super(EcommerceServiceTests, self).setUp()

def test_is_enabled(self):
"""Verify that is_enabled() returns True."""
Copy link
Contributor

Choose a reason for hiding this comment

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

What about when it is disabled?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seeing your other tests, this docstring needs to be more informative: Verify `is_enabled() returns True when not used for a microsite.

checkout_page, sku, course, request = self.prepare_course_about_with_ecommerce()
request.user = AnonymousUser()
mako_middleware_process_request(request)
ecommerce_enrollment_link = (
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a lot of duplicated code across these tests. Combine it into an assertion:

def assert_enrollment_link_present(self, request, href):
  ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally I could see these 4 tests using DDT

@ddt.data(
    (None, True, '<a href="/register?course_id={}&enrollment_action=add_to_ecomm_cart&checkout_url={}?sku={}" class="add-to-cart">'),
    ... etc
)
@dtt.unpack
def test_ecommerce_checkout_with_anonymous(self, min_price, is_anonymous, enrollment_link_template):
    request.user = AnonymousUser() if is_anonymous else self.user
    ... etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up splitting the tests into two with DDT, because two of them test when the shopping cart setting is enabled: 559b964

@clintonb
Copy link
Contributor

👍 pending:

  • All comments acknowledged
  • Comments added around Professional Education changes (see comment)
  • Manual redirects to login/registration page removed

@@ -117,7 +123,8 @@ def get(self, request, course_id, error=None):
)

context = {
"course_modes_choose_url": reverse("course_modes_choose", kwargs={'course_id': course_key.to_deprecated_string()}),
"course_modes_choose_url": reverse("course_modes_choose",
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: put both arguments one singly indented lines.

reverse(
    "course_modes_choose",
    kwargs={'course_id': course_key.to_deprecated_string()}
),

@bderusha
Copy link
Contributor

👍 pending:

  • All non-NIT/ASIDE comments acknowledged (though fixing those while you're at it would be 🚀 )
  • Fix failing tests
  • Squash commits

@vkaracic vkaracic force-pushed the coupons/otto-checkout branch 4 times, most recently from 01570ce to 5c44398 Compare February 17, 2016 12:16
@@ -232,6 +233,45 @@ def test_course_about_in_cart(self):
self.assertEqual(response.status_code, 200)
self.assertIn(in_cart_span, response.content)

def assert_enrollment_link_present(self, is_anonymous, _id=False):
""" Prepare ecommerce checkout data and assert if the ecommerce link is contained in the response. """
Copy link
Contributor

Choose a reason for hiding this comment

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

Document the kwargs.

@vkaracic
Copy link
Contributor Author

@clintonb I believe I have addressed all your comment. You were right about the login, I've removed that code which rendered the JS additions unnecessary so those are gone as well.

@bderusha as I removed the JS changes this aside https://github.com/edx/edx-platform/pull/11503#discussion_r52785405 might not be applicable anymore. Also I tend to agree with Clinton that this comment https://github.com/edx/edx-platform/pull/11503#discussion_r53178474 isn't necessary so I removed it, I hope that's OK.

@bderusha
Copy link
Contributor

@vkaracic That's fine

@clintonb
Copy link
Contributor

Cool.

@vkaracic vkaracic force-pushed the coupons/otto-checkout branch from 2699462 to 86a4710 Compare February 17, 2016 17:13
vkaracic added a commit that referenced this pull request Feb 17, 2016
@vkaracic vkaracic merged commit 2312b22 into master Feb 17, 2016
@vkaracic vkaracic deleted the coupons/otto-checkout branch February 17, 2016 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants