-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Aamir khan/ecom 528 donation verified courses #6521
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
Merged
aamir-khan
merged 11 commits into
master
from
aamir-khan/ECOM-528-donation-verified-courses
Jan 12, 2015
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
99659ce
ECOM-528 added donation support for verified courses
7bdbf8f
ECOM-528 added donation support for verified courses
7eb8195
ECOM-528 added donation support for verified courses
866ddc2
ECOM-528 refactor the code.
awais786 507d7b1
ECOM-528 refactor the code.
awais786 fd76f37
ECOM-528 added test cases
36626a2
ECOM-528 added test cases
d244b13
Merge remote-tracking branch 'origin/aamir-khan/ECOM-528-donation-ver…
4dfabe9
ECOM-528 removed the commented code in test cases
50961fe
ECOM-528 code refactoring
62ea486
ECOM-528 updated the test cases
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -712,9 +712,9 @@ def _create_recent_enrollment_message(course_enrollment_pairs, course_modes): | |
| { | ||
| "course_id": course.id, | ||
| "course_name": course.display_name, | ||
| "allow_donation": _allow_donation(course_modes, course.id) | ||
| "allow_donation": _allow_donation(course_modes, course.id, enrollment) | ||
| } | ||
| for course in recently_enrolled_courses | ||
| for course, enrollment in recently_enrolled_courses | ||
| ] | ||
|
|
||
| return render_to_string( | ||
|
|
@@ -738,30 +738,29 @@ def _get_recently_enrolled_courses(course_enrollment_pairs): | |
| seconds = DashboardConfiguration.current().recent_enrollment_time_delta | ||
| time_delta = (datetime.datetime.now(UTC) - datetime.timedelta(seconds=seconds)) | ||
| return [ | ||
| course for course, enrollment in course_enrollment_pairs | ||
| (course, enrollment) for course, enrollment in course_enrollment_pairs | ||
| # If the enrollment has no created date, we are explicitly excluding the course | ||
| # from the list of recent enrollments. | ||
| if enrollment.is_active and enrollment.created > time_delta | ||
| ] | ||
|
|
||
|
|
||
| def _allow_donation(course_modes, course_id): | ||
| def _allow_donation(course_modes, course_id, enrollment): | ||
| """Determines if the dashboard will request donations for the given course. | ||
|
|
||
| Check if donations are configured for the platform, and if the current course is accepting donations. | ||
|
|
||
| Args: | ||
| course_modes (dict): Mapping of course ID's to course mode dictionaries. | ||
| course_id (str): The unique identifier for the course. | ||
| enrollment(CourseEnrollment): The enrollment object in which the user is enrolled | ||
|
|
||
| Returns: | ||
| True if the course is allowing donations. | ||
|
|
||
| """ | ||
| donations_enabled = DonationConfiguration.current().enabled | ||
| is_verified_mode = CourseMode.has_verified_mode(course_modes[course_id]) | ||
| has_payment_option = CourseMode.has_payment_options(course_id) | ||
| return donations_enabled and not is_verified_mode and not has_payment_option | ||
| return donations_enabled and enrollment.mode in course_modes[course_id] and course_modes[course_id][enrollment.mode].min_price == 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these class methods aren't being used anywhere else, you can delete them from the |
||
|
|
||
|
|
||
| def try_change_enrollment(request): | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nitpick: please add a space between "#" and "Register" in each of these comments.
Also, we use "register" to mean "a user has created an account". This is different from "enroll", which means, "a user has enrolled in a course". So I think these comments should say "enroll" instead of "register".