Updated to python3
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
This file defines any decorators used by the shopping cart app
|
This file defines any decorators used by the shopping cart app
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
|
|
||||||
from .utils import is_shopping_cart_enabled
|
from .utils import is_shopping_cart_enabled
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
""" Objects and functions related to generating CSV reports """
|
""" Objects and functions related to generating CSV reports """
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
import unicodecsv
|
import unicodecsv
|
||||||
@@ -159,7 +161,7 @@ class CertificateStatusReport(Report):
|
|||||||
cur_course = get_course_by_id(course_id)
|
cur_course = get_course_by_id(course_id)
|
||||||
university = cur_course.org
|
university = cur_course.org
|
||||||
# TODO add term (i.e. Fall 2013) to course?
|
# TODO add term (i.e. Fall 2013) to course?
|
||||||
course = cur_course.number + " " + cur_course.display_name_with_default_escaped
|
course = cur_course.number + " " + cur_course.display_name_with_default
|
||||||
counts = CourseEnrollment.objects.enrollment_counts(course_id)
|
counts = CourseEnrollment.objects.enrollment_counts(course_id)
|
||||||
total_enrolled = counts['total']
|
total_enrolled = counts['total']
|
||||||
audit_enrolled = counts['audit']
|
audit_enrolled = counts['audit']
|
||||||
@@ -239,7 +241,7 @@ class UniversityRevenueShareReport(Report):
|
|||||||
for course_id in course_ids_between(self.start_word, self.end_word):
|
for course_id in course_ids_between(self.start_word, self.end_word):
|
||||||
cur_course = get_course_by_id(course_id)
|
cur_course = get_course_by_id(course_id)
|
||||||
university = cur_course.org
|
university = cur_course.org
|
||||||
course = cur_course.number + " " + cur_course.display_name_with_default_escaped
|
course = cur_course.number + " " + cur_course.display_name_with_default
|
||||||
total_payments_collected = CertificateItem.verified_certificates_monetary_field_sum(course_id, 'purchased', 'unit_cost')
|
total_payments_collected = CertificateItem.verified_certificates_monetary_field_sum(course_id, 'purchased', 'unit_cost')
|
||||||
service_fees = CertificateItem.verified_certificates_monetary_field_sum(course_id, 'purchased', 'service_fee')
|
service_fees = CertificateItem.verified_certificates_monetary_field_sum(course_id, 'purchased', 'service_fee')
|
||||||
num_refunds = CertificateItem.verified_certificates_count(course_id, "refunded")
|
num_refunds = CertificateItem.verified_certificates_count(course_id, "refunded")
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
|
"""This module contains views related to shopping cart"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import decimal
|
import decimal
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
|
import six
|
||||||
from config_models.decorators import require_config
|
from config_models.decorators import require_config
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.urls import reverse
|
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.http import (
|
from django.http import (
|
||||||
Http404,
|
Http404,
|
||||||
@@ -19,6 +23,7 @@ from django.http import (
|
|||||||
HttpResponseRedirect
|
HttpResponseRedirect
|
||||||
)
|
)
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.views.decorators.http import require_http_methods, require_POST
|
from django.views.decorators.http import require_http_methods, require_POST
|
||||||
@@ -39,9 +44,9 @@ from shoppingcart.reports import (
|
|||||||
UniversityRevenueShareReport
|
UniversityRevenueShareReport
|
||||||
)
|
)
|
||||||
from student.models import AlreadyEnrolledError, CourseEnrollment, CourseFullError, EnrollmentClosedError
|
from student.models import AlreadyEnrolledError, CourseEnrollment, CourseFullError, EnrollmentClosedError
|
||||||
from util.request_rate_limiter import BadRequestRateLimiter
|
|
||||||
from util.date_utils import get_default_time_display
|
from util.date_utils import get_default_time_display
|
||||||
from util.json_request import JsonResponse
|
from util.json_request import JsonResponse
|
||||||
|
from util.request_rate_limiter import BadRequestRateLimiter
|
||||||
|
|
||||||
from .decorators import enforce_shopping_cart_enabled
|
from .decorators import enforce_shopping_cart_enabled
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
@@ -105,7 +110,7 @@ def add_course_to_cart(request, course_id):
|
|||||||
heavy lifting (logging, error checking, etc)
|
heavy lifting (logging, error checking, etc)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert isinstance(course_id, basestring)
|
assert isinstance(course_id, six.string_types)
|
||||||
if not request.user.is_authenticated:
|
if not request.user.is_authenticated:
|
||||||
log.info(u"Anon user trying to add course %s to cart", course_id)
|
log.info(u"Anon user trying to add course %s to cart", course_id)
|
||||||
return HttpResponseForbidden(_('You must be logged-in to add to a shopping cart'))
|
return HttpResponseForbidden(_('You must be logged-in to add to a shopping cart'))
|
||||||
@@ -605,7 +610,7 @@ def donate(request):
|
|||||||
amount,
|
amount,
|
||||||
course_id
|
course_id
|
||||||
)
|
)
|
||||||
return HttpResponseBadRequest(unicode(ex))
|
return HttpResponseBadRequest(six.text_type(ex))
|
||||||
|
|
||||||
# Start the purchase.
|
# Start the purchase.
|
||||||
# This will "lock" the purchase so the user can't change
|
# This will "lock" the purchase so the user can't change
|
||||||
@@ -621,7 +626,7 @@ def donate(request):
|
|||||||
|
|
||||||
# Add extra to make it easier to track transactions
|
# Add extra to make it easier to track transactions
|
||||||
extra_data = [
|
extra_data = [
|
||||||
unicode(course_id) if course_id else "",
|
six.text_type(course_id) if course_id else "",
|
||||||
"donation_course" if course_id else "donation_general"
|
"donation_course" if course_id else "donation_general"
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -669,7 +674,7 @@ def _get_verify_flow_redirect(order):
|
|||||||
course_id = cert_items[0].course_id
|
course_id = cert_items[0].course_id
|
||||||
url = reverse(
|
url = reverse(
|
||||||
'verify_student_payment_confirmation',
|
'verify_student_payment_confirmation',
|
||||||
kwargs={'course_id': unicode(course_id)}
|
kwargs={'course_id': six.text_type(course_id)}
|
||||||
)
|
)
|
||||||
# Add a query string param for the order ID
|
# Add a query string param for the order ID
|
||||||
# This allows the view to query for the receipt information later.
|
# This allows the view to query for the receipt information later.
|
||||||
@@ -877,7 +882,7 @@ def _show_receipt_json(order):
|
|||||||
'unit_cost': item.unit_cost,
|
'unit_cost': item.unit_cost,
|
||||||
'line_cost': item.line_cost,
|
'line_cost': item.line_cost,
|
||||||
'line_desc': item.line_desc,
|
'line_desc': item.line_desc,
|
||||||
'course_key': unicode(item.course_id)
|
'course_key': six.text_type(item.course_id)
|
||||||
}
|
}
|
||||||
for item in OrderItem.objects.filter(order=order).select_subclasses()
|
for item in OrderItem.objects.filter(order=order).select_subclasses()
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user