def proposition_dissertation_detail(request, pk): subject = get_object_or_404( proposition_dissertation.PropositionDissertation, pk=pk) offer_propositions = proposition_offer.search_by_proposition_dissertation( subject) person = mdl.person.find_by_user(request.user) student = mdl.student.find_by_person(person) using = dissertation.count_by_proposition(subject) percent = using * 100 / subject.max_number_student if subject.max_number_student else 0 count_proposition_role = proposition_role.count_by_proposition(subject) files = proposition_document_file.find_by_proposition(subject) filename = "" for file in files: filename = file.document_file.file_name if count_proposition_role < 1: proposition_role.add('PROMOTEUR', subject.author, subject) proposition_roles = proposition_role.search_by_proposition(subject) return layout.render( request, 'proposition_dissertation_detail.html', { 'percent': round(percent, 2), 'proposition_roles': proposition_roles, 'proposition_dissertation': subject, 'offer_propositions': offer_propositions, 'student': student, 'using': using, 'filename': filename })
def manager_proposition_dissertation_detail(request, pk): proposition = proposition_dissertation.find_by_id(pk) if proposition is None: return redirect('manager_proposition_dissertations') offer_propositions = proposition_offer.find_by_proposition_dissertation(proposition) person = mdl.person.find_by_user(request.user) adv = adviser.search_by_person(person) count_use = dissertation.count_by_proposition(proposition) percent = count_use * 100 / proposition.max_number_student if proposition.max_number_student else 0 count_proposition_role = proposition_role.count_by_proposition(proposition) files = proposition_document_file.find_by_proposition(proposition) filename = "" for file in files: filename = file.document_file.file_name if count_proposition_role < 1: proposition_role.add('PROMOTEUR', proposition.author, proposition) proposition_roles = proposition_role.search_by_proposition(proposition) return layout.render(request, 'manager_proposition_dissertation_detail.html', {'proposition_dissertation': proposition, 'offer_propositions': offer_propositions, 'adviser': adv, 'count_use': count_use, 'percent': round(percent, 2), 'proposition_roles': proposition_roles, 'count_proposition_role': count_proposition_role, 'filename': filename})
def manager_proposition_dissertation_detail(request, pk): prefetch_propositions = return_prefetch_propositions() proposition = get_object_or_404( PropositionDissertation.objects.select_related( 'author__person', 'creator').prefetch_related( prefetch_propositions, 'offer_propositions__education_group__educationgroupyear_set', 'propositionrole_set__adviser__person', ), pk=pk) adv = request.user.person.adviser count_use = dissertation.count_by_proposition(proposition) percent = count_use * 100 / proposition.max_number_student if proposition.max_number_student else 0 count_proposition_role = proposition_role.count_by_proposition(proposition) files = proposition_document_file.find_by_proposition(proposition) filename = "" for file in files: filename = file.document_file.file_name if count_proposition_role < 1: proposition_role.add(dissertation_role_status.PROMOTEUR, proposition.author, proposition) return render( request, 'manager_proposition_dissertation_detail.html', { 'proposition_dissertation': proposition, 'adviser': adv, 'count_use': count_use, 'percent': round(percent, 2), 'count_proposition_role': count_proposition_role, 'filename': filename })
def test_count_by_proposition(self): self.prop_dissert = PropositionDissertationFactory() self.starting_academic_year = create_current_academic_year() self.dissertation_active = DissertationFactory( active=True, status=dissertation_status.COM_SUBMIT, proposition_dissertation=self.prop_dissert, education_group_year__academic_year=self.starting_academic_year ) DissertationFactory(active=False, proposition_dissertation=self.prop_dissert) DissertationFactory(active=True, status=dissertation_status.DRAFT, proposition_dissertation=self.prop_dissert) DissertationFactory(active=True, status=dissertation_status.DIR_KO, proposition_dissertation=self.prop_dissert) self.assertEqual(dissertation.count_by_proposition(self.prop_dissert), 1)
def proposition_dissertation_detail(request, pk): subject = get_object_or_404(proposition_dissertation.PropositionDissertation, pk=pk) offer_propositions = proposition_offer.search_by_proposition_dissertation(subject) person = mdl.person.find_by_user(request.user) student = mdl.student.find_by_person(person) using = dissertation.count_by_proposition(subject) percent = using * 100 / subject.max_number_student if subject.max_number_student else 0 count_proposition_role = proposition_role.count_by_proposition(subject) files = proposition_document_file.find_by_proposition(subject) filename = "" for file in files: filename = file.document_file.file_name if count_proposition_role < 1: proposition_role.add('PROMOTEUR', subject.author, subject) proposition_roles = proposition_role.search_by_proposition(subject) return layout.render(request, 'proposition_dissertation_detail.html', {'percent': round(percent, 2), 'proposition_roles': proposition_roles, 'proposition_dissertation': subject, 'offer_propositions': offer_propositions, 'student': student, 'using': using, 'filename': filename})
def proposition_dissertation_detail(request, pk): person = mdl.person.find_by_user(request.user) starting_academic_year = academic_year.starting_academic_year() subject = get_object_or_404(PropositionDissertation.objects.select_related( 'author', 'author__person').prefetch_related( 'propositionrole_set', 'propositionrole_set__adviser__person', 'offer_propositions'), pk=pk) offer_propositions = subject.offer_propositions.all().annotate( last_acronym=Subquery( EducationGroupYear.objects.filter( education_group__offer_proposition=OuterRef('pk'), academic_year=starting_academic_year).values('acronym')[:1])) student = mdl.student.find_by_person(person) using = dissertation.count_by_proposition(subject) percent = using * 100 / subject.max_number_student if subject.max_number_student else 0 count_proposition_role = PropositionRole.objects.filter( proposition_dissertation=subject).count() files = PropositionDocumentFile.objects.filter(proposition=subject) filename = "" for file in files: filename = file.document_file.file_name if count_proposition_role < 1: proposition_role.add('PROMOTEUR', subject.author, subject) proposition_roles = subject.propositionrole_set.all() return render( request, 'proposition_dissertation_detail.html', { 'percent': round(percent, 2), 'proposition_roles': proposition_roles, 'proposition_dissertation': subject, 'offer_propositions': offer_propositions, 'student': student, 'using': using, 'filename': filename })
def _append_dissertations_count(prop): prop.dissertations_count = dissertation.count_by_proposition(prop) return prop
def test_count_by_proposition(self): self.assertEqual( dissertation.count_by_proposition(self.proposition_dissertation), 2)