From a40c370ee8e4bb9456593db987c413aa6f6cbcb1 Mon Sep 17 00:00:00 2001 From: Mario Frasca Date: Thu, 28 Jan 2016 14:53:18 -0500 Subject: [PATCH] very minimal presenter, and it still does not save anything. related to Bauble/bauble.classic#59 --- bauble/plugins/garden/acc_editor.glade | 290 ++++++++++++++----------- bauble/plugins/garden/accession.py | 31 +++ 2 files changed, 194 insertions(+), 127 deletions(-) diff --git a/bauble/plugins/garden/acc_editor.glade b/bauble/plugins/garden/acc_editor.glade index 9e530fbea..7b5739c19 100644 --- a/bauble/plugins/garden/acc_editor.glade +++ b/bauble/plugins/garden/acc_editor.glade @@ -8,6 +8,123 @@ + + 360 + 240 + False + 5 + Accession Code Formats + dialog + + + True + False + 2 + + + True + False + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + True + 0 + + + + + True + True + 1 + automatic + automatic + in + + + 180 + True + True + acc_codes_liststore + + + item + + + + 0 + + + + + + + accession code format + + + True + + + + 1 + + + + + + + + + True + True + 1 + + + + + + button2 + button1 + + + + + + + + + + False Accession Editor @@ -333,7 +450,7 @@ True False - gtk-add + gtk-new False @@ -696,21 +813,53 @@ - + True False - acc_code_format_liststore - 0 - - - + + + True False - - False - False - True - True + acc_code_format_liststore + 0 + + + + False + + False + False + True + True + + + + True + True + 0 + + + + + True + True + True + False + + + + True + False + gtk-edit + + + + + False + True + 1 + @@ -830,7 +979,7 @@ True False - gtk-add + gtk-new False @@ -927,7 +1076,7 @@ True False - gtk-add + gtk-new False @@ -2835,119 +2984,6 @@ - - False - 5 - Accession Code Formats - dialog - - - True - False - 2 - - - True - False - end - - - gtk-cancel - True - True - True - False - True - - - False - False - 0 - - - - - gtk-ok - True - True - True - False - True - - - False - False - 1 - - - - - True - True - 0 - - - - - True - True - 1 - automatic - automatic - in - - - True - True - liststore1 - - - item - - - - 0 - - - - - - - accession code format - - - - - - 1 - - - - - - - - - True - True - 1 - - - - - - button2 - button1 - - - - - - - - - - False 5 diff --git a/bauble/plugins/garden/accession.py b/bauble/plugins/garden/accession.py index 990831306..95f742290 100755 --- a/bauble/plugins/garden/accession.py +++ b/bauble/plugins/garden/accession.py @@ -1936,6 +1936,37 @@ def on_acc_code_format_comboentry_changed(self, widget, *args): code = Accession.get_next_code(code_format) self.view.widget_set_value('acc_code_entry', code) + def on_acc_code_format_edit_btn_clicked(self, widget, *args): + view = editor.GenericEditorView( + os.path.join(paths.lib_dir(), 'plugins', 'garden', + 'acc_editor.glade'), + root_widget_name='acc_codes_dialog') + ls = view.widgets.acc_codes_liststore + ls.clear() + query = self.session.\ + query(meta.BaubleMeta).\ + filter(meta.BaubleMeta.name.like(u'acidf_%')).\ + order_by(meta.BaubleMeta.name) + for i, row in enumerate(query): + ls.append([i+1, row.value]) + ls.append([len(ls)+1, '']) + + class Presenter(editor.GenericEditorPresenter): + def on_acc_cf_renderer_edited(self, widget, iter, value): + i = ls.get_iter_from_string(str(iter)) + ls.set_value(i, 1, value) + if ls.iter_next(i) is None: + if value: + ls.append([len(ls)+1, '']) + elif value == '': + ls.remove(i) + while i: + ls.set_value(i, 0, ls.get_value(i, 0)-1) + i = ls.iter_next(i) + + presenter = Presenter(ls, view) + presenter.start() # does not save them yet + def refresh_id_qual_rank_combo(self): """ Populate the id_qual_rank_combo with the parts of the species string