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

Updated files to integrate authorizenet notifications #281

Open
wants to merge 2 commits into
base: open-release/lilac.master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions common/djangoapps/student/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import datetime
import logging
import base64
from collections import defaultdict

from django.conf import settings
Expand Down Expand Up @@ -34,6 +35,7 @@
get_pseudo_session_for_entitlement,
get_visible_sessions_for_entitlement
)
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.credit.email_utils import get_credit_provider_attribute_values, make_providers_strings
from openedx.core.djangoapps.plugins.constants import ProjectType
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
Expand Down Expand Up @@ -490,6 +492,7 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
The dashboard response.

"""
ECOMMERCE_TRANSACTION_COOKIE_NAME = "pendingTransactionCourse"

Choose a reason for hiding this comment

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

can we pleas move this constant to settings files (common and production).

user = request.user
if not UserProfile.objects.filter(user=user).exists():
return redirect(reverse('account_settings'))
Expand Down Expand Up @@ -740,7 +743,7 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
course_enrollments = [
enr for enr in course_enrollments if entitlement.enrollment_course_run.course_id != enr.course_id
]

context = {
'urls': urls,
'programs_data': programs_data,
Expand Down Expand Up @@ -810,6 +813,18 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
user,
)
)

# Retrieve pendingTransactionCourse cookie to show waiting alert to the learner. It conatain encrypted
# course_id for which AuthorizeNet transaction has been perfromed but notification is yet to be received.
transaction_hash = request.COOKIES.get(ECOMMERCE_TRANSACTION_COOKIE_NAME)
if transaction_hash:
decoded_course_id = base64.b64decode(transaction_hash[2:-1]).decode("utf-8")
transaction_course_id = CourseKey.from_string(decoded_course_id)
pending_transaction_course_name = CourseOverview.get_from_id(transaction_course_id).display_name
context.update({
'pending_upgrade_course_name': pending_transaction_course_name,
})

if ecommerce_service.is_enabled(request.user):
context.update({
'use_ecommerce_payment_flow': True,
Expand All @@ -826,4 +841,9 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
'resume_button_urls': resume_button_urls
})

return render_to_response('dashboard.html', context)
response = render_to_response('dashboard.html', context)
if transaction_hash:
response.delete_cookie(
ECOMMERCE_TRANSACTION_COOKIE_NAME, domain='localhost')

Choose a reason for hiding this comment

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

remove hard coded domain name.


return response
1 change: 1 addition & 0 deletions lms/static/sass/multicourse/_dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,7 @@ a.fade-cover {
width: flex-grid(12);
}

.course-upgrade,
.account-activation {
.message-copy {
position: relative;
Expand Down
8 changes: 8 additions & 0 deletions lms/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@
</div>
%endif

%if pending_upgrade_course_name:
<div class="course-upgrade aa-icon info" role="alert">
<div class="message-copy" >
Please wait for the confirmation email as your request is being processed. Course: ${ pending_upgrade_course_name } will be upgraded soon.
</div>
</div>
%endif

</div>

<main id="main" aria-label="Content" tabindex="-1">
Expand Down