Import Cleanups more logging

This PR is to add more logging when user clicks "Request Certificate" and gets error "Your certificate will be available when you pass the course."

EDUCATOR-1616
This commit is contained in:
Awais Jibran
2017-10-30 16:26:20 +05:00
parent 00d8b2a492
commit abe8b7e7b2

View File

@@ -5,12 +5,11 @@ import json
import logging
import urllib
from collections import OrderedDict, namedtuple
from datetime import datetime, timedelta
from datetime import datetime
import analytics
import shoppingcart
import survey.views
import waffle
from certificates import api as certs_api
from certificates.models import CertificateStatuses
from commerce.utils import EcommerceService
@@ -69,7 +68,6 @@ from markupsafe import escape
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey, UsageKey
from openedx.core.djangoapps.catalog.utils import get_programs, get_programs_with_type
from openedx.core.djangoapps.certificates import api as auto_certs_api
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.credit.api import (
get_credit_requirement_status,
@@ -1343,10 +1341,19 @@ def generate_user_cert(request, course_id):
return HttpResponseBadRequest(_("Course is not valid"))
if not is_course_passed(student, course):
log.info(u"User %s has not passed the course: %s", student.username, course_id)
return HttpResponseBadRequest(_("Your certificate will be available when you pass the course."))
certificate_status = certs_api.certificate_downloadable_status(student, course.id)
log.info(
u"User %s has requested for certificate in %s, current status: is_downloadable: %s, is_generating: %s",
student.username,
course_id,
certificate_status["is_downloadable"],
certificate_status["is_generating"],
)
if certificate_status["is_downloadable"]:
return HttpResponseBadRequest(_("Certificate has already been created."))
elif certificate_status["is_generating"]: