Exemplo n.º 1
0
 def on_add_button_clicked(self, button, data=None):
     """
     Add the values in the entries to the model.
     """
     treemodel = self.treeview.get_model()
     column = self.treeview.get_column(0)
     vn = VernacularName()
     self.model.vernacular_names.append(vn)
     treeiter = treemodel.append([vn])
     path = treemodel.get_path(treeiter)
     self.treeview.set_cursor(path, column, start_editing=True)
     if len(treemodel) == 1:
         #self.set_model_attr('default_vernacular_name', vn)
         self.model.default_vernacular_name = vn
Exemplo n.º 2
0
    def test_search_by_query_vernacural(self):
        """can find species by vernacular name"""

        Family = self.Family
        Genus = self.Genus
        from bauble.plugins.plants.species_model import Species
        from bauble.plugins.plants.species_model import VernacularName
        family2 = Family(epithet=u'family2')
        g2 = Genus(family=family2, epithet=u'genus2')
        f3 = Family(epithet=u'fam3', aggregate=u'agg.')
        g3 = Genus(family=f3, epithet=u'Ixora')
        sp = Species(epithet=u"coccinea", genus=g3)
        vn = VernacularName(name=u"coral rojo", language=u"es", species=sp)
        self.session.add_all([family2, g2, f3, g3, sp, vn])
        self.session.commit()

        mapper_search = search.get_strategy('MapperSearch')
        self.assertTrue(isinstance(mapper_search, search.MapperSearch))

        s = "rojo"
        results = mapper_search.search(s, self.session)
        self.assertEqual(results, set([sp]))