コード例 #1
0
ファイル: views.py プロジェクト: gurinderhans/coursys
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('advising: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
        })
コード例 #2
0
def chair_index(request):
    # discipline admin for these departments
    subunit_ids = Unit.sub_unit_ids(request.units)
    instr_cases = DisciplineCaseInstr.objects.filter(offering__owner__id__in=subunit_ids).select_related('owner')
    # can see cases either (1) in your unit, or (2) in subunits if the letter has been sent
    instr_cases = [c for c in instr_cases if (c.owner in request.units) or (c.letter_sent != 'WAIT')]
    instr_cases = [c.subclass() for c in instr_cases]

    context = {'instr_cases': instr_cases}
    return render_to_response("discipline/chair-index.html", context, context_instance=RequestContext(request))
コード例 #3
0
def chair_index(request):
    # discipline admin for these departments
    subunit_ids = Unit.sub_unit_ids(request.units)
    has_global_role = 'UNIV' in (u.label for u in request.units)

    instr_cases = DisciplineCaseInstr.objects.filter(offering__owner__id__in=subunit_ids).select_related('owner')
    # can see cases either (1) in your unit, or (2) in subunits if the letter has been sent
    instr_cases = [c for c in instr_cases if (c.owner in request.units) or (c.letter_sent != 'WAIT')]
    instr_cases = [c.subclass() for c in instr_cases]

    context = {'instr_cases': instr_cases, 'has_global_role': has_global_role}
    return render(request, "discipline/chair-index.html", context)
コード例 #4
0
ファイル: views.py プロジェクト: gurinderhans/coursys
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('advising: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
    })
コード例 #5
0
ファイル: views.py プロジェクト: skyemason/coursys
def chair_index(request):
    # discipline admin for these departments
    subunit_ids = Unit.sub_unit_ids(request.units)
    has_global_role = 'UNIV' in (u.label for u in request.units)

    instr_student_cases = DisciplineCaseInstrStudent.objects.filter(offering__owner__id__in=subunit_ids) \
        .select_related('owner', 'offering', 'offering__owner', 'offering__semester', 'group', 'student')
    instr_nonstudent_cases = DisciplineCaseInstrNonStudent.objects.filter(offering__owner__id__in=subunit_ids) \
        .select_related('owner', 'offering', 'offering__owner', 'offering__semester', 'group')
    instr_cases = itertools.chain(instr_student_cases, instr_nonstudent_cases)

    # can see cases either (1) in your unit, or (2) in subunits if the letter has been sent
    instr_cases = [
        c for c in instr_cases
        if (c.offering.owner in request.units) or (c.letter_sent != 'WAIT')
    ]

    context = {'instr_cases': instr_cases, 'has_global_role': has_global_role}
    return render(request, "discipline/chair-index.html", context)
コード例 #6
0
ファイル: views.py プロジェクト: avacariu/coursys
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}
    )
コード例 #7
0
ファイル: views.py プロジェクト: avacariu/coursys
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}
    )
コード例 #8
0
ファイル: models.py プロジェクト: csvenja/coursys
 def only_subunits(self, units):
     subunit_ids = Unit.sub_unit_ids(units)
     return self.filter(unit__id__in=subunit_ids)
コード例 #9
0
ファイル: models.py プロジェクト: avacariu/coursys
 def only_subunits(self, units):
     subunit_ids = Unit.sub_unit_ids(units)
     return self.filter(unit__id__in=subunit_ids)