Exemplo n.º 1
0
    def handle(self, *args, **options):

        if options['all']:
            course_keys = [course.id for course in modulestore().get_course_summaries()]
        else:
            if len(args) < 1:
                raise CommandError('At least one course or --all must be specified.')
            try:
                course_keys = [CourseKey.from_string(arg) for arg in args]
            except InvalidKeyError:
                raise CommandError('Invalid key specified.')

        CourseOverview.update_select_courses(course_keys, force_update=options.get('force_update'))
Exemplo n.º 2
0
    def setUp(self):
        """
        Create the CourseOverviews we need for this test case.

        There's no publish signal, so we manually create the CourseOverviews.
        Without that, backfill_orgs_and_org_courses has no way to figure out
        which courses exist, which it needs in order to figure out which ones
        need backfilling.

        We can't turn on the course_published signal because if we did so, then
        the outlines would get generated automatically, and there'd be nothing
        to backfill.
        """
        super().setUp()
        CourseOverview.update_select_courses(self.course_keys,
                                             force_update=True)
Exemplo n.º 3
0
    def test_already_enrolled_course_ended(self, mock_get_course_runs):
        """
        Test that already enrolled user can still select a session while
        course has ended but upgrade deadline is in future.
        """
        course_entitlement = CourseEntitlementFactory.create(
            user=self.user, mode=CourseMode.VERIFIED)
        mock_get_course_runs.return_value = self.return_values

        # Setup enrollment period to be in the past
        utc_now = datetime.now(UTC)
        self.course.start = utc_now - timedelta(days=15)
        self.course.end = utc_now - timedelta(days=1)
        self.course = self.update_course(self.course, self.user.id)
        CourseOverview.update_select_courses([self.course.id],
                                             force_update=True)

        CourseEnrollment.enroll(self.user,
                                self.course.id,
                                mode=CourseMode.AUDIT)

        url = reverse(self.ENTITLEMENTS_ENROLLMENT_NAMESPACE,
                      args=[str(course_entitlement.uuid)])

        data = {'course_run_id': str(self.course.id)}
        response = self.client.post(
            url,
            data=json.dumps(data),
            content_type='application/json',
        )
        course_entitlement.refresh_from_db()

        assert response.status_code == 201
        assert CourseEnrollment.is_enrolled(self.user, self.course.id)
        (enrolled_mode, is_active) = CourseEnrollment.enrollment_mode_for_user(
            self.user, self.course.id)
        assert is_active and (enrolled_mode == course_entitlement.mode)
        assert course_entitlement.enrollment_course_run is not None
Exemplo n.º 4
0
def async_course_overview_update(*args, **kwargs):
    course_keys = [CourseKey.from_string(arg) for arg in args]
    CourseOverview.update_select_courses(course_keys,
                                         force_update=kwargs['force_update'])
Exemplo n.º 5
0
def async_course_overview_update(*args, **kwargs):
    course_keys = [CourseKey.from_string(arg) for arg in args]
    CourseOverview.update_select_courses(course_keys, force_update=kwargs['force_update'])