Commit Graph

85 Commits

Author SHA1 Message Date
Feanil Patel
9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00
Matthew Piatetsky
2775b67787 Set discount on order based on discount that was on basket 2019-12-27 11:53:56 -05:00
Matthew Piatetsky
51ea129267 never give users discount unless they've seen the banner 2019-11-22 15:54:59 -05:00
Matthew Piatetsky
b0c9662b51 remove discount banner from track selection 2019-11-12 13:28:27 -05:00
julianajlk
afae1f1d2a a11y: add role to FPD banner (#22225)
REV-705
2019-11-04 10:46:53 -05:00
julianajlk
a4ca026c19 add missing parameter to discount_percentage 2019-10-25 16:28:33 -04:00
Matthew Piatetsky
86bb0cfa2c add discount percentage configuration 2019-10-23 12:00:34 -04:00
julianajlk
6e0914ad5d add FPD banner to courseware (#22113)
REV-980
2019-10-23 09:33:11 -04:00
julianajlk
98f907f23c Revert "add first purchase discount to courseware (#22058)"
This reverts commit 059b619794.
2019-10-21 13:57:18 -04:00
julianajlk
059b619794 add first purchase discount to courseware (#22058)
REV-980.
* moved get_first_purchase_offer_banner_fragment to Discounts utils.py
* added banner wrapper method
* updated banner with time limit
2019-10-21 13:56:38 -04:00
Matthew Piatetsky
ec8f9f8f86 disable discount when upgrade deadline has passed 2019-10-18 16:15:14 -04:00
Emma Green
def6bced98 move the anonymous check earlier so that it cannot error out when it expects a non-anonymous user 2019-10-17 12:54:36 -04:00
Matthew Piatetsky
f6d0bf77df check if discount expired 2019-10-16 11:32:27 -04:00
Calen Pennington
355826f7d8 Don't try to show anonymous users the first-purchase discount
This fixes errors like:

    Oct 10 12:46:07 ip-10-2-10-15 [service_variant=lms][django.request][env:prod-edx-edxapp] ERROR [ip-10-2-10-15  31278] [user None] [exception.py:135] - Internal Server Error: /courses/course-v1:HarvardX+1962USRx+3T2019/discussions/settings
    Traceback (most recent call last):
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
        response = get_response(request)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
        response = self._get_response(request)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
        response = self.process_exception_by_middleware(e, request)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
        return func(*args, **kwargs)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/newrelic/hooks/framework_django.py", line 539, in wrapper
        return wrapped(*args, **kwargs)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/views/decorators/http.py", line 40, in inner
        return func(request, *args, **kwargs)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
        response = view_func(request, *args, **kwargs)
    File "/edx/app/edxapp/edx-platform/common/djangoapps/util/json_request.py", line 55, in parse_json_into_request
        return view_function(request, *args, **kwargs)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
        return view_func(request, *args, **kwargs)
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 936, in course_discussions_settings_handler
        course, discussion_settings
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 957, in get_divided_discussions
        all_discussions = utils.get_discussion_categories_ids(course, None, include_all=True)
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/django_comment_client/utils.py", line 485, in get_discussion_categories_ids
        xblock.discussion_id for xblock in get_accessible_discussion_xblocks(course, user, include_all=include_all)
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/django_comment_client/utils.py", line 146, in get_accessible_discussion_xblocks
        return get_accessible_discussion_xblocks_by_course_id(course.id, user, include_all=include_all)
    File "/edx/app/edxapp/edx-platform/openedx/core/lib/cache_utils.py", line 73, in decorator
        result = wrapped(*args, **kwargs)
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/django_comment_client/utils.py", line 159, in get_accessible_discussion_xblocks_by_course_id
        if has_required_keys(xblock) and (include_all or has_access(user, 'load', xblock, course_id))
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 158, in has_access
        return _has_access_descriptor(user, action, obj, course_key)
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 572, in _has_access_descriptor
        return _dispatch(checkers, action, user, descriptor)
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 669, in _dispatch
        result = table[action]()
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 543, in can_load
        group_access_response = _has_group_access(descriptor, user, course_key)
    File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/access.py", line 513, in _has_group_access
        user_fragment=partition.access_denied_fragment(descriptor, user, user_group, allowed_groups),
    File "/edx/app/edxapp/edx-platform/openedx/features/content_type_gating/partitions.py", line 98, in access_denied_fragment
        upgrade_price, _ = format_strikeout_price(user, course)
    File "/edx/app/edxapp/edx-platform/openedx/features/discounts/utils.py", line 22, in format_strikeout_price
        if can_receive_discount(user, course):
    File "/edx/app/edxapp/edx-platform/openedx/features/discounts/applicability.py", line 74, in can_receive_discount
        if CourseEnrollment.objects.filter(user=user).exclude(mode__in=CourseMode.UPSELL_TO_VERIFIED_MODES).exists():
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
        return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/query.py", line 787, in filter
        return self._filter_or_exclude(False, *args, **kwargs)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/query.py", line 805, in _filter_or_exclude
        clone.query.add_q(Q(*args, **kwargs))
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1250, in add_q
        clause, _ = self._add_q(q_object, self.used_aliases)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1276, in _add_q
        allow_joins=allow_joins, split_subq=split_subq,
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1206, in build_filter
        condition = lookup_class(lhs, value)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/lookups.py", line 24, in __init__
        self.rhs = self.get_prep_lookup()
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/fields/related_lookups.py", line 112, in get_prep_lookup
        self.rhs = target_field.get_prep_value(self.rhs)
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 966, in get_prep_value
        return int(value)
    TypeError: int() argument must be a string or a number, not 'AnonymousUser'

This is tracked in https://openedx.atlassian.net/browse/REV-988
[REV-988]
2019-10-10 10:53:26 -04:00
Feanil Patel
3132982141 Fix datetime mock to only mock the now function. 2019-10-01 16:17:45 -04:00
Emma Green
4783aed927 Enterprise users should not get the first purchase discount. 2019-09-23 14:30:38 -04:00
Emma Green
502c8b5bf5 use the specified user from the parameter to determine if the flag is enabled, rather than the request's user 2019-09-19 15:51:57 -04:00
Emma Green
ef71b51137 Merge pull request #21399 from edx/emma-green/REV-901/remove-user-join-from-holdback
remove user.joined_date from holdback as this condition will create a…
2019-08-21 12:22:53 -04:00
Emma Green
fc003c428d remove user.joined_date from holdback as this condition will create a difference in the two a/b groups 2019-08-21 11:56:37 -04:00
Emma Green
48c17803c2 add endpoint that takes a user id to allow us to correctly get the discount after checkout to correctly create order 2019-08-16 10:55:39 -04:00
Ayub
044dc5f10a Merge pull request #21038 from edx/INCR-384
INCR-384 python 3 compatibility
2019-07-22 14:24:00 +05:00
Ayub khan
33227b8a72 INCR-384 python 3 compatibility 2019-07-10 16:31:18 +05:00
arbisoft
fe86f4e45a Fixing python-modernize issues. 2019-07-10 15:30:23 +05:00
Calen Pennington
708118f9c0 Enable holdback in first purchase discounts 2019-07-03 15:23:34 -04:00
Calen Pennington
8b4b5a4547 Move stable_bucketing into its own library to minimize circular dependencies 2019-07-03 15:03:31 -04:00
Calen Pennington
ce058aa5ee Only allow users who have no entitlements to receive discounts 2019-06-25 12:04:59 -04:00
Calen Pennington
ac9ba2b95a Only make users who haven't previously enrolled in a non-upsellable course eligible for the discount 2019-06-25 12:04:59 -04:00
Calen Pennington
2901d5f810 Centralize the strike-out price formatting to make correct accessibility easier 2019-06-18 11:00:08 -04:00
Matthew Piatetsky
8f2d7cfc8a switch enabled to disabled 2019-06-03 14:02:04 -04:00
Matthew Piatetsky
b32ed9ff2b add discount restriction stacked config models 2019-06-02 18:21:31 -04:00
emma-green
8615b1b0ac Merge pull request #20661 from edx/emma-green/REVEM-355/add-arch-decision
add arch decision of computation of course-user discount
2019-05-29 12:08:21 -04:00
Emma Green
95c15495dd add arch decision of computation of course-user discount 2019-05-29 10:21:46 -04:00
Matthew Piatetsky
93300a2e0e check course end date and verified mode for first purchase offer 2019-05-21 08:34:07 -04:00
Emma Green
7bcce26f85 spell receive correctly when discounting 2019-05-15 09:54:20 -04:00
Emma Green
7ae68aa383 add applicability endpoint 2019-05-10 09:11:54 -04:00