コード例 #1
0
def change_desiderata(request):
    """
    This view is to change desiderata for semester
    in which the desiderata is currently open.
    """
    user = request.user
    employee = user.employee
    semester = Semester.get_default_semester()

    desiderata = Desiderata.get_desiderata(employee, semester)
    other = DesiderataOther.get_desiderata_other(employee, semester)
    desiderata_formset_initial = Desiderata.get_desiderata_to_formset(
        desiderata)

    if request.method == 'POST':
        formset = DesiderataFormSet(request.POST)
        other_form = DesiderataOtherForm(request.POST, instance=other)
        if formset.is_valid():
            formset.save(desiderata, employee, semester)
            desiderata = Desiderata.get_desiderata(employee, semester)
            desiderata_formset_initial = Desiderata.get_desiderata_to_formset(
                desiderata)
        if other_form.is_valid():
            other_form.save()
        messages.success(request, 'Zmiany zapisano pomyślnie')
    else:
        other_form = DesiderataOtherForm(instance=other)
    formset = DesiderataFormSet(initial=desiderata_formset_initial)
    data = {'formset': formset, 'other_form': other_form, 'semester': semester}
    return render(request, 'offer/desiderata/change_desiderata.html', data)
コード例 #2
0
    def handle(self, *args, **options):
        semester = Semester.get_default_semester()
        if options['person']:
            students = Student.objects.filter(status=0)
            for student in students:
                records = Record.enrolled.filter(
                    student=student, group__course__semester=semester)
                for r in records:
                    print(str(student.id) + ' ' + str(r.group_id))
                    #print str(student.id) + ' ' + str(r.id)

        if options['group']:
            groups = Group.objects.filter(course__semester=semester)
            for g in groups:
                for t in g.term.all():
                    print(str(g.id) + ' ' + str(t))

        if options['type']:
            groups = Group.objects.filter(course__semester=semester)
            for g in groups:
                print(str(g.id) + ' ' + g.get_type_display())