Пример #1
0
    def get(self):
        """Get all relations of this record, adding any relations metadata."""
        relations = {}

        for relation_type in current_app.config["PARENT_CHILD_RELATION_TYPES"]:
            pcr = ParentChildRelation(relation_type)
            name = relation_type.name

            # self.record is a child
            for parent_pid in pcr.parents_of(self.record.pid):
                child_pid = self.record.pid
                r = self._build_child(parent_pid, child_pid, name)

                relations.setdefault(name, [])
                relations[name].append(r)

        for relation_type in current_app.config["SIBLINGS_RELATION_TYPES"]:
            sr = SiblingsRelation(relation_type)
            name = relation_type.name

            for related_pid in sr.all(self.record.pid):
                r = self._build_sibling(related_pid, name)

                relations.setdefault(name, [])
                relations[name].append(r)

        return relations
Пример #2
0
    def get(self):
        """Get all sibling relations with the current record."""
        relations = {}
        for relation_type in SIBLINGS_RELATION_TYPES:
            sr = SiblingsRelation(relation_type)
            name = relation_type.name

            for sibling_pid in sr.all(self.record.pid):
                r = self._build_relation_obj(sibling_pid, name)
                relations.setdefault(name, [])
                relations[name].append(r)
        return relations