def get_context_data(self, **kwargs): context = super().get_context_data() context["prerequisite"] = get_object_or_none(Prerequisite, learning_unit_year=context["learning_unit_year"], education_group_year=context["root"]) context["can_modify_prerequisite"] = perms.is_eligible_to_change_education_group(context['person'], context["root"]) return context
def get_context_data(self, **kwargs): context = super().get_context_data() luy = self.object root = context["root"] context["prerequisite"] = get_object_or_none(Prerequisite, learning_unit_year=luy, education_group_year=root) context[ "can_modify_prerequisite"] = perms.is_eligible_to_change_education_group( context['person'], context["root"]) context['is_prerequisites_list'] = Prerequisite.objects.filter( prerequisiteitem__learning_unit=luy.learning_unit, education_group_year=root) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # This objects are mandatory for all education group views context['person'] = self.get_person() # TODO same param context['root'] = self.get_root() context['root_id'] = self.kwargs.get("root_id") context['parent'] = self.get_root() context["education_group_year"] = self.get_object() context['group_to_parent'] = self.get_group_to_parent() context['can_change_education_group'] = perms.is_eligible_to_change_education_group( person=self.get_person(), education_group=context['object'], ) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # This objects are mandatory for all education group views context['person'] = self.person # FIXME same param context['root'] = self.root context['root_id'] = self.root.pk context['parent'] = self.root context['parent_training'] = self.object.parent_by_training() if self.with_tree: context['tree'] = json.dumps( EducationGroupHierarchy(self.root).to_json()) context['group_to_parent'] = self.request.GET.get( "group_to_parent") or '0' context[ 'can_change_education_group'] = perms.is_eligible_to_change_education_group( person=self.person, education_group=context['object'], ) context[ 'can_change_coorganization'] = perms.is_eligible_to_change_coorganization( person=self.person, education_group=context['object'], ) context['enums'] = mdl.enums.education_group_categories context['current_academic_year'] = self.current_academic_year context["show_identification"] = self.show_identification() context["show_diploma"] = self.show_diploma() context["show_general_information"] = self.show_general_information() context[ "show_skills_and_achievements"] = self.show_skills_and_achievements( ) context["show_administrative"] = self.show_administrative() context["show_content"] = self.show_content() context["show_utilization"] = self.show_utilization() context["show_admission_conditions"] = self.show_admission_conditions() return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # This objects are mandatory for all education group views context['person'] = self.get_person() root = self.get_root() # TODO same param context['root'] = root context['root_id'] = root.pk context['parent'] = root context['tree'] = json.dumps(NodeBranchJsTree(root).to_json()) context['group_to_parent'] = self.request.GET.get("group_to_parent") or '0' context['can_change_education_group'] = perms.is_eligible_to_change_education_group( person=self.get_person(), education_group=context['object'], ) context['enums'] = mdl.enums.education_group_categories return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # This objects are mandatory for all education group views context['person'] = self.person # FIXME same param context['root'] = self.root context['root_id'] = self.root.pk context['parent'] = self.root context['parent_training'] = self.object.parent_by_training() context["show_identification"] = self.show_identification() context["show_diploma"] = self.show_diploma() context["show_general_information"] = self.show_general_information() context["show_skills_and_achievements"] = self.show_skills_and_achievements() context["show_administrative"] = self.show_administrative() context["show_content"] = self.show_content() context["show_utilization"] = self.show_utilization() context["show_admission_conditions"] = self.show_admission_conditions() if self.with_tree: # FIXME: resolve dependency in other way from program_management.business.group_element_years.group_element_year_tree import EducationGroupHierarchy education_group_hierarchy_tree = EducationGroupHierarchy(self.root, tab_to_show=self.request.GET.get('tab_to_show')) context['tree'] = json.dumps(education_group_hierarchy_tree.to_json()) context['group_to_parent'] = self.request.GET.get("group_to_parent") or '0' context['can_change_education_group'] = perms.is_eligible_to_change_education_group( person=self.person, education_group=context['object'], ) context['can_change_coorganization'] = perms.is_eligible_to_change_coorganization( person=self.person, education_group=context['object'], ) context['enums'] = mdl.enums.education_group_categories context['current_academic_year'] = self.starting_academic_year context['selected_element_clipboard'] = self.get_selected_element_for_clipboard() context['form_xls_custom'] = CustomXlsForm() return context
def get_context_data(self, **kwargs): context = super().get_context_data() luy = self.object root = context["root"] context["prerequisite"] = get_object_or_none(Prerequisite, learning_unit_year=luy, education_group_year=root) context[ "can_modify_prerequisite"] = perms.is_eligible_to_change_education_group( context['person'], context["root"]) context["learning_unit_years_parent"] = {} for grp in self.hierarchy.included_group_element_years: if not grp.child_leaf: continue context["learning_unit_years_parent"].setdefault( grp.child_leaf.id, grp) context['is_prerequisites_list'] = Prerequisite.objects.filter( prerequisiteitem__learning_unit=luy.learning_unit, education_group_year=root).select_related('learning_unit_year') return context
def can_change_education_group(user, education_group): pers = get_object_or_404(person.Person, user=user) if not business_perms.is_eligible_to_change_education_group( pers, education_group, raise_exception=True): raise PermissionDenied return True
def is_eligible_to_detach_group_element_year(person, group_element_year, raise_exception): return is_eligible_to_change_education_group(person, group_element_year.parent, raise_exception)
def is_eligible_to_update_group_element_year(person, group_element_year, raise_exception): return is_eligible_to_change_education_group(person, group_element_year.parent, raise_exception) and \ (not group_element_year.child_branch or _can_user_update_education_group_year_child(person, group_element_year.child_branch, raise_exception))