Commit Graph

42 Commits

Author SHA1 Message Date
Awais Qureshi
e40d259a09 BOM-2442
pyupgrade in course-search and discount.
2021-03-11 14:49:15 +05:00
Michael Terry
1482755bbd Show discount deadline in a timezone-aware way
Also, fix it and the access expiration deadline to not hardcode
the date presentation in an American way.
2021-01-08 13:56:18 -05:00
Carla Duarte
99163bdf2c AA-131: Allow anonymous users through course home MFE 2020-12-16 12:58:33 -05:00
Régis Behmo
a16cd71046 Start waffle namespace deprecation
By explicitly importing the legacy namespace classes, we make it clear
that we are using soon-to-be-deprecated classes. We will then be able to
start removing the legacy classes, one module at a time.
2020-12-03 16:06:14 +01:00
Kyle McCormick
151bd13666 Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
2020-11-10 07:02:01 -05:00
Manjinder Singh
c74b623948 Fixing code-annotations (#25539)
* Fixing code-annotations
2020-11-06 12:52:08 -05:00
Kyle McCormick
d1a775d3cd Use full names for lms.djangoapps imports (#25401)
* Use full LMS imports paths in LMS settings and urls modules
* Use full LMS import paths in Studio settings and urls modules
* Import from lms.djangoapps.badges instead of badges
* Import from lms.djangoapps.branding instead of branding
* Import from lms.djangoapps.bulk_email instead of bulk_email
* Import from lms.djangoapps.bulk_enroll instead of bulk_enroll
* Import from lms.djangoapps.ccx instead of ccx
* Import from lms.djangoapps.course_api instead of course_api
* Import from lms.djangoapps.course_blocks instead of course_blocks
* Import from lms.djangoapps.course_wiki instead of course_wiki
* Import from lms.djangoapps.courseware instead of courseware
* Import from lms.djangoapps.dashboard instead of dashboard
* Import from lms.djangoapps.discussion import discussion
* Import from lms.djangoapps.email_marketing instead of email_marketing
* Import from lms.djangoapps.experiments instead of experiments
* Import from lms.djangoapps.gating instead of gating
* Import from lms.djangoapps.grades instead of grades
* Import from lms.djangoapps.instructor_analytics instead of instructor_analytics
* Import form lms.djangoapps.lms_xblock instead of lms_xblock
* Import from lms.djangoapps.lti_provider instead of lti_provider
* Import from lms.djangoapps.mobile_api instead of mobile_api
* Import from lms.djangoapps.rss_proxy instead of rss_proxy
* Import from lms.djangoapps.static_template_view instead of static_template_view
* Import from lms.djangoapps.survey instead of survey
* Import from lms.djangoapps.verify_student instead of verify_student
* Stop suppressing EdxPlatformDeprecatedImportWarnings
2020-11-04 08:48:33 -05:00
Régis Behmo
4586002956 Import waffle classes from edx_toggles instead of waffle_utils
Those classes were ported to edx_toggles. The imports remain in
waffle_utils.__init__ for backward compatibility.
2020-11-03 19:25:37 +01:00
Régis Behmo
a4ba4ae45e Clarify many feature toggle annotations across all applications 2020-09-16 15:20:43 +02:00
Régis Behmo
0c3bc12582 Fix deprecated toggle annoation format 2020-09-16 15:16:13 +02:00
Régis Behmo
307457a255 Simplify hack to obtain waffle module names
Instead of going up the stacktrace to find the module names of waffle
flags and switches, we manually pass the module __name__ whenever the
flag is created. This is similar to `logging.getLogger(__name__)`
standard behaviour.

As the waffle classes are used outside of edx-platform, we make the new
module_name argument an optional keyword argument. This will change once
we pull waffle_utils outside of edx-platform.

Note that the module name is normally only required to view the list of
existing waffle flags and switches. The module name should not be
necessary to verify if a flag is enabled. Thus, maybe it would make
sense to create a `add` class methor similar to:

    class WaffleFlag:
        @classmethod
        def add(cls, namespace, flag, module):
            instance = cls(namespace, flag)
            cls._class_instances.add((instance, module))
2020-09-14 09:30:24 +02:00
Aarif
09ac7f9372 remove cyclomatic complexity calculation for python code 2020-08-04 22:10:05 +05:00
Robert Raposa
77e490f057 ARCHBOM-1305: remove deprecated flag_undefined_default (#24426)
This is the final step in removing the deprecated
flag_undefined_default as explained by the following ADR:
https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/waffle_utils/docs/decisions/0001-refactor-waffle-flag-default.rst

Notes:

* All uses of flag_undefined_default=False were always
  supposed to have been no-ops.
* All uses of flag_undefined_default=True that are removed
  in this PR have been replaced by migrations in past PRs.
* The temporary metric temp_flag_default_used id no longer
  reporting any data.

ARCHBOM-1305
2020-07-09 09:31:31 -04:00
julianajlk
902f8646ea Update FPD holdback function call order (#24074)
REV-1153
2020-05-28 11:13:11 -04:00
julianajlk
565018bd2e Update FPD holdback to 10% for longitudinal analysis (#24037)
REV-1153
2020-05-26 13:16:40 -04:00
Matthew Piatetsky
be0f5b70e9 Remove holdback check to give first purchase discount to all eligible users
Not fully cleaning up the holdback code yet since the follow on first purchase discount tests may make use of it
REV-1119
2020-03-16 15:28:45 -04:00
Matthew Piatetsky
09e62afb99 Merge pull request #22598 from edx/REV-1061
[REV-1061] Set discount on order based on discount that was on basket
2020-01-01 22:53:01 -05:00
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
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
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
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
Ayub khan
33227b8a72 INCR-384 python 3 compatibility 2019-07-10 16:31:18 +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
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
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