def test_make_bread_crumbs(self): """ Verify the function parses the list of tuples and returns a list of corresponding dicts.""" links = [(reverse('publisher:publisher_courses_new'), 'Courses'), (None, 'Testing')] self.assertEqual( [{'url': '/publisher/courses/new/', 'slug': 'Courses'}, {'url': None, 'slug': 'Testing'}], make_bread_crumbs(links) )
def get_context_data(self, **kwargs): context = super(CourseDetailView, self).get_context_data(**kwargs) user = self.request.user course = self.object context['can_edit'] = mixins.check_course_organization_permission( user, course, OrganizationExtension.EDIT_COURSE) context['breadcrumbs'] = make_bread_crumbs([ (reverse('publisher:publisher_courses'), 'Courses'), (None, course.title), ]) context['comment_object'] = course context['post_back_url'] = reverse('publisher:publisher_course_detail', kwargs={'pk': self.object.id}) 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_history_widget_feature'] = waffle.switch_is_active( 'publisher_history_widget_feature') context['publisher_approval_widget_feature'] = waffle.switch_is_active( 'publisher_approval_widget_feature') context['role_widgets'] = get_course_role_widgets_data( user, course, course.course_state, 'publisher:api:change_course_state') return context
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
def get(self, request, *args, **kwargs): context = self.get_context_data() course_run = context.get('course_run') course = course_run.course context['course_form'] = self.course_form( instance=course, initial=context.get('initial'), organization=context.get('organization'), edit_mode=True) context['run_form'] = self.run_form(instance=course_run) context['seat_form'] = self.seat_form( instance=course_run.seats.first()) context['breadcrumbs'] = make_bread_crumbs([ (reverse('publisher:publisher_courses'), 'Courses'), (reverse('publisher:publisher_course_detail', kwargs={'pk': course.id}), course.title), (None, '{type}: {start}'.format( type=course_run.get_pacing_type_display(), start=course_run.start.strftime("%B %d, %Y"))) ]) return render(request, self.template_name, context)