Ejemplo n.º 1
0
    def _add_fts(
        self,
        item: "c2cgeoportal_commons.models.main.TreeItem",
        interface: "c2cgeoportal_commons.models.main.Interface",
        action: str,
        role: Optional["c2cgeoportal_commons.models.main.Role"],
    ) -> None:
        from c2cgeoportal_commons.models.main import FullTextSearch  # pylint: disable=import-outside-toplevel

        key = (
            item.name if self.options.name else item.id,
            interface.id,
            role.id if role is not None else None,
        )
        if key not in self.imported:
            self.imported.add(key)
            for lang in self.languages:
                fts = FullTextSearch()
                fts.label = self._[lang].gettext(item.name)
                fts.role = role
                fts.interface = interface
                fts.lang = lang
                fts.public = role is None
                fts.ts = func.to_tsvector(
                    self.fts_languages[lang],
                    " ".join(
                        [self.fts_normalizer(self._[lang].gettext(item.name))]
                        + [v.strip() for m in item.get_metadatas("searchAlias") for v in m.value.split(",")]
                    ),
                )
                fts.actions = [{"action": action, "data": item.name}]
                fts.from_theme = True
                self.session.add(fts)
Ejemplo n.º 2
0
    def _add_fts(self, item, interface, action, role):
        from c2cgeoportal_commons.models.main import FullTextSearch

        key = (item.name if self.options.name else item.id, interface.id,
               role.id if role is not None else None)
        if key not in self.imported:
            self.imported.add(key)
            for lang in self.languages:
                fts = FullTextSearch()
                fts.label = self._unicode_str(self._[lang].gettext(item.name))
                fts.role = role
                fts.interface = interface
                fts.lang = lang
                fts.public = role is None
                fts.ts = func.to_tsvector(self.fts_languages[lang], fts.label)
                fts.actions = [{
                    "action": action,
                    "data": item.name,
                }]
                fts.from_theme = True
                self.session.add(fts)
Ejemplo n.º 3
0
    def _add_fts(self, item, interface, action, role):
        from c2cgeoportal_commons.models.main import FullTextSearch

        key = (
            item.name if self.options.name else item.id,
            interface.id,
            role.id if role is not None else None
        )
        if key not in self.imported:
            self.imported.add(key)
            for lang in self.languages:
                fts = FullTextSearch()
                fts.label = self._[lang].gettext(item.name)
                fts.role = role
                fts.interface = interface
                fts.lang = lang
                fts.public = role is None
                fts.ts = func.to_tsvector(self.fts_languages[lang], fts.label)
                fts.actions = [{
                    "action": action,
                    "data": item.name,
                }]
                fts.from_theme = True
                self.session.add(fts)