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


Python Elaboration.search方法代码示例

本文整理汇总了Python中Elaboration.models.Elaboration.search方法的典型用法代码示例。如果您正苦于以下问题:Python Elaboration.search方法的具体用法?Python Elaboration.search怎么用?Python Elaboration.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Elaboration.models.Elaboration的用法示例。


在下文中一共展示了Elaboration.search方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: search

# 需要导入模块: from Elaboration.models import Elaboration [as 别名]
# 或者: from Elaboration.models.Elaboration import search [as 别名]
def search(request, course_short_title=None):
    course = Course.get_or_raise_404(short_title=course_short_title)

    selected_challenge = request.POST['selected_challenge']
    selected_user = request.POST['selected_user'].split()[0]
    selected_tag = request.POST['selected_tag']

    challenges = []
    if(selected_challenge != 'task...'):
        challenges = Challenge.objects.filter(title=selected_challenge[:(
            request.POST['selected_challenge'].rindex('(') - 1)], course=course)
    else:
        challenges = Challenge.objects.filter(course=course)

    user = []
    if(selected_user != 'user...'):
        user = AuroraUser.objects.filter(username=selected_user)
        request.session['display_points'] = "true"
    else:
        user = AuroraUser.objects.all()
        request.session['display_points'] = "false"

    if(selected_tag != 'tag...'):
        aurorauser_ct = ContentType.objects.get_for_model(AuroraUser)
        tagged_items = TaggedItem.objects.filter(
            content_type=aurorauser_ct, tag__name=selected_tag)
        tagged_user_ids = []
        for ti in tagged_items:
            if not tagged_user_ids.__contains__(ti.content_object):
                tagged_user_ids.append(ti.content_object.id)

        tagged_user = AuroraUser.objects.filter(id__in=tagged_user_ids)
        user = user & tagged_user

    elaborations = []
    if Elaboration.search(challenges, user):
        elaborations = list(Elaboration.search(challenges, user))

    # store selected elaborations in session
    request.session['elaborations'] = serializers.serialize(
        'json', elaborations)
    request.session['selection'] = 'search'
    request.session['selected_challenge'] = selected_challenge
    request.session['selected_user'] = selected_user
    request.session['selected_tag'] = selected_tag

    return evaluation(request, course_short_title)
开发者ID:martflu,项目名称:aurora,代码行数:49,代码来源:views.py


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