Esempio n. 1
0
def show_marks(request,landmark_id, grade):
    start, end = get_current_range()
    marks = StudentMark.objects.filter(
            date_created__gte=start,
            date_created__lte=end,
            landmark=landmark_id,
            student__grade=grade).order_by('student', 'date_created', )
    landmark = Landmark.objects.get(pk=landmark_id)
    if request.method == "POST":
        formset = MarkFormSet(request.POST, request.FILES)
        if formset.is_valid():
            formset.save()
            messages.info(request, 'Landmarks Saved')
        else:
            print "formset_invalid"
            print formset.errors
            # Do something.
    else:
        formset = MarkFormSet(queryset=marks)

    return render_to_response ("landmarks/show_marks.html",{

        'marks':marks,
        'formset':formset,
        'landmark':landmark,
        'grade':grade,
    },context_instance=RequestContext(request))
Esempio n. 2
0
def show_student(request,student_id):
    start, end = get_current_range()
    student_person = Person.objects.get(school_id=student_id)
    # marks = StudentMark.objects.filter(student = student_person).select_related().order_by('landmark__area')
    grade_lookup = Grade.objects.get(grade__iexact=student_person.grade)
    landmarks = grade_lookup.landmark_set.all().order_by('area')
    marks = student_person.studentmark_set.select_related().order_by(
            'landmark__area', 'landmark__presentation_order', 'date_created'
            ).filter(
                    landmark__in=landmarks,
                    # grade=grade_lookup,
                    # date_created__gte=start,
                    # date_created__lte=end,
                    )

    if request.method == "POST":
        formset = MarkFormSet(request.POST, request.FILES)
        if formset.is_valid():
            formset.save()
            messages.info(request, 'Landmarks Saved')
        else:
            print "formset_invalid"
            print formset.errors
            # Do something.
    else:
        formset = MarkFormSet(queryset=marks)

    return render_to_response ("landmarks/show_student.html",{
        'student':student_person,
        'marks':marks,
        'formset': formset,
        }, context_instance=RequestContext(request))