def scores_responsible_search(request): entities_manager = mdl_base.entity_manager.find_by_user(request.user) academic_year = mdl_base.academic_year.current_academic_year() _append_entity_version(entities_manager, academic_year) if request.GET: entities_with_descendants = find_entities_with_descendants_from_entity_managers( entities_manager) attributions = list( mdl_attr.attribution.search_scores_responsible( learning_unit_title=request.GET.get('learning_unit_title'), course_code=request.GET.get('course_code'), entities=entities_with_descendants, tutor=request.GET.get('tutor'), responsible=request.GET.get('scores_responsible'))) dict_attribution = get_attributions_list(attributions, "-score_responsible") return render( request, 'scores_responsible.html', { "entities_manager": entities_manager, "academic_year": academic_year, "dict_attribution": dict_attribution, "learning_unit_title": request.GET.get('learning_unit_title'), "course_code": request.GET.get('course_code'), "tutor": request.GET.get('tutor'), "scores_responsible": request.GET.get('scores_responsible'), "init": "1" }) else: return render( request, 'scores_responsible.html', { "entities_manager": entities_manager, "academic_year": academic_year, "init": "0" })
def scores_responsible_search(request): entities_manager = mdl_base.entity_manager.find_by_user(request.user) academic_year = mdl_base.academic_year.current_academic_year() _append_entity_version(entities_manager, academic_year) if request.GET: entities_with_descendants = find_entities_with_descendants_from_entity_managers(entities_manager) attributions = list(mdl_attr.attribution.search_scores_responsible( learning_unit_title=request.GET.get('learning_unit_title'), course_code=request.GET.get('course_code'), entities=entities_with_descendants, tutor=request.GET.get('tutor'), responsible=request.GET.get('scores_responsible') )) dict_attribution = get_attributions_list(attributions, "-score_responsible") return render(request, 'scores_responsible.html', {"entities_manager": entities_manager, "academic_year": academic_year, "dict_attribution": dict_attribution, "learning_unit_title": request.GET.get( 'learning_unit_title'), "course_code": request.GET.get('course_code'), "tutor": request.GET.get('tutor'), "scores_responsible": request.GET.get('scores_responsible'), "init": "1"}) else: return render(request, 'scores_responsible.html', {"entities_manager": entities_manager, "academic_year": academic_year, "init": "0"})
def filter_learning_unit_year_according_person(queryset: QuerySet, person: Person) -> QuerySet: """ This function will filter the learning unit year queryset according to permission of person. * As Entity Manager, we will filter on linked entities * As Program Manager, we will filter on learning unit year which are contained in the program that the person manage but not a borrow learning unit year :param queryset: LearningUnitYear queryset :param person: Person object :return: queryset """ structure = entity_version.build_current_entity_version_structure_in_memory( ) entities_with_descendants = entity_manager.find_entities_with_descendants_from_entity_managers( person.entitymanager_set.all().select_related('entity'), structure) learning_units_of_prgm_mngr = program_manager.get_learning_unit_years_attached_to_program_managers( person.programmanager_set.all(), structure) queryset = queryset.filter( Q(learning_container_year__requirement_entity__in= entities_with_descendants) | Q(id__in=learning_units_of_prgm_mngr)) return queryset
def search_attributions(**criteria): entities_manager = criteria["entities_manager"] course_code = criteria["course_code"] learning_unit_title = criteria["learning_unit_title"] tutor = criteria["tutor"] responsible = criteria["summary_responsible"] entities_with_descendants = find_entities_with_descendants_from_entity_managers(entities_manager) learning_unit_year_attributions_queryset = search_by_learning_unit_this_year(course_code, learning_unit_title) attributions = list(mdl_attr.attribution.filter_attributions( attributions_queryset=learning_unit_year_attributions_queryset, entities=entities_with_descendants, tutor=tutor, responsible=responsible)) return attributions
def search_attributions(academic_year, entities_manager=None, course_code=None, learning_unit_title=None, tutor=None, summary_responsible=None): if entities_manager is None: entities_manager = [] entities_with_descendants = find_entities_with_descendants_from_entity_managers(entities_manager) learning_unit_year_attributions_queryset = search_by_learning_unit_this_year( course_code, learning_unit_title, academic_year=academic_year, ) attributions = mdl_attr.attribution.filter_attributions( attributions_queryset=learning_unit_year_attributions_queryset, entities=entities_with_descendants, tutor=tutor, responsible=summary_responsible, ) return list(attributions)
def search_attributions(academic_year, entities_manager=None, course_code=None, learning_unit_title=None, tutor=None, summary_responsible=None): if entities_manager is None: entities_manager = [] entities_with_descendants = find_entities_with_descendants_from_entity_managers(entities_manager) learning_unit_year_attributions_queryset = search_by_learning_unit_this_year( course_code, learning_unit_title, academic_year=academic_year, ) attributions = mdl_attr.attribution.filter_attributions( attributions_queryset=learning_unit_year_attributions_queryset, entities=entities_with_descendants, tutor=tutor, responsible=summary_responsible, ) return list(attributions)
def _is_user_manager_of_entity_allocation_of_learning_unit_year(user, a_learning_unit_year): entities_manager = mdl_base.entity_manager.find_by_user(user) entities_with_descendants = find_entities_with_descendants_from_entity_managers(entities_manager) return a_learning_unit_year.allocation_entity in entities_with_descendants
def _is_user_manager_of_entity_allocation_of_learning_unit_year( user, a_learning_unit_year): entities_manager = mdl_base.entity_manager.find_by_user(user) entities_with_descendants = find_entities_with_descendants_from_entity_managers( entities_manager) return a_learning_unit_year.allocation_entity in entities_with_descendants