本文整理匯總了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)