Пример #1
0
def dissertation_new(request):
    person = mdl.person.find_by_user(request.user)
    student = mdl.student.find_by_person(person)
    offers = mdl.offer.find_by_student(student)
    offer_propositions = offer_proposition.search_by_offers(offers)
    date_now = timezone.now().date()

    if any(o.start_visibility_dissertation <= date_now <= o.end_visibility_dissertation for o in offer_propositions):
        if request.method == "POST":
            form = DissertationForm(request.POST)
            if form.is_valid():
                memory = form.save()
                dissertation_update.add(request, memory, memory.status, justification="student_creation_dissertation")
                return redirect('dissertation_detail', pk=memory.pk)
            else:
                form.fields["offer_year_start"].queryset = offer_year.find_by_student_enrollment(student)
                form.fields["proposition_dissertation"].queryset = proposition_dissertation.search_by_offers(offers)
        else:
            form = DissertationForm(initial={'active': True, 'author': student})
            form.fields["offer_year_start"].queryset = offer_year.find_by_student_enrollment(student)
            form.fields["proposition_dissertation"].queryset = proposition_dissertation.search_by_offers(offers)
        return layout.render(request, 'dissertation_form.html',
                             {'form': form,
                              'defend_periode_choices': dissertation.DEFEND_PERIODE_CHOICES})
    else:
        return redirect('dissertations')
Пример #2
0
def dissertations(request):
    person = mdl.person.find_by_user(request.user)
    student = mdl.student.find_by_person(person)
    offers = mdl.offer.find_by_student(student)
    offer_propositions = offer_proposition.search_by_offers(offers)
    memories = dissertation.find_by_user(student)
    date_now = timezone.now().date()
    visibility = False
    for offer_pro in offer_propositions:
        if offer_pro.start_visibility_dissertation <= date_now <= offer_pro.end_visibility_dissertation:
            visibility = True
    return layout.render(request, 'dissertations_list.html',
                         {'date_now': date_now,
                          'dissertations': memories,
                          'student': student,
                          'visibility': visibility})
Пример #3
0
def dissertations(request):
    person = mdl.person.find_by_user(request.user)
    student = mdl.student.find_by_person(person)
    offers = mdl.offer.find_by_student(student)
    offer_propositions = offer_proposition.search_by_offers(offers)
    memories = dissertation.find_by_user(student)
    date_now = timezone.now().date()
    visibility = False
    for offer_pro in offer_propositions:
        if offer_pro.start_visibility_dissertation <= date_now <= offer_pro.end_visibility_dissertation:
            visibility = True
    return layout.render(
        request, 'dissertations_list.html', {
            'date_now': date_now,
            'dissertations': memories,
            'student': student,
            'visibility': visibility
        })
Пример #4
0
def dissertation_new(request):
    person = mdl.person.find_by_user(request.user)
    student = mdl.student.find_by_person(person)
    offers = mdl.offer.find_by_student(student)
    offer_propositions = offer_proposition.search_by_offers(offers)
    date_now = timezone.now().date()

    if any(o.start_visibility_dissertation <= date_now <=
           o.end_visibility_dissertation for o in offer_propositions):
        if request.method == "POST":
            form = DissertationForm(request.POST)
            if form.is_valid():
                memory = form.save()
                dissertation_update.add(
                    request,
                    memory,
                    memory.status,
                    justification="student_creation_dissertation")
                return redirect('dissertation_detail', pk=memory.pk)
            else:
                form.fields[
                    "offer_year_start"].queryset = offer_year.find_by_student_enrollment(
                        student)
                form.fields[
                    "proposition_dissertation"].queryset = proposition_dissertation.search_by_offers(
                        offers)
        else:
            form = DissertationForm(initial={
                'active': True,
                'author': student
            })
            form.fields[
                "offer_year_start"].queryset = offer_year.find_by_student_enrollment(
                    student)
            form.fields[
                "proposition_dissertation"].queryset = proposition_dissertation.search_by_offers(
                    offers)
        return layout.render(
            request, 'dissertation_form.html', {
                'form': form,
                'defend_periode_choices': dissertation.DEFEND_PERIODE_CHOICES
            })
    else:
        return redirect('dissertations')