Commit 4d5a4b03 by Awais

ECOM-1683 removing regen-cert code.

parent 0d961d5c
...@@ -262,16 +262,7 @@ class XQueueCertInterface(object): ...@@ -262,16 +262,7 @@ class XQueueCertInterface(object):
if forced_grade: if forced_grade:
grade['grade'] = forced_grade grade['grade'] = forced_grade
cert, created = GeneratedCertificate.objects.get_or_create(user=student, course_id=course_id) cert, __ = GeneratedCertificate.objects.get_or_create(user=student, course_id=course_id)
if not created:
LOGGER.info(
u"Regenerate certificate for user %s in course %s "
u"with status %s, download_uuid %s, "
u"and download_url %s",
cert.user.id, unicode(cert.course_id),
cert.status, cert.download_uuid, cert.download_url
)
cert.mode = cert_mode cert.mode = cert_mode
cert.user = student cert.user = student
......
...@@ -1042,8 +1042,9 @@ class GenerateUserCertTests(ModuleStoreTestCase): ...@@ -1042,8 +1042,9 @@ class GenerateUserCertTests(ModuleStoreTestCase):
@patch('courseware.grades.grade', Mock(return_value={'grade': 'Pass', 'percent': 0.75})) @patch('courseware.grades.grade', Mock(return_value={'grade': 'Pass', 'percent': 0.75}))
@override_settings(CERT_QUEUE='certificates', SEGMENT_IO_LMS_KEY="foobar", FEATURES={'SEGMENT_IO_LMS': True}) @override_settings(CERT_QUEUE='certificates', SEGMENT_IO_LMS_KEY="foobar", FEATURES={'SEGMENT_IO_LMS': True})
def test_user_with_passing_existing_downloadable_cert(self): def test_user_with_passing_existing_downloadable_cert(self):
# If user has already downloadable certificate then he can again re-generate the # If user has already downloadable certificate
# the cert. # then json will return cert generating message with bad request code
GeneratedCertificateFactory.create( GeneratedCertificateFactory.create(
user=self.student, user=self.student,
course_id=self.course.id, course_id=self.course.id,
...@@ -1051,30 +1052,9 @@ class GenerateUserCertTests(ModuleStoreTestCase): ...@@ -1051,30 +1052,9 @@ class GenerateUserCertTests(ModuleStoreTestCase):
mode='verified' mode='verified'
) )
analytics_patcher = patch('courseware.views.analytics') resp = self.client.post(self.url)
mock_tracker = analytics_patcher.start() self.assertEqual(resp.status_code, HttpResponseBadRequest.status_code)
self.addCleanup(analytics_patcher.stop) self.assertIn("Certificate has already been created.", resp.content)
with patch('capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_send_to_queue:
mock_send_to_queue.return_value = (0, "Successfully queued")
resp = self.client.post(self.url)
self.assertEqual(resp.status_code, 200)
#Verify Google Analytics event fired after generating certificate
mock_tracker.track.assert_called_once_with( # pylint: disable=no-member
self.student.id, # pylint: disable=no-member
'edx.bi.user.certificate.generate',
{
'category': 'certificates',
'label': unicode(self.course.id)
},
context={
'Google Analytics':
{'clientId': None}
}
)
mock_tracker.reset_mock()
def test_user_with_non_existing_course(self): def test_user_with_non_existing_course(self):
# If try to access a course with valid key pattern then it will return # If try to access a course with valid key pattern then it will return
......
...@@ -1349,7 +1349,9 @@ def generate_user_cert(request, course_id): ...@@ -1349,7 +1349,9 @@ def generate_user_cert(request, course_id):
certificate_status = certs_api.certificate_downloadable_status(student, course.id) certificate_status = certs_api.certificate_downloadable_status(student, course.id)
if certificate_status["is_generating"]: if certificate_status["is_downloadable"]:
return HttpResponseBadRequest(_("Certificate has already been created."))
elif certificate_status["is_generating"]:
return HttpResponseBadRequest(_("Certificate is being created.")) return HttpResponseBadRequest(_("Certificate is being created."))
else: else:
# If the certificate is not already in-process or completed, # If the certificate is not already in-process or completed,
......
...@@ -51,53 +51,50 @@ from django.utils.http import urlquote_plus ...@@ -51,53 +51,50 @@ from django.utils.http import urlquote_plus
<div class="wrapper-msg wrapper-auto-cert"> <div class="wrapper-msg wrapper-auto-cert">
<div id="errors-info" class="errors-info"></div> <div id="errors-info" class="errors-info"></div>
<div class="auto-cert-message" id="course-success">
<div class="has-actions">
%if passed: %if passed:
<div class="auto-cert-message" id="course-success">
% if is_downloadable and download_url: <div class="has-actions">
% if is_downloadable and download_url:
<% post_url = reverse('generate_user_cert', args=[unicode(course.id)]) %>
<div class="msg-content"> <div class="msg-content">
<h2 class="title">${_("Your certificate is available")}</h2> <h2 class="title">${_("Your certificate is available")}</h2>
%if show_cert_web_view: %if show_cert_web_view:
<p class="copy">${_("You can now view your certificate.")}</p> <p class="copy">${_("You can now view your certificate.")}</p>
%else: %else:
<p class="copy">${_( <p class="copy">${_(
"You can now download your certificate as a PDF. If you keep working and receive a higher grade,you can request an {link_start} updated certificate {link_end}.").format( "You can now download your certificate as a PDF. If you keep working and receive a higher grade, you can request an updated certificate.")}
link_start=u"<a class='generate_certs' href='#' data-endpoint={}>".format(post_url) ,link_end=u"</a>")} </p>
</p> %endif
%endif </div>
</div> <div class="msg-actions">
<div class="msg-actions"> %if show_cert_web_view:
%if show_cert_web_view: <a class="btn" href="${cert_web_view_url}" target="_blank" title="${_('View certificate in a new browser window or tab.')}">
<a class="btn" href="${cert_web_view_url}" target="_blank" title="${_('View certificate in a new browser window or tab.')}"> ${_("View Certificate")}
${_("View Certificate")} </a>
</a> %else:
<a class="btn" href="${download_url}" target="_blank" title="${_('PDF will open in a new browser window or tab.')}">
${_("Download Your Certificate")}
</a>
%endif
</div>
%elif is_generating:
<div class="msg-content">
<h2 class="title">${_("We're working on it...")}</h2>
<p class="copy">${_("We're creating your certificate. You can keep working in your courses and a link to it will appear here and on your Dashboard when it is ready.")}</p>
</div>
<div class="msg-actions"></div>
%else: %else:
<a class="btn" href="${download_url}" target="_blank" title="${_('PDF will open in a new browser window or tab.')}"> <div class="msg-content">
${_("Download Your Certificate")} <h2 class="title">${_("Congratulations, you qualified for a certificate!")}</h2>
</a> <p class="copy">${_("You can keep working for a higher grade, or request your certificate now.")}</p>
</div>
<div class="msg-actions">
<button class="btn generate_certs" data-endpoint="${reverse('generate_user_cert', args=[unicode(course.id)])}" id="btn_generate_cert">${_('Request Certificate')}</button>
</div>
%endif %endif
</div> </div>
%elif is_generating: </div>
<div class="msg-content">
<h2 class="title">${_("We're working on it...")}</h2>
<p class="copy">${_("We're creating your certificate. You can keep working in your courses and a link to it will appear here and on your Dashboard when it is ready.")}</p>
</div>
<div class="msg-actions"></div>
%else:
<div class="msg-content">
<h2 class="title">${_("Congratulations, you qualified for a certificate!")}</h2>
<p class="copy">${_("You can keep working for a higher grade, or request your certificate now.")}</p>
</div>
<div class="msg-actions">
<button class="btn generate_certs" data-endpoint="${reverse('generate_user_cert', args=[unicode(course.id)])}" id="btn_generate_cert">${_('Request Certificate')}</button>
</div>
%endif
</div>
%endif %endif
</div>
</div> </div>
%endif %endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment