+ if not (comp_ids or sect_ids):
+ if level:
+ errors["competences"] = "Please!"
+ elif level is None:
+ errors["level"] = "Please!"
+ else:
+ chosen_competences = SortedDict()
+ for competence in Competence.objects.filter(
+ models.Q(pk__in=comp_ids) | models.Q(section__pk__in=sect_ids)):
+ try:
+ competence.for_level_ = competence.for_level(level)
+ except CompetenceLevel.DoesNotExist:
+ pass
+ chosen_competences.setdefault(competence.section, []).append(competence)
+ context['chosen_competences'] = chosen_competences