Updated to python3
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
This file defines any decorators used by the shopping cart app
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.http import Http404
|
||||
|
||||
from .utils import is_shopping_cart_enabled
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
""" Objects and functions related to generating CSV reports """
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
import unicodecsv
|
||||
@@ -159,7 +161,7 @@ class CertificateStatusReport(Report):
|
||||
cur_course = get_course_by_id(course_id)
|
||||
university = cur_course.org
|
||||
# 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)
|
||||
total_enrolled = counts['total']
|
||||
audit_enrolled = counts['audit']
|
||||
@@ -239,7 +241,7 @@ class UniversityRevenueShareReport(Report):
|
||||
for course_id in course_ids_between(self.start_word, self.end_word):
|
||||
cur_course = get_course_by_id(course_id)
|
||||
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')
|
||||
service_fees = CertificateItem.verified_certificates_monetary_field_sum(course_id, 'purchased', 'service_fee')
|
||||
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 decimal
|
||||
import json
|
||||
import logging
|
||||
|
||||
import pytz
|
||||
import six
|
||||
from config_models.decorators import require_config
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import Group
|
||||
from django.urls import reverse
|
||||
from django.db.models import Q
|
||||
from django.http import (
|
||||
Http404,
|
||||
@@ -19,6 +23,7 @@ from django.http import (
|
||||
HttpResponseRedirect
|
||||
)
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.decorators.http import require_http_methods, require_POST
|
||||
@@ -39,9 +44,9 @@ from shoppingcart.reports import (
|
||||
UniversityRevenueShareReport
|
||||
)
|
||||
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.json_request import JsonResponse
|
||||
from util.request_rate_limiter import BadRequestRateLimiter
|
||||
|
||||
from .decorators import enforce_shopping_cart_enabled
|
||||
from .exceptions import (
|
||||
@@ -105,7 +110,7 @@ def add_course_to_cart(request, course_id):
|
||||
heavy lifting (logging, error checking, etc)
|
||||
"""
|
||||
|
||||
assert isinstance(course_id, basestring)
|
||||
assert isinstance(course_id, six.string_types)
|
||||
if not request.user.is_authenticated:
|
||||
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'))
|
||||
@@ -605,7 +610,7 @@ def donate(request):
|
||||
amount,
|
||||
course_id
|
||||
)
|
||||
return HttpResponseBadRequest(unicode(ex))
|
||||
return HttpResponseBadRequest(six.text_type(ex))
|
||||
|
||||
# Start the purchase.
|
||||
# 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
|
||||
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"
|
||||
]
|
||||
|
||||
@@ -669,7 +674,7 @@ def _get_verify_flow_redirect(order):
|
||||
course_id = cert_items[0].course_id
|
||||
url = reverse(
|
||||
'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
|
||||
# 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,
|
||||
'line_cost': item.line_cost,
|
||||
'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()
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user