Exemple #1
0
def generate_proposition_offers(request, proposition):
    for key, value in request.POST.items():
        if 'txt_checkbox_' in key and value == 'on':
            offer = PropositionOffer()
            offer.proposition_dissertation = proposition
            offer_proposition_id = key.replace("txt_checkbox_", "")
            offer.offer_proposition = offer_proposition.find_by_id(int(offer_proposition_id))
            offer.save()
Exemple #2
0
def manager_dissertations_search(request):
    person = mdl.person.find_by_user(request.user)
    adv = adviser.search_by_person(person)
    offers = faculty_adviser.search_by_adviser(adv)
    disserts = dissertation.search(terms=request.GET.get('search', ''),
                                   active=True)
    disserts = disserts.filter(offer_year_start__offer__in=offers)
    offer_prop_search = request.GET.get('offer_prop_search', '')
    academic_year_search = request.GET.get('academic_year', '')
    status_search = request.GET.get('status_search', '')

    if offer_prop_search != '':
        offer_prop_search = int(offer_prop_search)
        offer_prop = offer_proposition.find_by_id(offer_prop_search)
        disserts = disserts.filter(offer_year_start__offer=offer_prop.offer)
    if academic_year_search != '':
        academic_year_search = int(academic_year_search)
        disserts = disserts.filter(
            offer_year_start__academic_year=academic_year.
            find_academic_year_by_id(academic_year_search))
    if status_search != '':
        disserts = disserts.filter(status=status_search)
    offer_props = offer_proposition.search_by_offer(offers)
    show_validation_commission = offer_proposition.show_validation_commission(
        offer_props)
    show_evaluation_first_year = offer_proposition.show_evaluation_first_year(
        offer_props)
    start_date = timezone.now().replace(year=timezone.now().year - 10)
    end_date = timezone.now().replace(year=timezone.now().year + 1)
    academic_year_10y = academic_year.find_academic_years(end_date, start_date)

    if 'bt_xlsx' in request.GET:
        xls = generate_xls(disserts)
        filename = 'dissertations_{}.xlsx'.format(
            time.strftime("%Y-%m-%d_%H:%M"))
        response = HttpResponse(
            xls,
            content_type=
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        )
        response['Content-Disposition'] = "%s%s" % ("attachment; filename=",
                                                    filename)
        return response

    else:
        return layout.render(
            request, "manager_dissertations_list.html", {
                'dissertations': disserts,
                'show_validation_commission': show_validation_commission,
                'show_evaluation_first_year': show_evaluation_first_year,
                'academic_year_10y': academic_year_10y,
                'offer_props': offer_props,
                'offer_prop_search': offer_prop_search,
                'academic_year_search': academic_year_search,
                'status_search': status_search
            })
Exemple #3
0
def manager_offer_parameters_edit(request, pk):
    offer_prop = offer_proposition.find_by_id(pk)
    redirect_if_none(offer_prop, 'dissertations')
    if request.method == "POST":
        form = ManagerOfferPropositionForm(request.POST, instance=offer_prop)
        if form.is_valid():
            form.save()
            return redirect('manager_offer_parameters')
    else:
        form = ManagerOfferPropositionForm(instance=offer_prop)
    return layout.render(request, "manager_offer_parameters_edit.html",
                         {'offer_proposition': offer_prop,
                          'form': form})
Exemple #4
0
def manager_dissertations_search(request):
    terms = request.GET.get('search', '')
    disserts = Dissertation.objects.filter(
        education_group_year__education_group__facultyadviser__adviser__person__user
        =request.user,
        active=True
    ).filter(
        Q(author__person__first_name__icontains=terms)
        | Q(author__person__middle_name__icontains=terms)
        | Q(author__person__last_name__icontains=terms)
        | Q(description__icontains=terms)
        | Q(proposition_dissertation__title__icontains=terms) |
        Q(proposition_dissertation__author__person__first_name__icontains=terms
          ) |
        Q(proposition_dissertation__author__person__middle_name__icontains=terms
          ) |
        Q(proposition_dissertation__author__person__last_name__icontains=terms)
        | Q(status__icontains=terms) | Q(title__icontains=terms)
        | Q(education_group_year__acronym__icontains=terms)).select_related(
            'author__person', 'education_group_year',
            'education_group_year__academic_year',
            'proposition_dissertation__author__person').distinct()
    offer_prop_search = request.GET.get('offer_prop_search', '')
    academic_year_search = request.GET.get('academic_year', '')
    status_search = request.GET.get('status_search', '')

    if offer_prop_search != '':
        offer_prop_search = int(offer_prop_search)
        offer_prop = offer_proposition.find_by_id(offer_prop_search)
        disserts = disserts.filter(
            education_group_year__education_group=offer_prop.education_group)
    if academic_year_search != '':
        academic_year_search = int(academic_year_search)
        disserts = disserts.filter(
            education_group_year__academic_year=academic_year.
            find_academic_year_by_id(academic_year_search))
    if status_search != '':
        disserts = disserts.filter(status=status_search)
    offer_props = OfferProposition.objects.filter(
        education_group__facultyadviser__adviser__person__user=request.user
    ).distinct()
    show_validation_commission = offer_proposition.show_validation_commission(
        offer_props)
    show_evaluation_first_year = offer_proposition.show_evaluation_first_year(
        offer_props)
    year = timezone.now().year
    academic_year_10y = AcademicYear.objects.filter(year__gte=year - 10,
                                                    year__lte=year + 1)

    if 'bt_xlsx' in request.GET:
        xls = generate_xls(disserts)
        filename = 'dissertations_{}.xlsx'.format(
            time.strftime("%Y-%m-%d_%H:%M"))
        response = HttpResponse(
            xls,
            content_type=
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        )
        response['Content-Disposition'] = "%s%s" % ("attachment; filename=",
                                                    filename)
        return response

    else:
        return render(
            request, "manager_dissertations_list.html", {
                'dissertations': disserts,
                'show_validation_commission': show_validation_commission,
                'show_evaluation_first_year': show_evaluation_first_year,
                'academic_year_10y': academic_year_10y,
                'offer_props': offer_props,
                'offer_prop_search': offer_prop_search,
                'academic_year_search': academic_year_search,
                'status_search': status_search
            })
 def test_find_by_id_with_bad_values(self):
     offer_proposition = find_by_id(None)
     self.assertIsNone(offer_proposition)