From cfa747978158eb4d3fe00b65f7c7a667560ab901 Mon Sep 17 00:00:00 2001 From: David Kilias Date: Thu, 26 Mar 2020 08:51:14 +0100 Subject: [PATCH 1/2] testweise Status mit SelectOne widget --- membership_data_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/membership_data_model.py b/membership_data_model.py index 800f2b2..4d1a931 100644 --- a/membership_data_model.py +++ b/membership_data_model.py @@ -7,7 +7,7 @@ class membership_data_model(): def add_edit_fields(self, parent_form): mem = self.membership_data_dict - self.forms['status'] = parent_form.add(npyscreen.TitleText, name="Status: ", value=mem['status']) + self.forms['status'] = parent_form.add(npyscreen.TitleSelectOne, name="Status: ", values=['V', 'E', 'F'], value=0, max_height=2, scroll_exit=True) self.forms['von'] = parent_form.add(npyscreen.TitleText, name="Von: ", value=mem['von']) self.forms['bis'] = parent_form.add(npyscreen.TitleText, name="Bis: ", value=mem['bis']) self.forms['mitgliedsbeitrag'] = parent_form.add(npyscreen.TitleText, name="Mitgliedsbeitrag: ", -- 2.45.2 From cf2a8ed82a723c5d18e6d23d5f40d5f6c7dae0be Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Thu, 26 Mar 2020 11:28:13 +0100 Subject: [PATCH 2/2] Status: Display long names and input value handling --- membership_data_model.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/membership_data_model.py b/membership_data_model.py index 4d1a931..f2fbae7 100644 --- a/membership_data_model.py +++ b/membership_data_model.py @@ -1,13 +1,26 @@ import npyscreen class membership_data_model(): + status_values = { + 'V': 'Vollzahler', + 'E': 'Ermäßigt', + 'F': 'Fördermitglied' + } + def __init__(self, membership_data_dict): self.membership_data_dict = membership_data_dict self.forms = {} def add_edit_fields(self, parent_form): mem = self.membership_data_dict - self.forms['status'] = parent_form.add(npyscreen.TitleSelectOne, name="Status: ", values=['V', 'E', 'F'], value=0, max_height=2, scroll_exit=True) + status_value = 0 + if 'status' in mem.keys() and mem['status'] in self.status_values.keys(): + status_value = list(self.status_values.keys()).index(mem['status']) + + self.forms['status'] = parent_form.add(npyscreen.TitleSelectOne, name="Status: ", + values=list(self.status_values.values()), + value=status_value, + max_height=3, scroll_exit=True) self.forms['von'] = parent_form.add(npyscreen.TitleText, name="Von: ", value=mem['von']) self.forms['bis'] = parent_form.add(npyscreen.TitleText, name="Bis: ", value=mem['bis']) self.forms['mitgliedsbeitrag'] = parent_form.add(npyscreen.TitleText, name="Mitgliedsbeitrag: ", @@ -21,6 +34,7 @@ class membership_data_model(): def get_form_values_dict(self): membership_data_model = dict(zip(self.forms.keys(), map(lambda f: f.value, self.forms.values()))) + membership_data_model['status'] = list(self.status_values.keys())[self.forms['status'].value[0]] return membership_data_model def has_changed(self): -- 2.45.2