Skip to content

Commit

Permalink
relates to #150 and #147, but I'm afraid this should go to 1.0-dev.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Frasca authored and Mario Frasca committed Aug 1, 2016
1 parent 957293b commit 2768a73
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
1 change: 1 addition & 0 deletions bauble/plugins/plants/ask_tpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def ask_tpl(binomial):
'http://www.theplantlist.org/tpl1.1/search?q=' + binomial +
'&csv=true',
timeout=self.timeout)
logger.debug(result.text)
l = result.text[1:].split('\n')
result = [row for row in csv.reader(k.encode('utf-8')
for k in l if k)]
Expand Down
63 changes: 37 additions & 26 deletions bauble/plugins/plants/species_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,33 +195,44 @@ def on_response_found(button, response):
self.species_check_messages.append(box)
msg_box_msg = None

if self.model.accepted is None and accepted:
cit = ('<i>%(Genus)s</i> %(Species hybrid marker)s'
'<i>%(Species)s</i> %(Authorship)s (%(Family)s)'
) % accepted_s
msg = _('%s is the accepted taxon for your data.\n'
'Do you want to add it?' % cit)
b2 = box = self.view.add_message_box(
utils.MESSAGE_BOX_YESNO)
box.message = msg
if self.model.accepted is None and accepted is not None:
if accepted == []: # infraspecific synonym, can't handle
msg = _('closest match is a synonym of something at '
'infraspecific rank, which I cannot handle.')
b2 = box = self.view.add_message_box(
utils.MESSAGE_BOX_INFO)
box.message = msg

def on_response_accepted(button, response):
self.view.remove_box(b2)
else:
cit = ('<i>%(Genus)s</i> %(Species hybrid marker)s'
'<i>%(Species)s</i> %(Authorship)s (%(Family)s)'
) % accepted_s
msg = _('%s is the accepted taxon for your data.\n'
'Do you want to add it?' % cit)
b2 = box = self.view.add_message_box(
utils.MESSAGE_BOX_YESNO)
box.message = msg

def on_response_accepted(button, response):
self.view.remove_box(b2)
if response:
hybrid = accepted['Species hybrid marker']
self.model.accepted = Species.retrieve_or_create(
self.session, {
'object': 'taxon',
'rank': 'species',
'ht-rank': 'genus',
'familia': accepted['Family'],
'ht-epithet': accepted['Genus'],
'epithet': accepted['Species'],
'author': accepted['Authorship'],
'hybrid_marker': hybrid}
)
self.refresh_view()
self.refresh_fullname_label()

def on_response_accepted(button, response):
self.view.remove_box(b2)
if response:
hybrid = accepted['Species hybrid marker']
self.model.accepted = Species.retrieve_or_create(
self.session, {
'object': 'taxon',
'rank': 'species',
'ht-rank': 'genus',
'familia': accepted['Family'],
'ht-epithet': accepted['Genus'],
'epithet': accepted['Species'],
'author': accepted['Authorship'],
'hybrid_marker': hybrid}
)
self.refresh_view()
self.refresh_fullname_label()
box.on_response = on_response_accepted
box.show()
self.view.add_box(box)
Expand Down

0 comments on commit 2768a73

Please sign in to comment.