def manager_informations_detail_stats(request, pk): adv = adviser.get_by_id(pk) if adv is None: return redirect('manager_informations') advisers_pro = dissertation_role.search_by_adviser_and_role_stats( adv, 'PROMOTEUR') count_advisers_pro = dissertation_role.count_by_adviser_and_role_stats( adv, 'PROMOTEUR') count_advisers_pro_request = dissertation_role.count_by_adviser( adv, 'PROMOTEUR', 'DIR_SUBMIT') tab_offer_count_pro = dissertation_role.get_tab_count_role_by_offer( advisers_pro) advisers_copro = dissertation_role.search_by_adviser_and_role_stats( adv, 'CO_PROMOTEUR') count_advisers_copro = dissertation_role.count_by_adviser_and_role_stats( adv, 'CO_PROMOTEUR') tab_offer_count_copro = dissertation_role.get_tab_count_role_by_offer( advisers_copro) advisers_reader = dissertation_role.search_by_adviser_and_role_stats( adv, 'READER') count_advisers_reader = dissertation_role.count_by_adviser_and_role_stats( adv, 'READER') tab_offer_count_read = dissertation_role.get_tab_count_role_by_offer( advisers_reader) return layout.render( request, 'manager_informations_detail_stats.html', { 'adviser': adv, 'count_advisers_copro': count_advisers_copro, 'count_advisers_pro': count_advisers_pro, 'count_advisers_reader': count_advisers_reader, 'count_advisers_pro_request': count_advisers_pro_request, 'tab_offer_count_pro': tab_offer_count_pro, 'tab_offer_count_read': tab_offer_count_read, 'tab_offer_count_copro': tab_offer_count_copro })
def informations_detail_stats(request): person = mdl.person.find_by_user(request.user) adv = adviser.search_by_person(person) advisers_pro = dissertation_role.search_by_adviser_and_role_stats( adv, 'PROMOTEUR') count_advisers_pro = dissertation_role.count_by_adviser_and_role_stats( adv, 'PROMOTEUR') count_advisers_pro_request = dissertation_role.count_by_adviser( adv, 'PROMOTEUR', 'DIR_SUBMIT') tab_offer_count_pro = dissertation_role.get_tab_count_role_by_offer( advisers_pro) advisers_copro = dissertation_role.search_by_adviser_and_role_stats( adv, 'CO_PROMOTEUR') count_advisers_copro = dissertation_role.count_by_adviser_and_role_stats( adv, 'CO_PROMOTEUR') tab_offer_count_copro = dissertation_role.get_tab_count_role_by_offer( advisers_copro) advisers_reader = dissertation_role.search_by_adviser_and_role_stats( adv, 'READER') count_advisers_reader = dissertation_role.count_by_adviser_and_role_stats( adv, 'READER') tab_offer_count_read = dissertation_role.get_tab_count_role_by_offer( advisers_reader) return layout.render( request, 'informations_detail_stats.html', { 'adviser': adv, 'count_advisers_copro': count_advisers_copro, 'count_advisers_pro': count_advisers_pro, 'count_advisers_reader': count_advisers_reader, 'count_advisers_pro_request': count_advisers_pro_request, 'tab_offer_count_pro': tab_offer_count_pro, 'tab_offer_count_read': tab_offer_count_read, 'tab_offer_count_copro': tab_offer_count_copro })
def get_stat_dissertation_role(self): list_stat = [0] * 5 # list_stat[0]= count dissertation_role active of adviser # list_stat[1]= count dissertation_role Promoteur active of adviser # list_stat[2]= count dissertation_role coPromoteur active of adviser # list_stat[3]= count dissertation_role coPromoteur active of adviser # list_stat[4]= count dissertation_role need request active of adviser list_stat[0] = 0 list_stat[1] = 0 list_stat[2] = 0 list_stat[3] = 0 list_stat[4] = 0 queryset = dissertation_role.DissertationRole.objects.all().filter( Q(adviser=self)) list_stat[0] = queryset.filter(dissertation__active=True)\ .count() list_stat[1] = queryset.filter(status='PROMOTEUR')\ .filter(Q(dissertation__active=True)) \ .exclude(Q(dissertation__status='DRAFT') | Q(dissertation__status='ENDED') | Q(dissertation__status='DEFENDED'))\ .count() list_stat[4] = queryset.filter(status='PROMOTEUR')\ .filter(dissertation__status='DIR_SUBMIT')\ .filter(dissertation__active=True)\ .count() advisers_copro = queryset.filter(status='CO_PROMOTEUR')\ .filter(dissertation__active=True) \ .exclude(Q(dissertation__status='DRAFT') | Q(dissertation__status='ENDED') | Q(dissertation__status='DEFENDED')) list_stat[2] = advisers_copro.count() tab_offer_count_copro = dissertation_role.get_tab_count_role_by_offer( advisers_copro) advisers_reader = queryset.filter(Q(adviser=self) & Q(status='READER') & Q(dissertation__active=True))\ .exclude(Q(dissertation__status='DRAFT') | Q(dissertation__status='ENDED') | Q(dissertation__status='DEFENDED')) list_stat[3] = advisers_reader.count() tab_offer_count_read = dissertation_role.get_tab_count_role_by_offer( advisers_reader) advisers_pro = queryset.filter(status='PROMOTEUR')\ .filter(Q(dissertation__active=True)) \ .exclude(Q(dissertation__status='DRAFT') | Q(dissertation__status='ENDED') | Q(dissertation__status='DEFENDED')) tab_offer_count_pro = dissertation_role.get_tab_count_role_by_offer( advisers_pro) return list_stat, tab_offer_count_read, tab_offer_count_copro, tab_offer_count_pro