def get(self, request): # lint-amnesty, pylint: disable=missing-function-docstring if not configuration_helpers.get_value('CONTACT_US_PAGE', True): raise Http404 context = { 'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME), 'support_email': configuration_helpers.get_value('CONTACT_EMAIL', settings.CONTACT_EMAIL), 'custom_fields': settings.ZENDESK_CUSTOM_FIELDS } # Tag all issues with LMS to distinguish channel which received the request tags = ['LMS'] # Per edX support, we would like to be able to route feedback items by site via tagging current_site_name = configuration_helpers.get_value("SITE_NAME") if current_site_name: current_site_name = current_site_name.replace(".", "_") tags.append(f"site_name_{current_site_name}") if request.user.is_authenticated: context['course_id'] = request.session.get('course_id', '') context['user_enrollments'] = CourseEnrollment.enrollments_for_user_with_overviews_preload(request.user) enterprise_customer = enterprise_api.enterprise_customer_for_request(request) if enterprise_customer: tags.append('enterprise_learner') context['tags'] = tags return render_to_response("support/contact_us.html", context)
def get_course_enrollments(user, org_whitelist, org_blacklist, course_limit=None): """ Given a user, return a filtered set of their course enrollments. Arguments: user (User): the user in question. org_whitelist (list[str]): If not None, ONLY courses of these orgs will be returned. org_blacklist (list[str]): Courses of these orgs will be excluded. course_limit: Number courses to load in dashboard if set to None then all the courses would be load. Returns: generator[CourseEnrollment]: a sequence of enrollments to be displayed on the user's dashboard. """ for enrollment in CourseEnrollment.enrollments_for_user_with_overviews_preload( user, course_limit): # If the course is missing or broken, log an error and skip it. course_overview = enrollment.course_overview if not course_overview: log.error("User %s enrolled in broken or non-existent course %s", user.username, enrollment.course_id) continue # Filter out anything that is not in the whitelist. if org_whitelist and course_overview.location.org not in org_whitelist: continue # Conversely, filter out any enrollments in the blacklist. elif org_blacklist and course_overview.location.org in org_blacklist: continue # Else, include the enrollment. else: yield enrollment