コード例 #1
0
    def test_organization_key(self):
        """ Verify that the wrapper return the organization key. """
        course = factories.CourseFactory()
        course_run = factories.CourseRunFactory(course=course)
        wrapped_course_run = CourseRunWrapper(course_run)
        self.assertEqual(wrapped_course_run.organization_key, None)

        organization = OrganizationFactory()
        course.organizations.add(organization)
        wrapped_course_run = CourseRunWrapper(course_run)
        self.assertEqual(wrapped_course_run.organization_key, organization.key)
コード例 #2
0
 def test_organization_key(self):
     """ Verify that the wrapper return the organization key. """
     organization = OrganizationFactory()
     course_run = factories.CourseRunFactory(
         course__organizations=[organization])
     wrapped_course_run = CourseRunWrapper(course_run)
     self.assertEqual(wrapped_course_run.organization_key, organization.key)
コード例 #3
0
    def test_verified_seat_price(self):
        """ Verify that the wrapper return the verified seat price. """
        self.assertEqual(self.wrapped_course_run.verified_seat_price, None)

        seat = factories.SeatFactory(type=Seat.VERIFIED, course_run=self.course_run)
        wrapped_course_run = CourseRunWrapper(self.course_run)
        self.assertEqual(wrapped_course_run.verified_seat_price, seat.price)
コード例 #4
0
 def test_course_type_(self, seats_list, course_type):
     """ Verify that the wrapper return the course type according to the
     available seats.
     """
     self._generate_seats(seats_list)
     wrapper_object = CourseRunWrapper(self.course_run)
     self.assertEqual(wrapper_object.course_type, course_type)
コード例 #5
0
    def test_credit_seat_price(self):
        """ Verify that the wrapper return the credit seat price. """
        self.assertEqual(self.wrapped_course_run.credit_seat_price, None)

        seat = factories.SeatFactory(type=Seat.CREDIT, course_run=self.course_run)
        wrapped_course_run = CourseRunWrapper(self.course_run)
        self.assertEqual(wrapped_course_run.credit_seat_price, seat.credit_price)
コード例 #6
0
    def setUp(self):
        super(CourseRunWrapperTests, self).setUp()
        organization = OrganizationFactory()
        self.course_run = factories.CourseRunFactory(course__organizations=[organization])
        self.course = self.course_run.course

        self.wrapped_course_run = CourseRunWrapper(self.course_run)
コード例 #7
0
    def test_credit_seat(self):
        """ Verify that the wrapper return the credit seat. """
        self.assertEqual(self.wrapped_course_run.credit_seat, None)
        seat = factories.SeatFactory(
            type=Seat.CREDIT, course_run=self.course_run, credit_provider='ASU', credit_hours=9
        )

        wrapped_course_run = CourseRunWrapper(self.course_run)
        self.assertEqual(wrapped_course_run.credit_seat, seat)
コード例 #8
0
    def setUp(self):
        super(CourseRunWrapperTests, self).setUp()
        self.course_run = factories.CourseRunFactory()
        self.course = self.course_run.course
        organization = OrganizationFactory()

        self.course.organizations.add(organization)
        self.course.save()

        self.wrapped_course_run = CourseRunWrapper(self.course_run)
コード例 #9
0
    def get_context_data(self, **kwargs):
        context = super(CourseRunDetailView, self).get_context_data(**kwargs)

        user = self.request.user
        course_run = CourseRunWrapper(self.get_object())
        context['object'] = course_run
        context['comment_object'] = course_run
        context['post_back_url'] = reverse(
            'publisher:publisher_course_run_detail',
            kwargs={'pk': course_run.id})

        context['can_edit'] = mixins.check_course_organization_permission(
            user, course_run.course, OrganizationExtension.EDIT_COURSE_RUN)
        context['role_widgets'] = get_course_role_widgets_data(
            user, course_run.course, course_run.course_run_state,
            'publisher:api:change_course_run_state')
        course_run_state = course_run.course_run_state
        if course_run_state.preview_accepted:
            history_object = course_run_state.history.filter(
                preview_accepted=True).order_by('-modified').first()
            if history_object:
                context['preview_accepted_date'] = history_object.modified

        context['breadcrumbs'] = make_bread_crumbs([
            (reverse('publisher:publisher_courses'), 'Courses'),
            (reverse('publisher:publisher_course_detail',
                     kwargs={'pk':
                             course_run.course.id}), course_run.course.title),
            (None, '{type}: {start}'.format(
                type=course_run.get_pacing_type_display(),
                start=course_run.start.strftime("%B %d, %Y")))
        ])

        context['can_view_all_tabs'] = mixins.check_roles_access(user)
        context['publisher_hide_features_for_pilot'] = waffle.switch_is_active(
            'publisher_hide_features_for_pilot')
        context['publisher_comment_widget_feature'] = waffle.switch_is_active(
            'publisher_comment_widget_feature')
        context['publisher_approval_widget_feature'] = waffle.switch_is_active(
            'publisher_approval_widget_feature')

        return context
コード例 #10
0
    def get_context_data(self, **kwargs):
        context = super(Dashboard, self).get_context_data(**kwargs)
        course_runs = context.get('object_list')
        published_course_runs = course_runs.filter(
            state__name=State.PUBLISHED,
            state__modified__gt=datetime.today() -
            timedelta(days=self.default_published_days)).select_related(
                'state').all().order_by('-state__modified')
        unpublished_course_runs = course_runs.exclude(
            state__name=State.PUBLISHED)
        studio_request_courses = unpublished_course_runs.filter(
            lms_course_id__isnull=True)

        context['studio_request_courses'] = [
            CourseRunWrapper(course_run)
            for course_run in studio_request_courses
        ]
        context['unpublished_course_runs'] = [
            CourseRunWrapper(course_run)
            for course_run in unpublished_course_runs
        ]
        context['published_course_runs'] = [
            CourseRunWrapper(course_run)
            for course_run in published_course_runs
        ]
        context['default_published_days'] = self.default_published_days

        preview_course_runs = course_runs.filter(
            state__name=State.NEEDS_FINAL_APPROVAL,
            preview_url__isnull=False).select_related('state').order_by(
                '-state__modified')

        context['preview_course_runs'] = [
            CourseRunWrapper(course_run) for course_run in preview_course_runs
        ]

        return context
コード例 #11
0
    def test_callable(self):
        mock_callable = mock.Mock(return_value='callable_value')
        mock_obj = mock.MagicMock(callable_attr=mock_callable)
        wrapper = CourseRunWrapper(mock_obj)

        self.assertEqual(wrapper.callable_attr(), 'callable_value')
コード例 #12
0
ファイル: test_wrapper.py プロジェクト: edx/course-discovery
    def test_callable(self):
        mock_callable = mock.Mock(return_value="callable_value")
        mock_obj = mock.MagicMock(callable_attr=mock_callable)
        wrapper = CourseRunWrapper(mock_obj)

        self.assertEqual(wrapper.callable_attr(), "callable_value")
コード例 #13
0
    def get_context_data(self, **kwargs):
        context = super(Dashboard, self).get_context_data(**kwargs)
        course_runs = context.get('object_list')
        published_course_runs = course_runs.filter(
            course_run_state__name=CourseRunStateChoices.Published,
            course_run_state__modified__gt=datetime.today() -
            timedelta(days=self.default_published_days)).select_related(
                'course_run_state').order_by('-course_run_state__modified')

        unpublished_course_runs = course_runs.exclude(
            course_run_state__name=CourseRunStateChoices.Published)

        # Studio requests needs to check depending upon the user role with course
        # Also user should be part of project coordinator group.
        if is_publisher_admin(self.request.user):
            studio_request_courses = unpublished_course_runs.filter(
                lms_course_id__isnull=True)
        elif is_project_coordinator_user(self.request.user):
            studio_request_courses = unpublished_course_runs.filter(
                lms_course_id__isnull=True).filter(
                    course__course_user_roles__role=PublisherUserRole.
                    ProjectCoordinator)
        else:
            studio_request_courses = []

        context['studio_request_courses'] = [
            CourseRunWrapper(course_run)
            for course_run in studio_request_courses
        ]
        context['unpublished_course_runs'] = [
            CourseRunWrapper(course_run)
            for course_run in unpublished_course_runs
        ]
        context['published_course_runs'] = [
            CourseRunWrapper(course_run)
            for course_run in published_course_runs
        ]
        context['default_published_days'] = self.default_published_days

        in_progress_course_runs = course_runs.filter(
            course_run_state__name__in=[
                CourseRunStateChoices.Review, CourseRunStateChoices.Draft
            ]).select_related('course_run_state').order_by(
                '-course_run_state__modified')

        preview_course_runs = unpublished_course_runs.filter(
            course_run_state__name=CourseRunStateChoices.Approved,
            preview_url__isnull=False).order_by('-course_run_state__modified')

        context['in_progress_course_runs'] = [
            CourseRunWrapper(course_run)
            for course_run in in_progress_course_runs
        ]
        context['preview_course_runs'] = [
            CourseRunWrapper(course_run) for course_run in preview_course_runs
        ]

        # If user is course team member only show in-progress tab.
        # shows all tabs to internal-users and publisher admins
        context['can_view_all_tabs'] = mixins.check_roles_access(
            self.request.user)

        return context
コード例 #14
0
 def get_context_data(self, **kwargs):
     context = super(CourseRunDetailView, self).get_context_data(**kwargs)
     context['object'] = CourseRunWrapper(context['object'])
     context['comment_object'] = self.object.course
     return context