2020-03-14 15:03:37 +01:00
|
|
|
import npyscreen
|
|
|
|
|
2020-03-14 13:16:36 +01:00
|
|
|
class membership_data_model():
|
2020-03-26 11:28:13 +01:00
|
|
|
status_values = {
|
|
|
|
'V': 'Vollzahler',
|
|
|
|
'E': 'Ermäßigt',
|
|
|
|
'F': 'Fördermitglied'
|
|
|
|
}
|
|
|
|
|
2020-03-14 13:16:36 +01:00
|
|
|
def __init__(self, membership_data_dict):
|
|
|
|
self.membership_data_dict = membership_data_dict
|
|
|
|
self.forms = {}
|
|
|
|
|
|
|
|
def add_edit_fields(self, parent_form):
|
2020-03-14 15:03:37 +01:00
|
|
|
mem = self.membership_data_dict
|
2020-03-26 11:28:13 +01:00
|
|
|
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)
|
2020-03-14 13:16:36 +01:00
|
|
|
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'])
|
2020-10-22 11:26:39 +02:00
|
|
|
self.forms['mitgliedsbeitrag'] = parent_form.add(npyscreen.TitleText, begin_entry_at=20, use_two_lines=False, name="Mitgliedsbeitrag: ",
|
2020-03-14 13:16:36 +01:00
|
|
|
value=mem['mitgliedsbeitrag'])
|
2020-10-22 11:26:39 +02:00
|
|
|
self.forms['spendenbeitrag'] = parent_form.add(npyscreen.TitleText, begin_entry_at=20, use_two_lines=False, name="Spendenbeitrag: ",
|
2020-03-14 15:03:37 +01:00
|
|
|
value=mem['spendenbeitrag'])
|
2022-10-24 23:51:43 +02:00
|
|
|
self.forms['schliessberechtigung'] = parent_form.add(npyscreen.TitleText, begin_entry_at=24, use_two_lines=False, name="Schliessberechtigung: ",
|
|
|
|
value=mem['schliessberechtigung'])
|
2020-10-22 11:26:39 +02:00
|
|
|
self.forms['scan-antrag'] = parent_form.add(npyscreen.TitleText, begin_entry_at=18, use_two_lines=False, name="URI Scan Antrag: ",
|
2020-03-14 13:16:36 +01:00
|
|
|
value=mem['scan-antrag'])
|
|
|
|
|
|
|
|
def get_form_values_dict(self):
|
2020-03-14 15:03:37 +01:00
|
|
|
membership_data_model = dict(zip(self.forms.keys(), map(lambda f: f.value, self.forms.values())))
|
2020-03-26 11:28:13 +01:00
|
|
|
membership_data_model['status'] = list(self.status_values.keys())[self.forms['status'].value[0]]
|
2020-03-14 15:03:37 +01:00
|
|
|
return membership_data_model
|
|
|
|
|
|
|
|
def has_changed(self):
|
|
|
|
return self.membership_data_dict != self.get_form_values_dict()
|