diff --git a/bauble/plugins/plants/genus.py b/bauble/plugins/plants/genus.py index 42d62165f..626ec3c2b 100755 --- a/bauble/plugins/plants/genus.py +++ b/bauble/plugins/plants/genus.py @@ -149,7 +149,8 @@ class Genus(db.Base, db.Serializable, db.WithNotes): def search_view_markup_pair(self): '''provide the two lines describing object for SearchView row. ''' - return utils.xml_safe(self), utils.xml_safe(self.family) + return utils.xml_safe(self.str(use_hybrid_marker=True), + utils.xml_safe(self.family)) @property def cites(self): @@ -214,16 +215,17 @@ def accepted(self, value): def __repr__(self): return self.str() - def str(self, author=False): + def str(self, author=False, use_hybrid_marker=False): # string representation of genus, good for markup. + prepend = use_hybrid_marker and self.hybrid_marker or '' if self.epithet is None: return repr(self) elif not author or self.author is None: - return (self.hybrid_marker + + return (prepend + ' '.join([s for s in [self.epithet, self.aggregate] if s not in ('', None)])) else: - return (self.hybrid_marker + + return (prepend + ' '.join( [s for s in [self.epithet, self.aggregate, xml.sax.saxutils.escape(self.author)] @@ -860,7 +862,8 @@ def update(self, row): session = object_session(row) self.current_obj = row self.widget_set_value('gen_name_data', '%s %s' % - (row, utils.xml_safe(unicode(row.author))), + (row.str(use_hybrid_marker=True), + utils.xml_safe(unicode(row.author))), markup=True) self.widget_set_value('gen_fam_data', (utils.xml_safe(unicode(row.family)))) diff --git a/bauble/plugins/plants/species.py b/bauble/plugins/plants/species.py index e176a26d1..c2550ec52 100755 --- a/bauble/plugins/plants/species.py +++ b/bauble/plugins/plants/species.py @@ -323,7 +323,7 @@ def update(self, row): self.widgets.sp_fam_data, on_label_clicked, row.genus.family) # link to genus self.widget_set_value('sp_gen_data', '%s' % - row.genus.epithet, markup=True) + row.genus.str(use_hybrid_marker=True), markup=True) utils.make_label_clickable( self.widgets.sp_gen_data, on_label_clicked, row.genus) # epithet (full binomial but missing genus) diff --git a/bauble/plugins/plants/species_model.py b/bauble/plugins/plants/species_model.py index 66569ba33..b38f35d21 100755 --- a/bauble/plugins/plants/species_model.py +++ b/bauble/plugins/plants/species_model.py @@ -377,7 +377,7 @@ def str(self, authors=False, markup=False, remove_zws=False, genus=True, # since it won't be able to look up the genus....we could # probably try to query the genus directly with the genus_id if genus is True: - genus = self.genus.str(author=False) + genus = self.genus.str(author=False, use_hybrid_marker=True) else: genus = '' if self.epithet and not remove_zws: diff --git a/bauble/plugins/plants/test.py b/bauble/plugins/plants/test.py index 6833de0a3..3d41b5160 100644 --- a/bauble/plugins/plants/test.py +++ b/bauble/plugins/plants/test.py @@ -540,6 +540,7 @@ def test_genus_str_plain(self): genus = Genus(family=f, epithet=u'Crataegus', author='L.', hybrid_marker='') self.assertEquals(genus.str(), 'Crataegus') + self.assertEquals(genus.str(use_hybrid_marker=True), 'Crataegus') self.assertEquals(genus.str(author=True), 'Crataegus L.') @@ -547,16 +548,26 @@ def test_genus_str_nothotaxon(self): f = Family(epithet=u'Rosaceae') genus = Genus(family=f, epithet=u"Cratae-Mespilus", author="E.G.Camus", hybrid_marker="×") - self.assertEquals(genus.str(), '×Cratae-Mespilus') - self.assertEquals(genus.str(author=True), - '×Cratae-Mespilus E.G.Camus') + self.assertEquals( + genus.str(), 'Cratae-Mespilus') + self.assertEquals( + genus.str(use_hybrid_marker=True), '×Cratae-Mespilus') + self.assertEquals( + genus.str(author=True), 'Cratae-Mespilus E.G.Camus') + self.assertEquals( + genus.str(author=True, use_hybrid_marker=True), + '×Cratae-Mespilus E.G.Camus') def test_genus_str_graft_chimera(self): f = Family(epithet=u'Rosaceae') genus = Genus(family=f, epithet=u'Crataegomespilus', author="Simon-Louis & Bellair", hybrid_marker="+") - self.assertEquals(genus.str(), '+Crataegomespilus') + self.assertEquals(genus.str(), 'Crataegomespilus') + self.assertEquals( + genus.str(use_hybrid_marker=True), '+Crataegomespilus') self.assertEquals(genus.str(author=True), + 'Crataegomespilus Simon-Louis & Bellair') + self.assertEquals(genus.str(use_hybrid_marker=True, author=True), '+Crataegomespilus Simon-Louis & Bellair') def test_synonyms(self):