Ejemplo n.º 1
0
    def verify_requireds(self, discipline):
        """
        Verify if discipline in the list is required of specific discipline.
        """

        # is Required Of
        disciplines = Disciplines.get_requireds(discipline.uri)

        slug = self.kwargs.get('discipline', '')

        for discipline in disciplines:
            if discipline.slug == slug:
                return False

        requireds = Disciplines.get_requireds(self.get_object().uri)

        for required in requireds:
            if required.slug == discipline.slug:
                return False

        return True
Ejemplo n.º 2
0
    def get_required(self):
        """
        Get the specific required discipline.
        """

        discipline = self.get_object()

        requireds = Disciplines.get_requireds(discipline.uri)

        slug = self.kwargs.get('required', '')

        for required in requireds:
            if required.slug == slug:
                return required

        return None
Ejemplo n.º 3
0
    def get_context_data(self, **kwargs):
        """
        Get discipline to specific semestes.
        """

        context = super(DisciplineDetailView, self).get_context_data(**kwargs)

        discipline = self.get_object()

        context['are_requireds_of'] = Disciplines.get_is_required_of(
            discipline.uri)

        context['requireds'] = Disciplines.get_requireds(discipline.uri)

        context['program'] = Disciplines.get_contents(discipline.uri)

        return context
Ejemplo n.º 4
0
    def remove_requireds(self):
        """
        Remove all requireds discipline from discipline.
        """

        discipline = self.get_object()

        requireds = Disciplines.get_requireds(discipline.uri)

        if requireds:
            for required in requireds:
                query = """
                    PREFIX pp: <http://www.semanticweb.org/ontologies/2018/Pedagogical_Project/>
                    DELETE {
                        <%s> pp:hasRequired <%s> .
                        <%s> pp:isRequiredOf <%s>
                    } WHERE {}
                """ % (discipline.uri, required.uri, required.uri,
                       discipline.uri)

                Query.update(query)