本文整理汇总了Python中models.Course.get_notes方法的典型用法代码示例。如果您正苦于以下问题:Python Course.get_notes方法的具体用法?Python Course.get_notes怎么用?Python Course.get_notes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Course
的用法示例。
在下文中一共展示了Course.get_notes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: browse_one_course
# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import get_notes [as 别名]
def browse_one_course(request, course_query, school):
""" View for viewing notes from a fuzzy course search
:course_query: unicode url match, to be type parsed
"""
# TODO: combine this function with `b_school_course`
response = nav_helper(request)
try:
course_query = int(course_query)
except ValueError:
# cant be cast as an int, so we will search for it as a string
pass
course, files = Course.get_notes(course_query, school)
response['course'], response['files'] = course, files
# get the users who are members of the course
response['profiles'] = course.userprofile_set.all()
# get the karma events associated with the course
response['events'] = course.reputationevent_set.order_by('-timestamp').all() # FIXME: possibly order-by
response['viewed_files'] = request.user.get_profile().files.all()
# FIXME: I don't like this logic one bit, either annotate the db query or fix the schema to NEVER do this
response['thanked_files'] = []
response['flagged_files'] = []
for file in files:
_vote = file.votes.filter(user=request.user)
if _vote.exists():
if _vote[0].up: # assuming only one vote result
response['thanked_files'].append(file.id)
else:
response['flagged_files'].append(file.id)
return render(request, 'browse_one_course.html', response)