예제 #1
0
    def test_get_verbose_children(self):
        result = EducationGroupHierarchy(self.education_group_year_1).to_list()
        context_waiting = [
            self.group_element_year_1, [self.group_element_year_2],
            self.group_element_year_3, [self.group_element_year_4]
        ]
        self.assertEqual(result, context_waiting)

        credits = self.group_element_year_1.relative_credits or self.group_element_year_1.child_branch.credits or 0
        verbose_branch = "{} ({} {})".format(
            self.group_element_year_1.child.title, credits, _("credits"))

        self.assertEqual(self.group_element_year_1.verbose, verbose_branch)

        components = LearningComponentYear.objects.filter(
            learning_unit_year=self.group_element_year_2.child_leaf).annotate(
                total=Case(When(hourly_volume_total_annual=None, then=0),
                           default=F('hourly_volume_total_annual'))).values(
                               'type', 'total')

        verbose_leaf = "{} {} [{}] ({} {})".format(
            self.group_element_year_2.child_leaf.acronym,
            self.group_element_year_2.child_leaf.complete_title,
            volume_total_verbose(components),
            self.group_element_year_2.relative_credits
            or self.group_element_year_2.child_leaf.credits or 0,
            _("credits"),
        )
        self.assertEqual(self.group_element_year_2.verbose, verbose_leaf)
예제 #2
0
    def verbose(self):
        if self.child_branch:
            return _("%(title)s (%(credits)s credits)") % {
                "title": self.child.title,
                "credits": self.relative_credits or self.child_branch.credits
                or 0
            }
        else:
            components = LearningComponentYear.objects.filter(
                learningunitcomponent__learning_unit_year=self.child_leaf
            ).annotate(
                total=Case(When(hourly_volume_total_annual=None, then=0),
                           default=F('hourly_volume_total_annual'))).values(
                               'type', 'total')

            return _(
                "%(acronym)s %(title)s [%(volumes)s] (%(credits)s credits)"
            ) % {
                "acronym":
                self.child_leaf.acronym,
                "title":
                self.child.complete_title_english
                if self.child.complete_title_english
                and translation.get_language() == 'en' else
                self.child.complete_title,
                "volumes":
                volume_total_verbose(components),
                "credits":
                self.relative_credits or self.child_leaf.credits or 0
            }
예제 #3
0
    def verbose(self):
        if self.child_branch:
            return _("%(title)s (%(credits)s credits)") % {
                "title": self.child.title,
                "credits": self.relative_credits or self.child_branch.credits
                or 0
            }
        else:
            components = LearningComponentYear.objects.filter(
                learningunitcomponent__learning_unit_year=self.child_leaf)

            return _(
                "%(acronym)s %(title)s [%(volumes)s] (%(credits)s credits)"
            ) % {
                "acronym": self.child_leaf.acronym,
                "title": self.child_leaf.specific_title,
                "volumes": volume_total_verbose(components),
                "credits": self.relative_credits or self.child_leaf.credits
                or 0
            }
예제 #4
0
    def verbose(self):
        if self.child_branch:
            return self._verbose_credits()
        else:
            components = LearningComponentYear.objects.filter(
                learning_unit_year=self.child_leaf).annotate(total=Case(
                    When(hourly_volume_total_annual=None, then=0),
                    default=F('hourly_volume_total_annual'))).values(
                        'type', 'total')

            return "{} {} [{}] ({} {})".format(
                self.child_leaf.acronym,
                self.child.complete_title_english
                if self.child.complete_title_english
                and translation.get_language() == 'en' else
                self.child.complete_title,
                volume_total_verbose(components),
                self.relative_credits or self.child_leaf.credits or 0,
                _("credits"),
            )
예제 #5
0
    def verbose(self):
        if self.child_branch:
            return "{} ({} {})".format(
                self.child.title, self.relative_credits or self.child_branch.credits or 0, _("credits")
            )

        else:
            components = LearningComponentYear.objects.filter(
                learning_unit_year=self.child_leaf).annotate(
                total=Case(When(hourly_volume_total_annual=None, then=0),
                           default=F('hourly_volume_total_annual'))).values('type', 'total')

            return "{} {} [{}] ({} {})".format(
                self.child_leaf.acronym,
                self.child.complete_title_english
                if self.child.complete_title_english and translation.get_language() == 'en'
                else self.child.complete_title,
                volume_total_verbose(components),
                self.relative_credits or self.child_leaf.credits or 0,
                _("credits"),
            )
예제 #6
0
    def test_get_verbose_children(self):
        result = get_verbose_children(self.education_group_year_1)
        context_waiting = [self.group_element_year_1, [self.group_element_year_2], self.group_element_year_3,
                           [self.group_element_year_4]]
        self.assertEqual(result, context_waiting)

        verbose_branch = _("%(title)s (%(credits)s credits)") % {
            "title": self.group_element_year_1.child.title,
            "credits": self.group_element_year_1.relative_credits or self.group_element_year_1.child_branch.credits or 0
        }
        self.assertEqual(self.group_element_year_1.verbose, verbose_branch)

        components = LearningComponentYear.objects.filter(
            learningunitcomponent__learning_unit_year=self.group_element_year_2.child_leaf
        )
        verbose_leaf = _("%(acronym)s %(title)s [%(volumes)s] (%(credits)s credits)") % {
            "acronym": self.group_element_year_2.child_leaf.acronym,
            "title": self.group_element_year_2.child_leaf.specific_title,
            "volumes": volume_total_verbose(components),
            "credits": self.group_element_year_2.relative_credits or self.group_element_year_2.child_leaf.credits or 0
        }
        self.assertEqual(self.group_element_year_2.verbose, verbose_leaf)
예제 #7
0
    def test_get_verbose_children(self):
        result = get_verbose_children(self.education_group_year_1)
        context_waiting = [
            self.group_element_year_1, [self.group_element_year_2],
            self.group_element_year_3, [self.group_element_year_4]
        ]
        self.assertEqual(result, context_waiting)

        verbose_branch = _("%(title)s (%(credits)s credits)") % {
            "title":
            self.group_element_year_1.child.title,
            "credits":
            self.group_element_year_1.relative_credits
            or self.group_element_year_1.child_branch.credits or 0
        }
        self.assertEqual(self.group_element_year_1.verbose, verbose_branch)

        components = LearningComponentYear.objects.filter(
            learningunitcomponent__learning_unit_year=self.
            group_element_year_2.child_leaf).annotate(
                total=Case(When(hourly_volume_total_annual=None, then=0),
                           default=F('hourly_volume_total_annual'))).values(
                               'type', 'total')

        verbose_leaf = _(
            "%(acronym)s %(title)s [%(volumes)s] (%(credits)s credits)") % {
                "acronym":
                self.group_element_year_2.child_leaf.acronym,
                "title":
                self.group_element_year_2.child_leaf.complete_title,
                "volumes":
                volume_total_verbose(components),
                "credits":
                self.group_element_year_2.relative_credits
                or self.group_element_year_2.child_leaf.credits or 0
            }
        self.assertEqual(self.group_element_year_2.verbose, verbose_leaf)