当前位置: 首页>>代码示例>>Python>>正文


Python Course.get_notes方法代码示例

本文整理汇总了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)
开发者ID:mpevner,项目名称:djKarma,代码行数:34,代码来源:views.py


注:本文中的models.Course.get_notes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。