def get_context_data(self, **kwargs): context = super(EnrollmentGeographyView, self).get_context_data(**kwargs) presenter = CourseEnrollmentPresenter(self.course_id) data = None last_updated = None try: summary, data = presenter.get_geography_data() last_updated = summary['last_updated'] # Add summary data (e.g. num countries, top 3 countries) directly to the context context.update(summary) except NotFoundError: logger.error( "Failed to retrieve enrollment geography data for %s.", self.course_id) context['js_data']['course']['enrollmentByCountry'] = data context.update( {'update_message': self.get_last_updated_message(last_updated)}) context['page_data'] = self.get_page_data(context) return context
def get_context_data(self, **kwargs): context = super(EnrollmentActivityView, self).get_context_data(**kwargs) presenter = CourseEnrollmentPresenter(self.course_id) summary = None trend = None last_updated = None try: summary, trend = presenter.get_summary_and_trend_data() last_updated = summary['last_updated'] except NotFoundError: logger.error("Failed to retrieve enrollment activity data for %s.", self.course_id) # add the enrollment data for the page context['js_data']['course']['enrollmentTrends'] = trend context.update({ 'summary': summary, 'update_message': self.get_last_updated_message(last_updated) }) context['page_data'] = self.get_page_data(context) return context
def setUp(self): self.course_id = 'edX/DemoX/Demo_Course' self.presenter = CourseEnrollmentPresenter(self.course_id)