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


Python Unit.sub_unit_ids方法代码示例

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


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

示例1: view_courses

# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import sub_unit_ids [as 别名]
def view_courses(request):
    """
    View to view all courses
    """
    if 'coursesearch' in request.GET and 'course' in request.GET \
            and request.GET['course'] and request.GET['course'].isdigit():
        # handle the search for other courses
        offering = get_object_or_404(Course, id=request.GET['course'])
        return HttpResponseRedirect(reverse('advisornotes.views.view_course_notes', kwargs={'unit_course_slug': offering.slug}))

    # all courses where a recent offering was owned by relevant units
    subunits = Unit.sub_unit_ids(request.units)
    old_sem = Semester.get_semester(datetime.date.today() - datetime.timedelta(days=365 * 2))
    offerings = CourseOffering.objects.filter(owner__in=subunits, semester__name__gte=old_sem.name) \
                                      .values('course').order_by().distinct()

    # all courses where there are notes from relevant units
    notes = ArtifactNote.objects.filter(unit__in=request.units).exclude(course__isnull=True) \
                                .values('course').order_by().distinct()
    
    with_note_ids = set(n['course'] for n in notes)
    course_ids = set(o['course'] for o in offerings)
    course_ids |= with_note_ids

    # all current CourseOfferings with notes: interested in those Courses too
    offering_notes = ArtifactNote.objects.filter(unit__in=request.units, course_offering__semester__name__gte=old_sem.name) \
                                        .values('course_offering__course').order_by().distinct()
    offering_note_ids = set(n['course_offering__course'] for n in offering_notes)
    with_note_ids |= offering_note_ids
    course_ids |= offering_note_ids
    
    courses = Course.objects.filter(id__in=course_ids)
    form = CourseSearchForm()

    return render(request,
        'advisornotes/view_courses.html',
        {'courses': courses, 'with_note_ids': with_note_ids, 'form': form}
    )
开发者ID:avacariu,项目名称:coursys,代码行数:40,代码来源:views.py

示例2: view_course_offerings

# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import sub_unit_ids [as 别名]
def view_course_offerings(request, semester=None):
    """
    View to view all courses
    """
    if semester:
        semester = get_object_or_404(Semester, name=semester)
        semesters = None
    else:
        semester = Semester.get_semester(date=datetime.date.today() + datetime.timedelta(days=60))
        semesters = Semester.objects.filter(start__lte=datetime.date.today() + datetime.timedelta(days=365)).order_by('-end')[:6]
    
    if 'offeringsearch' in request.GET and request.GET['offeringsearch'] and request.GET['offeringsearch'].isdigit():
        # handle the search for other offerings
        offering = get_object_or_404(CourseOffering, id=request.GET['offering'])
        return HttpResponseRedirect(reverse('advisornotes.views.view_offering_notes', kwargs={'course_slug': offering.slug}))

    subunits = Unit.sub_unit_ids(request.units)
    offerings = CourseOffering.objects.filter(owner__in=subunits, semester=semester)
    form = OfferingSearchForm()
    return render(request,
        'advisornotes/view_course_offerings.html',
        {'offerings': offerings, 'semester': semester, 'semesters': semesters, 'form': form}
    )
开发者ID:avacariu,项目名称:coursys,代码行数:25,代码来源:views.py

示例3: only_subunits

# 需要导入模块: from coredata.models import Unit [as 别名]
# 或者: from coredata.models.Unit import sub_unit_ids [as 别名]
 def only_subunits(self, units):
     subunit_ids = Unit.sub_unit_ids(units)
     return self.filter(unit__id__in=subunit_ids)
开发者ID:avacariu,项目名称:coursys,代码行数:5,代码来源:models.py


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