Fix Certificates import and signals code
This commit is contained in:
@@ -1036,9 +1036,6 @@ INSTALLED_APPS = [
|
||||
# Country embargo support
|
||||
'openedx.core.djangoapps.embargo',
|
||||
|
||||
# Signals
|
||||
'openedx.core.djangoapps.signals.apps.SignalConfig',
|
||||
|
||||
# Course action state
|
||||
'course_action_state',
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.contrib.sites.models import Site
|
||||
from django.db import models
|
||||
from django.utils.timezone import now
|
||||
|
||||
from certificates.models import GeneratedCertificate
|
||||
from lms.djangoapps.certificates.models import GeneratedCertificate
|
||||
from model_utils.models import TimeStampedModel
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.utils.timezone import now
|
||||
|
||||
from certificates.models import CertificateStatuses # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.api import MODES
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory
|
||||
|
||||
@@ -19,7 +19,7 @@ from openedx.core.djangoapps.theming.helpers import (
|
||||
get_template_path,
|
||||
is_request_in_themed_site,
|
||||
)
|
||||
from certificates.api import get_asset_url_by_slug
|
||||
from lms.djangoapps.certificates.api import get_asset_url_by_slug
|
||||
from webpack_loader.templatetags.webpack_loader import render_bundle
|
||||
logger = logging.getLogger(__name__)
|
||||
%>
|
||||
|
||||
@@ -50,7 +50,7 @@ import dogstats_wrapper as dog_stats_api
|
||||
import lms.lib.comment_client as cc
|
||||
import request_cache
|
||||
from student.signals import UNENROLL_DONE, ENROLL_STATUS_CHANGE, ENROLLMENT_TRACK_UPDATED
|
||||
from certificates.models import GeneratedCertificate
|
||||
from lms.djangoapps.certificates.models import GeneratedCertificate
|
||||
from course_modes.models import CourseMode
|
||||
from courseware.models import (
|
||||
CourseDynamicUpgradeDeadlineConfiguration,
|
||||
|
||||
@@ -11,9 +11,9 @@ from django.test.utils import override_settings
|
||||
from mock import patch
|
||||
from pytz import UTC
|
||||
|
||||
from certificates.api import get_certificate_url # pylint: disable=import-error
|
||||
from certificates.models import CertificateStatuses # pylint: disable=import-error
|
||||
from certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.api import get_certificate_url # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
|
||||
from course_modes.models import CourseMode
|
||||
from student.models import LinkedInAddToProfileConfiguration
|
||||
from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
|
||||
@@ -16,8 +16,8 @@ from django.test.client import Client
|
||||
from django.test.utils import override_settings
|
||||
from mock import patch
|
||||
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from certificates.tests.factories import GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
# These imports refer to lms djangoapps.
|
||||
# Their testcases are only run under lms.
|
||||
from course_modes.tests.factories import CourseModeFactory
|
||||
|
||||
@@ -121,7 +121,10 @@ class TestStudentDashboardUnenrollments(SharedModuleStoreTestCase):
|
||||
|
||||
def test_cant_unenroll_status(self):
|
||||
""" Assert that the dashboard loads when cert_status does not allow for unenrollment"""
|
||||
with patch('certificates.models.certificate_status_for_student', return_value={'status': 'downloadable'}):
|
||||
with patch(
|
||||
'lms.djangoapps.certificates.models.certificate_status_for_student',
|
||||
return_value={'status': 'downloadable'},
|
||||
):
|
||||
response = self.client.get(reverse('dashboard'))
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
@@ -25,8 +25,8 @@ from six import text_type
|
||||
|
||||
import shoppingcart # pylint: disable=import-error
|
||||
from bulk_email.models import Optout # pylint: disable=import-error
|
||||
from certificates.models import CertificateStatuses # pylint: disable=import-error
|
||||
from certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
|
||||
from course_modes.models import CourseMode
|
||||
from course_modes.tests.factories import CourseModeFactory
|
||||
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification
|
||||
|
||||
@@ -56,8 +56,8 @@ import third_party_auth
|
||||
from third_party_auth.saml import SAP_SUCCESSFACTORS_SAML_KEY
|
||||
import track.views
|
||||
from bulk_email.models import BulkEmailFlag, Optout # pylint: disable=import-error
|
||||
from certificates.api import get_certificate_url, has_html_certificates_enabled # pylint: disable=import-error
|
||||
from certificates.models import ( # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.api import get_certificate_url, has_html_certificates_enabled # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.models import ( # pylint: disable=import-error
|
||||
CertificateStatuses,
|
||||
GeneratedCertificate,
|
||||
certificate_status_for_student
|
||||
|
||||
@@ -50,7 +50,7 @@ def completion_check(user):
|
||||
completed courses. This badge will not work if certificate generation isn't
|
||||
enabled and run.
|
||||
"""
|
||||
from certificates.models import CertificateStatuses
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses
|
||||
config = CourseEventBadgesConfiguration.current().completed_settings
|
||||
certificates = user.generatedcertificate_set.filter(status__in=CertificateStatuses.PASSED_STATUSES).count()
|
||||
award_badge(config, certificates, user)
|
||||
@@ -61,7 +61,7 @@ def course_group_check(user, course_key):
|
||||
"""
|
||||
Awards a badge if a user has completed every course in a defined set.
|
||||
"""
|
||||
from certificates.models import CertificateStatuses
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses
|
||||
config = CourseEventBadgesConfiguration.current().course_group_settings
|
||||
awards = []
|
||||
for slug, keys in config.items():
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.test.utils import override_settings
|
||||
from mock import patch
|
||||
|
||||
from badges.tests.factories import CourseEventBadgesConfigurationFactory, RandomBadgeClassFactory
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from student.models import CourseEnrollment
|
||||
from student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
|
||||
@@ -11,7 +11,7 @@ from django.db import migrations, models
|
||||
|
||||
def forwards(apps, schema_editor):
|
||||
"""
|
||||
Migrate the initial badge classes, assertions, and course image configurations from certificates.
|
||||
Migrate the initial badge classes, assertions, and course image configurations from lms.djangoapps.certificates.
|
||||
"""
|
||||
from django.core.files.base import ContentFile
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
@@ -20,7 +20,7 @@ from badges.models import (
|
||||
validate_badge_image
|
||||
)
|
||||
from badges.tests.factories import BadgeAssertionFactory, BadgeClassFactory, RandomBadgeClassFactory
|
||||
from certificates.tests.test_models import TEST_DATA_ROOT
|
||||
from lms.djangoapps.certificates.tests.test_models import TEST_DATA_ROOT
|
||||
from student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
@@ -8,7 +8,7 @@ from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationConfiguration,
|
||||
CertificateGenerationCourseSetting,
|
||||
CertificateHtmlViewConfiguration,
|
||||
|
||||
@@ -12,7 +12,7 @@ from django.db.models import Q
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from branding import api as branding_api
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationConfiguration,
|
||||
CertificateGenerationCourseSetting,
|
||||
CertificateInvalidation,
|
||||
@@ -23,7 +23,7 @@ from certificates.models import (
|
||||
GeneratedCertificate,
|
||||
certificate_status_for_student
|
||||
)
|
||||
from certificates.queue import XQueueCertInterface
|
||||
from lms.djangoapps.certificates.queue import XQueueCertInterface
|
||||
from eventtracking import tracker
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
|
||||
@@ -377,7 +377,7 @@ def example_certificates_status(course_key):
|
||||
|
||||
Example Usage:
|
||||
|
||||
>>> from certificates import api as certs_api
|
||||
>>> from lms.djangoapps.certificates import api as certs_api
|
||||
>>> certs_api.example_certificate_status(course_key)
|
||||
[
|
||||
{
|
||||
|
||||
@@ -10,8 +10,8 @@ from oauth2_provider import models as dot_models
|
||||
from rest_framework import status
|
||||
from rest_framework.test import APITestCase
|
||||
|
||||
from certificates.models import CertificateStatuses
|
||||
from certificates.tests.factories import GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
from course_modes.models import CourseMode
|
||||
from student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
|
||||
@@ -13,7 +13,7 @@ class CertificatesConfig(AppConfig):
|
||||
"""
|
||||
Application Configuration for Certificates.
|
||||
"""
|
||||
name = u'certificates'
|
||||
name = u'lms.djangoapps.certificates'
|
||||
|
||||
def ready(self):
|
||||
"""
|
||||
|
||||
@@ -10,7 +10,7 @@ from django.contrib.auth.models import User
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from certificates.models import CertificateWhitelist
|
||||
from lms.djangoapps.certificates.models import CertificateWhitelist
|
||||
|
||||
|
||||
def get_user_from_identifier(identifier):
|
||||
|
||||
@@ -16,7 +16,7 @@ from django.core.management.base import BaseCommand
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from six import text_type
|
||||
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from certificates.models import GeneratedCertificate
|
||||
from lms.djangoapps.certificates.models import GeneratedCertificate
|
||||
from courseware import courses
|
||||
from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from django.db.models import Count
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from six import text_type
|
||||
|
||||
from certificates.models import GeneratedCertificate
|
||||
from lms.djangoapps.certificates.models import GeneratedCertificate
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
@@ -9,7 +9,7 @@ from six import text_type
|
||||
|
||||
from badges.events.course_complete import get_completion_badge
|
||||
from badges.utils import badges_enabled
|
||||
from certificates.api import regenerate_user_certificates
|
||||
from lms.djangoapps.certificates.api import regenerate_user_certificates
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -23,8 +23,8 @@ from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from six import text_type
|
||||
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates import api as certs_api
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -12,8 +12,8 @@ from opaque_keys.edx.keys import CourseKey
|
||||
from pytz import UTC
|
||||
from six import text_type
|
||||
|
||||
from certificates.api import generate_user_certificates
|
||||
from certificates.models import CertificateStatuses, certificate_status_for_student
|
||||
from lms.djangoapps.certificates.api import generate_user_certificates
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, certificate_status_for_student
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import certificates.models
|
||||
import jsonfield.fields
|
||||
import model_utils.fields
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
from badges.models import validate_badge_image
|
||||
from django.conf import settings
|
||||
from lms.djangoapps.certificates import models as cert_models
|
||||
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ class Migration(migrations.Migration):
|
||||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
|
||||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
|
||||
('description', models.CharField(help_text='Description of the asset.', max_length=255, null=True, blank=True)),
|
||||
('asset', models.FileField(help_text='Asset file. It could be an image or css file.', max_length=255, upload_to=certificates.models.template_assets_path)),
|
||||
('asset', models.FileField(help_text='Asset file. It could be an image or css file.', max_length=255, upload_to=cert_models.template_assets_path)),
|
||||
],
|
||||
options={
|
||||
'get_latest_by': 'created',
|
||||
@@ -127,8 +127,8 @@ class Migration(migrations.Migration):
|
||||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
|
||||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
|
||||
('description', models.CharField(help_text="A human-readable description of the example certificate. For example, 'verified' or 'honor' to differentiate between two types of certificates.", max_length=255)),
|
||||
('uuid', models.CharField(default=certificates.models._make_uuid, help_text='A unique identifier for the example certificate. This is used when we receive a response from the queue to determine which example certificate was processed.', unique=True, max_length=255, db_index=True)),
|
||||
('access_key', models.CharField(default=certificates.models._make_uuid, help_text='An access key for the example certificate. This is used when we receive a response from the queue to validate that the sender is the same entity we asked to generate the certificate.', max_length=255, db_index=True)),
|
||||
('uuid', models.CharField(default=cert_models._make_uuid, help_text='A unique identifier for the example certificate. This is used when we receive a response from the queue to determine which example certificate was processed.', unique=True, max_length=255, db_index=True)),
|
||||
('access_key', models.CharField(default=cert_models._make_uuid, help_text='An access key for the example certificate. This is used when we receive a response from the queue to validate that the sender is the same entity we asked to generate the certificate.', max_length=255, db_index=True)),
|
||||
('full_name', models.CharField(default='John Do\xeb', help_text='The full name that will appear on the certificate.', max_length=255)),
|
||||
('template', models.CharField(help_text='The template file to use when generating the certificate.', max_length=255)),
|
||||
('status', models.CharField(default=b'started', help_text='The status of the example certificate.', max_length=255, choices=[(b'started', b'Started'), (b'success', b'Success'), (b'error', b'Error')])),
|
||||
|
||||
@@ -12,9 +12,8 @@ from lxml.etree import ParserError, XMLSyntaxError
|
||||
from requests.auth import HTTPBasicAuth
|
||||
|
||||
from capa.xqueue_interface import XQueueInterface, make_hashkey, make_xheader
|
||||
from certificates.models import CertificateStatuses as status
|
||||
from certificates.models import (
|
||||
CertificateStatuses,
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses as status
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateWhitelist,
|
||||
ExampleCertificate,
|
||||
GeneratedCertificate,
|
||||
@@ -356,7 +355,7 @@ class XQueueCertInterface(object):
|
||||
# existing audit certs as ineligible.
|
||||
cutoff = settings.AUDIT_CERT_CUTOFF_DATE
|
||||
if (cutoff and cert.created_date >= cutoff) and not is_eligible_for_certificate:
|
||||
cert.status = CertificateStatuses.audit_passing if passing else CertificateStatuses.audit_notpassing
|
||||
cert.status = status.audit_passing if passing else status.audit_notpassing
|
||||
cert.save()
|
||||
LOGGER.info(
|
||||
u"Student %s with enrollment mode %s is not eligible for a certificate.",
|
||||
|
||||
@@ -6,15 +6,17 @@ import logging
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationCourseSetting,
|
||||
CertificateWhitelist,
|
||||
GeneratedCertificate
|
||||
)
|
||||
from certificates.tasks import generate_certificate
|
||||
from lms.djangoapps.certificates.tasks import generate_certificate
|
||||
from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory
|
||||
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification
|
||||
from openedx.core.djangoapps.certificates.api import auto_certificate_generation_enabled
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.content.course_overviews.signals import COURSE_PACING_CHANGED
|
||||
from openedx.core.djangoapps.signals.signals import COURSE_GRADE_NOW_PASSED, LEARNER_NOW_VERIFIED
|
||||
from course_modes.models import CourseMode
|
||||
from student.models import CourseEnrollment
|
||||
@@ -24,6 +26,21 @@ log = logging.getLogger(__name__)
|
||||
CERTIFICATE_DELAY_SECONDS = 2
|
||||
|
||||
|
||||
@receiver(COURSE_PACING_CHANGED, dispatch_uid="update_cert_settings_on_pacing_change")
|
||||
def _update_cert_settings_on_pacing_change(sender, updated_course_overview, **kwargs): # pylint: disable=unused-argument
|
||||
"""
|
||||
Catches the signal that course pacing has changed and enable/disable
|
||||
the self-generated certificates according to course-pacing.
|
||||
"""
|
||||
CertificateGenerationCourseSetting.set_self_generatation_enabled_for_course(
|
||||
updated_course_overview.id,
|
||||
updated_course_overview.self_paced,
|
||||
)
|
||||
log.info(u'Certificate Generation Setting Toggled for {course_id} via pacing change'.format(
|
||||
course_id=updated_course_overview.id
|
||||
))
|
||||
|
||||
|
||||
@receiver(post_save, sender=CertificateWhitelist, dispatch_uid="append_certificate_whitelist")
|
||||
def _listen_for_certificate_whitelist_append(sender, instance, **kwargs): # pylint: disable=unused-argument
|
||||
course = CourseOverview.get_from_id(instance.course_id)
|
||||
|
||||
@@ -4,7 +4,7 @@ from uuid import uuid4
|
||||
|
||||
from factory.django import DjangoModelFactory
|
||||
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateHtmlViewConfiguration,
|
||||
CertificateInvalidation,
|
||||
CertificateStatuses,
|
||||
|
||||
@@ -18,16 +18,16 @@ from nose.plugins.attrib import attr
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
import pytz
|
||||
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates import api as certs_api
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationConfiguration,
|
||||
CertificateStatuses,
|
||||
ExampleCertificate,
|
||||
GeneratedCertificate,
|
||||
certificate_status_for_student
|
||||
)
|
||||
from certificates.queue import XQueueAddToQueueError, XQueueCertInterface
|
||||
from certificates.tests.factories import CertificateInvalidationFactory, GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.queue import XQueueAddToQueueError, XQueueCertInterface
|
||||
from lms.djangoapps.certificates.tests.factories import CertificateInvalidationFactory, GeneratedCertificateFactory
|
||||
from course_modes.models import CourseMode
|
||||
from course_modes.tests.factories import CourseModeFactory
|
||||
from courseware.tests.factories import GlobalStaffFactory
|
||||
@@ -504,7 +504,7 @@ class GenerateUserCertificatesTest(EventTestMixin, WebCertificateTestMixin, Modu
|
||||
ENABLED_SIGNALS = ['course_published']
|
||||
|
||||
def setUp(self): # pylint: disable=arguments-differ
|
||||
super(GenerateUserCertificatesTest, self).setUp('certificates.api.tracker')
|
||||
super(GenerateUserCertificatesTest, self).setUp('lms.djangoapps.certificates.api.tracker')
|
||||
|
||||
self.student = UserFactory.create(
|
||||
email='joe_user@edx.org',
|
||||
@@ -599,7 +599,7 @@ class CertificateGenerationEnabledTest(EventTestMixin, TestCase):
|
||||
COURSE_KEY = CourseLocator(org='test', course='test', run='test')
|
||||
|
||||
def setUp(self): # pylint: disable=arguments-differ
|
||||
super(CertificateGenerationEnabledTest, self).setUp('certificates.api.tracker')
|
||||
super(CertificateGenerationEnabledTest, self).setUp('lms.djangoapps.certificates.api.tracker')
|
||||
|
||||
# Since model-based configuration is cached, we need
|
||||
# to clear the cache before each test.
|
||||
@@ -753,7 +753,7 @@ class CertificatesBrandingTest(TestCase):
|
||||
@set_microsite(settings.MICROSITE_CONFIGURATION['test_site']['domain_prefix'])
|
||||
def test_certificate_header_data(self):
|
||||
"""
|
||||
Test that get_certificate_header_context from certificates api
|
||||
Test that get_certificate_header_context from lms.djangoapps.certificates api
|
||||
returns data customized according to site branding.
|
||||
"""
|
||||
# Generate certificates for the course
|
||||
@@ -778,7 +778,7 @@ class CertificatesBrandingTest(TestCase):
|
||||
@set_microsite(settings.MICROSITE_CONFIGURATION['test_site']['domain_prefix'])
|
||||
def test_certificate_footer_data(self):
|
||||
"""
|
||||
Test that get_certificate_footer_context from certificates api returns
|
||||
Test that get_certificate_footer_context from lms.djangoapps.certificates api returns
|
||||
data customized according to site branding.
|
||||
"""
|
||||
# Generate certificates for the course
|
||||
|
||||
@@ -12,7 +12,7 @@ from six import text_type
|
||||
from badges.events.course_complete import get_completion_badge
|
||||
from badges.models import BadgeAssertion
|
||||
from badges.tests.factories import BadgeAssertionFactory, CourseCompleteImageConfigurationFactory
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from course_modes.models import CourseMode
|
||||
from lms.djangoapps.grades.tests.utils import mock_passing_grade
|
||||
from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
@@ -168,7 +168,7 @@ class RegenerateCertificatesTest(CertificateManagementTest):
|
||||
@ddt.data(True, False)
|
||||
@override_settings(CERT_QUEUE='test-queue')
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_OPENBADGES': True})
|
||||
@patch('certificates.api.XQueueCertInterface', spec=True)
|
||||
@patch('lms.djangoapps.certificates.api.XQueueCertInterface', spec=True)
|
||||
def test_clear_badge(self, issue_badges, xqueue):
|
||||
"""
|
||||
Given that I have a user with a badge
|
||||
|
||||
@@ -7,7 +7,7 @@ from nose.plugins.attrib import attr
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from six import text_type
|
||||
|
||||
from certificates.models import GeneratedCertificate
|
||||
from lms.djangoapps.certificates.models import GeneratedCertificate
|
||||
from student.tests.factories import UserFactory
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from nose.plugins.attrib import attr
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from path import Path as path
|
||||
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationHistory,
|
||||
CertificateHtmlViewConfiguration,
|
||||
CertificateInvalidation,
|
||||
@@ -21,7 +21,7 @@ from certificates.models import (
|
||||
ExampleCertificateSet,
|
||||
GeneratedCertificate
|
||||
)
|
||||
from certificates.tests.factories import CertificateInvalidationFactory, GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.tests.factories import CertificateInvalidationFactory, GeneratedCertificateFactory
|
||||
from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
|
||||
from student.tests.factories import AdminFactory, UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
|
||||
@@ -19,9 +19,9 @@ from opaque_keys.edx.locator import CourseLocator
|
||||
# and verify that items are being correctly added to the queue
|
||||
# in our `XQueueCertInterface` implementation.
|
||||
from capa.xqueue_interface import XQueueInterface
|
||||
from certificates.models import CertificateStatuses, ExampleCertificate, ExampleCertificateSet, GeneratedCertificate
|
||||
from certificates.queue import XQueueCertInterface
|
||||
from certificates.tests.factories import CertificateWhitelistFactory, GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, ExampleCertificate, ExampleCertificateSet, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.queue import XQueueCertInterface
|
||||
from lms.djangoapps.certificates.tests.factories import CertificateWhitelistFactory, GeneratedCertificateFactory
|
||||
from course_modes.models import CourseMode
|
||||
from lms.djangoapps.grades.tests.utils import mock_passing_grade
|
||||
from lms.djangoapps.verify_student.tests.factories import SoftwareSecurePhotoVerificationFactory
|
||||
@@ -196,7 +196,10 @@ class XQueueCertInterfaceAddCertificateTest(ModuleStoreTestCase):
|
||||
Test that certificates can or cannot be generated with the given
|
||||
certificate status.
|
||||
"""
|
||||
with patch('certificates.queue.certificate_status_for_student', Mock(return_value={'status': status})):
|
||||
with patch(
|
||||
'lms.djangoapps.certificates.queue.certificate_status_for_student',
|
||||
Mock(return_value={'status': status})
|
||||
):
|
||||
mock_send = self.add_cert_to_queue('verified')
|
||||
if should_generate:
|
||||
self.assertTrue(mock_send.called)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
Unit Tests for the Certificate service
|
||||
"""
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from certificates.services import CertificateService
|
||||
from certificates.tests.factories import GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.services import CertificateService
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
from student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
@@ -5,19 +5,18 @@ and disabling for instructor-paced courses.
|
||||
import ddt
|
||||
import mock
|
||||
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates import api as certs_api
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationConfiguration,
|
||||
CertificateWhitelist,
|
||||
GeneratedCertificate,
|
||||
CertificateStatuses,
|
||||
)
|
||||
from certificates.signals import fire_ungenerated_certificate_task
|
||||
from lms.djangoapps.certificates.signals import fire_ungenerated_certificate_task, CERTIFICATE_DELAY_SECONDS
|
||||
from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory
|
||||
from lms.djangoapps.grades.tests.utils import mock_passing_grade
|
||||
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification
|
||||
from openedx.core.djangoapps.certificates.config import waffle
|
||||
from lms.djangoapps.certificates.signals import CERTIFICATE_DELAY_SECONDS
|
||||
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
|
||||
from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
|
||||
@@ -10,8 +10,8 @@ from django.core.urlresolvers import reverse
|
||||
from django.test.utils import override_settings
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from certificates.models import CertificateInvalidation, CertificateStatuses, GeneratedCertificate
|
||||
from certificates.tests.factories import CertificateInvalidationFactory
|
||||
from lms.djangoapps.certificates.models import CertificateInvalidation, CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.tests.factories import CertificateInvalidationFactory
|
||||
from student.models import CourseEnrollment
|
||||
from student.roles import GlobalStaff, SupportStaffRole
|
||||
from student.tests.factories import UserFactory
|
||||
|
||||
@@ -13,8 +13,8 @@ from django.test.utils import override_settings
|
||||
from nose.plugins.attrib import attr
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
|
||||
from certificates.api import get_certificate_url
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.api import get_certificate_url
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateHtmlViewConfiguration,
|
||||
ExampleCertificate,
|
||||
ExampleCertificateSet,
|
||||
|
||||
@@ -14,8 +14,8 @@ from django.test.utils import override_settings
|
||||
from mock import patch
|
||||
|
||||
import ddt
|
||||
from certificates.api import get_certificate_url
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.api import get_certificate_url
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationCourseSetting,
|
||||
CertificateHtmlViewConfiguration,
|
||||
CertificateSocialNetworks,
|
||||
@@ -24,7 +24,7 @@ from certificates.models import (
|
||||
CertificateTemplateAsset,
|
||||
GeneratedCertificate
|
||||
)
|
||||
from certificates.tests.factories import (
|
||||
from lms.djangoapps.certificates.tests.factories import (
|
||||
CertificateHtmlViewConfigurationFactory,
|
||||
GeneratedCertificateFactory,
|
||||
LinkedInAddToProfileConfigurationFactory
|
||||
@@ -423,7 +423,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
self.assertIn('logo_test1.png', response.content)
|
||||
|
||||
@ddt.data(True, False)
|
||||
@patch('certificates.views.webview.get_completion_badge')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_completion_badge')
|
||||
@override_settings(FEATURES=FEATURES_WITH_BADGES_ENABLED)
|
||||
def test_fetch_badge_info(self, issue_badges, mock_get_completion_badge):
|
||||
"""
|
||||
@@ -986,7 +986,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
#TEMPLATES WITHOUT LANGUAGE TESTS
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@override_settings(LANGUAGE_CODE='fr')
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
def test_certificate_custom_template_with_org_mode_and_course_key(self, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template search and rendering.
|
||||
@@ -1002,7 +1002,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
course_id=unicode(self.course.id)
|
||||
)
|
||||
|
||||
with patch('certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
with patch('lms.djangoapps.certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
mock_get_org_id.side_effect = [1, 2]
|
||||
response = self.client.get(test_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@@ -1015,7 +1015,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
self.assertContains(response, 'course name: test_template_3_course')
|
||||
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
def test_certificate_custom_template_with_org_and_mode(self, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template search if no template matches course_key, but a template does
|
||||
@@ -1042,14 +1042,14 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
course_id=unicode(self.course.id)
|
||||
)
|
||||
|
||||
with patch('certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
with patch('lms.djangoapps.certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
mock_get_org_id.side_effect = [1]
|
||||
response = self.client.get(test_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, 'course name: test_template_1_course')
|
||||
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
def test_certificate_custom_template_with_org(self, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template search when we have a single template for a organization.
|
||||
@@ -1065,14 +1065,14 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
course_id=unicode(self.course.id)
|
||||
)
|
||||
|
||||
with patch('certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
with patch('lms.djangoapps.certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
mock_get_org_id.side_effect = [1]
|
||||
response = self.client.get(test_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, 'course name: test_template_1_course')
|
||||
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
def test_certificate_custom_template_with_mode(self, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template search if we have a single template for a course mode.
|
||||
@@ -1089,7 +1089,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
course_id=unicode(self.course.id)
|
||||
)
|
||||
|
||||
with patch('certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
with patch('lms.djangoapps.certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
mock_get_org_id.return_value = None
|
||||
response = self.client.get(test_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@@ -1100,8 +1100,8 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
#1
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@override_settings(LANGUAGE_CODE='fr')
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('certificates.api.get_course_organization_id')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.api.get_course_organization_id')
|
||||
def test_certificate_custom_language_template_with_org_mode_and_course_key(self, mock_get_org_id, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template search and rendering.
|
||||
@@ -1159,8 +1159,8 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
|
||||
#2
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('certificates.api.get_course_organization_id')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.api.get_course_organization_id')
|
||||
def test_certificate_custom_language_template_with_org_and_mode(self, mock_get_org_id, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template search if no template matches course_key, but a template does
|
||||
@@ -1218,8 +1218,8 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
|
||||
#3
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('certificates.api.get_course_organization_id')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.api.get_course_organization_id')
|
||||
def test_certificate_custom_language_template_with_org(self, mock_get_org_id, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template search when we have a single template for a organization.
|
||||
@@ -1275,8 +1275,8 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
|
||||
#4
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('certificates.api.get_course_organization_id')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.api.get_course_organization_id')
|
||||
def test_certificate_custom_language_template_with_mode(self, mock_get_org_id, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template search if we have a single template for a course mode.
|
||||
@@ -1332,8 +1332,8 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
self.assertContains(response, 'course name: test_right_lang_template')
|
||||
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('certificates.api.get_course_organization_id')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.api.get_course_organization_id')
|
||||
def test_certificate_custom_language_template_with_locale_language_from_catalogue(self, mock_get_org_id, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template search if we have a single template for a course mode.
|
||||
@@ -1390,8 +1390,8 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@ddt.data(True, False)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('certificates.api.get_course_organization_id')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.api.get_course_organization_id')
|
||||
def test_certificate_custom_template_with_hours_of_effort(self, include_effort, mock_get_org_id, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template properly retrieves and calculates Hours of Effort when the feature is enabled
|
||||
@@ -1419,7 +1419,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
self.assertNotIn('hours of effort', response.content)
|
||||
|
||||
@ddt.data(True, False)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
def test_certificate_custom_template_with_unicode_data(self, custom_certs_enabled, mock_get_course_run_details):
|
||||
"""
|
||||
Tests custom template renders properly with unicode data.
|
||||
@@ -1442,7 +1442,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
}):
|
||||
with patch('django.http.HttpRequest.build_absolute_uri') as mock_abs_uri:
|
||||
mock_abs_uri.return_value = '='.join(['http://localhost/?param', u'é'])
|
||||
with patch('certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
with patch('lms.djangoapps.certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
mock_get_org_id.return_value = None
|
||||
response = self.client.get(test_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@@ -1453,7 +1453,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
self.assertContains(response, 'https://twitter.com/intent/tweet')
|
||||
|
||||
@override_settings(FEATURES=FEATURES_WITH_CUSTOM_CERTS_ENABLED)
|
||||
@patch('certificates.views.webview.get_course_run_details')
|
||||
@patch('lms.djangoapps.certificates.views.webview.get_course_run_details')
|
||||
def test_certificate_asset_by_slug(self, mock_get_course_run_details):
|
||||
"""
|
||||
Tests certificate template asset display by slug using static.certificate_asset_url method.
|
||||
@@ -1467,7 +1467,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
)
|
||||
|
||||
# render certificate without template asset
|
||||
with patch('certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
with patch('lms.djangoapps.certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
mock_get_org_id.return_value = None
|
||||
response = self.client.get(test_url)
|
||||
self.assertContains(response, '<img class="custom-logo" src="" />')
|
||||
@@ -1480,7 +1480,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
|
||||
template_asset.save()
|
||||
|
||||
# render certificate with template asset
|
||||
with patch('certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
with patch('lms.djangoapps.certificates.api.get_course_organization_id') as mock_get_org_id:
|
||||
mock_get_org_id.return_value = None
|
||||
response = self.client.get(test_url)
|
||||
self.assertContains(
|
||||
|
||||
@@ -8,13 +8,13 @@ from mock import patch
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
from badges.tests.factories import CourseCompleteImageConfigurationFactory
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateStatuses,
|
||||
GeneratedCertificate,
|
||||
certificate_info_for_user,
|
||||
certificate_status_for_student
|
||||
)
|
||||
from certificates.tests.factories import GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from util.milestones_helpers import milestones_achieved_by_user, set_prerequisite_courses
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
|
||||
@@ -4,7 +4,7 @@ URLs for the certificates app.
|
||||
from django.conf import settings
|
||||
from django.conf.urls import url
|
||||
|
||||
from certificates import views
|
||||
from lms.djangoapps.certificates import views
|
||||
|
||||
urlpatterns = [
|
||||
# Certificates HTML view end point to render web certs by user and course
|
||||
|
||||
@@ -16,8 +16,8 @@ from django.views.decorators.http import require_GET, require_POST
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from certificates import api
|
||||
from certificates.models import CertificateInvalidation
|
||||
from lms.djangoapps.certificates import api
|
||||
from lms.djangoapps.certificates.models import CertificateInvalidation
|
||||
from courseware.access import has_access
|
||||
from lms.djangoapps.instructor_task.api import generate_certificates_for_students
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
|
||||
@@ -20,7 +20,7 @@ from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from badges.events.course_complete import get_completion_badge
|
||||
from badges.utils import badges_enabled
|
||||
from certificates.api import (
|
||||
from lms.djangoapps.certificates.api import (
|
||||
emit_certificate_event,
|
||||
get_active_web_certificate,
|
||||
get_certificate_footer_context,
|
||||
@@ -28,7 +28,7 @@ from certificates.api import (
|
||||
get_certificate_template,
|
||||
get_certificate_url
|
||||
)
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationCourseSetting,
|
||||
CertificateHtmlViewConfiguration,
|
||||
CertificateSocialNetworks,
|
||||
|
||||
@@ -13,8 +13,8 @@ from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
import dogstats_wrapper as dog_stats_api
|
||||
from capa.xqueue_interface import XQUEUE_METRIC_NAME
|
||||
from certificates.api import generate_user_certificates
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates.api import generate_user_certificates
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateStatuses,
|
||||
ExampleCertificate,
|
||||
GeneratedCertificate,
|
||||
|
||||
@@ -33,9 +33,6 @@ from xblock.fields import Scope, String
|
||||
import courseware.views.views as views
|
||||
import shoppingcart
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import CertificateGenerationConfiguration, CertificateStatuses, CertificateWhitelist
|
||||
from certificates.tests.factories import CertificateInvalidationFactory, GeneratedCertificateFactory
|
||||
from course_modes.models import CourseMode
|
||||
from course_modes.tests.factories import CourseModeFactory
|
||||
from courseware.access_utils import check_course_open_for_learner
|
||||
@@ -45,6 +42,11 @@ from courseware.tests.factories import GlobalStaffFactory, StudentModuleFactory
|
||||
from courseware.testutils import RenderXBlockTestMixin
|
||||
from courseware.url_helpers import get_redirect_url
|
||||
from courseware.user_state_client import DjangoXBlockUserStateClient
|
||||
from lms.djangoapps.certificates import api as certs_api
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationConfiguration, CertificateStatuses, CertificateWhitelist,
|
||||
)
|
||||
from lms.djangoapps.certificates.tests.factories import CertificateInvalidationFactory, GeneratedCertificateFactory
|
||||
from lms.djangoapps.commerce.models import CommerceConfiguration
|
||||
from lms.djangoapps.commerce.utils import EcommerceService # pylint: disable=import-error
|
||||
from lms.djangoapps.grades.config.waffle import waffle as grades_waffle
|
||||
@@ -1627,7 +1629,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
self.generate_certificate(
|
||||
"http://www.example.com/certificate.pdf", "honor"
|
||||
)
|
||||
with patch('certificates.api.certificate_downloadable_status',
|
||||
with patch('lms.djangoapps.certificates.api.certificate_downloadable_status',
|
||||
return_value=self.mock_certificate_downloadable_status(is_downloadable=True)):
|
||||
response = views._get_cert_data(self.user, self.course, CourseMode.HONOR, MagicMock(passed=True))
|
||||
|
||||
@@ -1641,7 +1643,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
self.generate_certificate(
|
||||
"http://www.example.com/certificate.pdf", "honor"
|
||||
)
|
||||
with patch('certificates.api.certificate_downloadable_status',
|
||||
with patch('lms.djangoapps.certificates.api.certificate_downloadable_status',
|
||||
return_value=self.mock_certificate_downloadable_status(is_generating=True)):
|
||||
response = views._get_cert_data(self.user, self.course, CourseMode.HONOR, MagicMock(passed=True))
|
||||
|
||||
@@ -1655,7 +1657,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
self.generate_certificate(
|
||||
"http://www.example.com/certificate.pdf", "honor"
|
||||
)
|
||||
with patch('certificates.api.certificate_downloadable_status',
|
||||
with patch('lms.djangoapps.certificates.api.certificate_downloadable_status',
|
||||
return_value=self.mock_certificate_downloadable_status(is_unverified=True)):
|
||||
response = views._get_cert_data(self.user, self.course, CourseMode.HONOR, MagicMock(passed=True))
|
||||
|
||||
@@ -1669,7 +1671,7 @@ class ProgressPageTests(ProgressPageBaseTests):
|
||||
self.generate_certificate(
|
||||
"http://www.example.com/certificate.pdf", "honor"
|
||||
)
|
||||
with patch('certificates.api.certificate_downloadable_status',
|
||||
with patch('lms.djangoapps.certificates.api.certificate_downloadable_status',
|
||||
return_value=self.mock_certificate_downloadable_status()):
|
||||
response = views._get_cert_data(self.user, self.course, CourseMode.HONOR, MagicMock(passed=True))
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ from web_fragments.fragment import Fragment
|
||||
|
||||
import shoppingcart
|
||||
import survey.views
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import CertificateStatuses
|
||||
from lms.djangoapps.certificates import api as certs_api
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses
|
||||
from course_modes.models import CourseMode, get_course_prices
|
||||
from courseware.access import has_access, has_ccx_coach_role
|
||||
from courseware.access_utils import check_course_open_for_learner
|
||||
|
||||
@@ -32,8 +32,8 @@ from six import text_type
|
||||
import lms.djangoapps.instructor.views.api
|
||||
import lms.djangoapps.instructor_task.api
|
||||
from bulk_email.models import BulkEmailFlag, CourseEmail, CourseEmailTemplate
|
||||
from certificates.models import CertificateStatuses
|
||||
from certificates.tests.factories import GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
from course_modes.models import CourseMode
|
||||
from course_modes.tests.factories import CourseModeFactory
|
||||
from courseware.models import StudentFieldOverride, StudentModule
|
||||
|
||||
@@ -16,15 +16,15 @@ from django.test.utils import override_settings
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
from capa.xqueue_interface import XQueueInterface
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates import api as certs_api
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationConfiguration,
|
||||
CertificateInvalidation,
|
||||
CertificateStatuses,
|
||||
CertificateWhitelist,
|
||||
GeneratedCertificate
|
||||
)
|
||||
from certificates.tests.factories import (
|
||||
from lms.djangoapps.certificates.tests.factories import (
|
||||
CertificateInvalidationFactory,
|
||||
CertificateWhitelistFactory,
|
||||
GeneratedCertificateFactory
|
||||
|
||||
@@ -40,8 +40,10 @@ import instructor_analytics.distributions
|
||||
import lms.djangoapps.instructor.enrollment as enrollment
|
||||
import lms.djangoapps.instructor_task.api
|
||||
from bulk_email.models import BulkEmailFlag, CourseEmail
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import CertificateInvalidation, CertificateStatuses, CertificateWhitelist, GeneratedCertificate
|
||||
from lms.djangoapps.certificates import api as certs_api
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateInvalidation, CertificateStatuses, CertificateWhitelist, GeneratedCertificate,
|
||||
)
|
||||
from courseware.access import has_access
|
||||
from courseware.courses import get_course_by_id, get_course_with_access
|
||||
from courseware.models import StudentModule
|
||||
|
||||
@@ -24,8 +24,8 @@ from xblock.field_data import DictFieldData
|
||||
from xblock.fields import ScopeIds
|
||||
|
||||
from bulk_email.models import BulkEmailFlag
|
||||
from certificates import api as certs_api
|
||||
from certificates.models import (
|
||||
from lms.djangoapps.certificates import api as certs_api
|
||||
from lms.djangoapps.certificates.models import (
|
||||
CertificateGenerationConfiguration,
|
||||
CertificateGenerationHistory,
|
||||
CertificateInvalidation,
|
||||
|
||||
@@ -17,7 +17,7 @@ from opaque_keys.edx.keys import UsageKey
|
||||
from six import text_type
|
||||
|
||||
import xmodule.graders as xmgraders
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from courseware.models import StudentModule
|
||||
from lms.djangoapps.grades.context import grading_context_for_course
|
||||
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification
|
||||
|
||||
@@ -12,7 +12,7 @@ from collections import Counter
|
||||
from celery.states import READY_STATES
|
||||
|
||||
from bulk_email.models import CourseEmail
|
||||
from certificates.models import CertificateGenerationHistory
|
||||
from lms.djangoapps.certificates.models import CertificateGenerationHistory
|
||||
from lms.djangoapps.instructor_task.api_helper import (
|
||||
check_arguments_for_rescoring,
|
||||
check_arguments_for_overriding,
|
||||
|
||||
@@ -6,8 +6,8 @@ from time import time
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models import Q
|
||||
|
||||
from certificates.api import generate_user_certificates
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.api import generate_user_certificates
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from student.models import CourseEnrollment
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ from time import time
|
||||
from lazy import lazy
|
||||
from pytz import UTC
|
||||
|
||||
from certificates.models import CertificateWhitelist, GeneratedCertificate, certificate_info_for_user
|
||||
from courseware.courses import get_course_by_id
|
||||
from instructor_analytics.basic import list_problem_responses
|
||||
from instructor_analytics.csvs import format_dictlist
|
||||
from lms.djangoapps.certificates.models import CertificateWhitelist, GeneratedCertificate, certificate_info_for_user
|
||||
from lms.djangoapps.grades.context import grading_context, grading_context_for_course
|
||||
from lms.djangoapps.grades.models import PersistentCourseGrade
|
||||
from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory
|
||||
|
||||
@@ -6,7 +6,7 @@ from mock import MagicMock, Mock, patch
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
from bulk_email.models import SEND_TO_LEARNERS, SEND_TO_MYSELF, SEND_TO_STAFF, CourseEmail
|
||||
from certificates.models import CertificateGenerationHistory, CertificateStatuses
|
||||
from lms.djangoapps.certificates.models import CertificateGenerationHistory, CertificateStatuses
|
||||
from common.test.utils import normalize_repr
|
||||
from courseware.tests.factories import UserFactory
|
||||
from lms.djangoapps.instructor_task.api import (
|
||||
|
||||
@@ -27,8 +27,8 @@ from six import text_type
|
||||
|
||||
import openedx.core.djangoapps.user_api.course_tag.api as course_tag_api
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from certificates.tests.factories import CertificateWhitelistFactory, GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
|
||||
from lms.djangoapps.certificates.tests.factories import CertificateWhitelistFactory, GeneratedCertificateFactory
|
||||
from course_modes.models import CourseMode
|
||||
from course_modes.tests.factories import CourseModeFactory
|
||||
from courseware.tests.factories import InstructorFactory
|
||||
|
||||
@@ -5,7 +5,7 @@ Serializer for user API
|
||||
from rest_framework import serializers
|
||||
from rest_framework.reverse import reverse
|
||||
|
||||
from certificates.api import certificate_downloadable_status
|
||||
from lms.djangoapps.certificates.api import certificate_downloadable_status
|
||||
from courseware.access import has_access
|
||||
from student.models import CourseEnrollment, User
|
||||
from util.course import get_encoded_course_sharing_utm_params, get_link_for_about_page
|
||||
|
||||
@@ -14,9 +14,9 @@ from milestones.tests.utils import MilestonesTestCaseMixin
|
||||
from mock import patch
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
from certificates.api import generate_user_certificates
|
||||
from certificates.models import CertificateStatuses
|
||||
from certificates.tests.factories import GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.api import generate_user_certificates
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
from course_modes.models import CourseMode
|
||||
from courseware.access_response import MilestoneAccessError, StartDateError, VisibilityError
|
||||
from lms.djangoapps.grades.tests.utils import mock_passing_grade
|
||||
|
||||
@@ -2120,7 +2120,7 @@ INSTALLED_APPS = [
|
||||
'track',
|
||||
'eventtracking.django.apps.EventTrackingConfig',
|
||||
'util',
|
||||
'certificates.apps.CertificatesConfig',
|
||||
'lms.djangoapps.certificates.apps.CertificatesConfig',
|
||||
'dashboard',
|
||||
'lms.djangoapps.instructor.apps.InstructorConfig',
|
||||
'lms.djangoapps.instructor_task',
|
||||
@@ -2128,9 +2128,6 @@ INSTALLED_APPS = [
|
||||
'bulk_email',
|
||||
'branding',
|
||||
|
||||
# Signals
|
||||
'openedx.core.djangoapps.signals.apps.SignalConfig',
|
||||
|
||||
# Student support tools
|
||||
'support',
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<%def name="online_help_token()"><% return "progress" %></%def>
|
||||
<%!
|
||||
from course_modes.models import CourseMode
|
||||
from certificates.models import CertificateStatuses
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses
|
||||
from django.utils.translation import ugettext as _
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
@@ -10,7 +10,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.generic.base import RedirectView
|
||||
|
||||
from branding import views as branding_views
|
||||
from certificates import views as certificates_views
|
||||
from lms.djangoapps.certificates import views as certificates_views
|
||||
from config_models.views import ConfigurationModelCurrentAPIView
|
||||
from courseware.masquerade import handle_ajax as courseware_masquerade_handle_ajax
|
||||
from courseware.module_render import handle_xblock_callback, handle_xblock_callback_noauth, xblock_view, xqueue_callback
|
||||
|
||||
@@ -6,7 +6,7 @@ from datetime import datetime
|
||||
|
||||
from pytz import UTC
|
||||
|
||||
from certificates.models import CertificateWhitelist
|
||||
from lms.djangoapps.certificates.models import CertificateWhitelist
|
||||
from openedx.core.djangoapps.certificates.config import waffle
|
||||
from student.models import CourseEnrollment
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
"""
|
||||
Openedx Certificates Application Configuration
|
||||
"""
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class OpenedxCertificatesConfig(AppConfig):
|
||||
"""
|
||||
Application Configuration for Openedx Certificates.
|
||||
"""
|
||||
name = 'openedx.core.djangoapps.certificates'
|
||||
label = 'openedx_certificates'
|
||||
@@ -7,7 +7,7 @@ from django.core.management import BaseCommand
|
||||
from django.db.models import Q
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from certificates.models import CertificateStatuses, GeneratedCertificate # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate # pylint: disable=import-error
|
||||
from course_modes.models import CourseMode
|
||||
from openedx.core.djangoapps.catalog.utils import get_programs
|
||||
from openedx.core.djangoapps.programs.tasks.v1.tasks import award_program_certificates
|
||||
|
||||
@@ -4,7 +4,7 @@ import mock
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase
|
||||
|
||||
from certificates.models import CertificateStatuses # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.models import CertificateStatuses # pylint: disable=import-error
|
||||
from course_modes.models import CourseMode
|
||||
from lms.djangoapps.certificates.api import MODES
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
"""
|
||||
Signal handlers are registered at startup here.
|
||||
"""
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SignalConfig(AppConfig):
|
||||
"""
|
||||
Application Configuration for Signals.
|
||||
"""
|
||||
name = u'openedx.core.djangoapps.signals'
|
||||
|
||||
def ready(self):
|
||||
"""
|
||||
Connect handlers.
|
||||
"""
|
||||
# Can't import models at module level in AppConfigs, and models get
|
||||
# included from the signal handlers
|
||||
from . import signals, handlers # pylint: disable=unused-variable
|
||||
@@ -1,30 +0,0 @@
|
||||
"""
|
||||
This module contains all general use or cross-use handlers.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from django.dispatch import receiver
|
||||
|
||||
from certificates.models import CertificateGenerationCourseSetting
|
||||
from signals import COURSE_PACING_CHANGED
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@receiver(COURSE_PACING_CHANGED, dispatch_uid="update_cert_settings_on_pacing_change")
|
||||
def _update_cert_settings_on_pacing_change(sender, updated_course_overview, **kwargs): # pylint: disable=unused-argument
|
||||
"""
|
||||
Catches the signal that course pacing has changed and enable/disable
|
||||
the self-generated certificates according to course-pacing.
|
||||
"""
|
||||
toggle_self_generated_certs(updated_course_overview.id, updated_course_overview.self_paced)
|
||||
log.info(u'Certificate Generation Setting Toggled for {course_id} via pacing change'.format(
|
||||
course_id=updated_course_overview.id
|
||||
))
|
||||
|
||||
|
||||
def toggle_self_generated_certs(course_key, course_self_paced):
|
||||
"""
|
||||
Enable or disable self-generated certificates for a course according to pacing.
|
||||
"""
|
||||
CertificateGenerationCourseSetting.set_self_generatation_enabled_for_course(course_key, course_self_paced)
|
||||
@@ -5,7 +5,7 @@ import datetime
|
||||
import ddt
|
||||
import mock
|
||||
|
||||
from certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
|
||||
from course_modes.models import CourseMode
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
@@ -62,7 +62,7 @@ INSTALLED_APPS = (
|
||||
'edxval',
|
||||
'courseware',
|
||||
'student',
|
||||
'certificates.apps.CertificatesConfig',
|
||||
'lms.djangoapps.certificates.apps.CertificatesConfig',
|
||||
'openedx.core.djangoapps.user_api',
|
||||
'course_modes.apps.CourseModesConfig',
|
||||
'lms.djangoapps.verify_student.apps.VerifyStudentConfig',
|
||||
|
||||
Reference in New Issue
Block a user