本文整理汇总了Python中student.models.CourseEnrollment.enrollments_for_user_with_overviews_preload方法的典型用法代码示例。如果您正苦于以下问题:Python CourseEnrollment.enrollments_for_user_with_overviews_preload方法的具体用法?Python CourseEnrollment.enrollments_for_user_with_overviews_preload怎么用?Python CourseEnrollment.enrollments_for_user_with_overviews_preload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student.models.CourseEnrollment
的用法示例。
在下文中一共展示了CourseEnrollment.enrollments_for_user_with_overviews_preload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import enrollments_for_user_with_overviews_preload [as 别名]
def get(self, request):
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("site_name_{site}".format(site=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_learner_data = enterprise_api.get_enterprise_learner_data(user=request.user)
if enterprise_learner_data:
tags.append('enterprise_learner')
context['tags'] = tags
return render_to_response("support/contact_us.html", context)
示例2: get_course_enrollments
# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import enrollments_for_user_with_overviews_preload [as 别名]
def get_course_enrollments(user, org_whitelist, org_blacklist):
"""
Given a user, return a filtered set of his or her 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.
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):
# 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