Merge pull request 'Add four options for schliessberechtigung' (#31) from add-schliessberechtigung-options into master
Reviewed-on: https://gitea.n39.eu/Netz39_Vorstand/stammdaten-formular/pulls/31
This commit is contained in:
commit
dae586df57
2 changed files with 28 additions and 4 deletions
|
@ -29,7 +29,10 @@
|
||||||
"bis": "",
|
"bis": "",
|
||||||
"mitgliedsbeitrag": "",
|
"mitgliedsbeitrag": "",
|
||||||
"spendenbeitrag": "",
|
"spendenbeitrag": "",
|
||||||
"schliessberechtigung": "",
|
"schliessberechtigung": [
|
||||||
|
"BLE",
|
||||||
|
"SSH"
|
||||||
|
],
|
||||||
"scan-antrag": ""
|
"scan-antrag": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@ class membership_data_model():
|
||||||
'E': 'Ermäßigt',
|
'E': 'Ermäßigt',
|
||||||
'F': 'Fördermitglied'
|
'F': 'Fördermitglied'
|
||||||
}
|
}
|
||||||
|
schliessberechtigung_values = [
|
||||||
|
'SSH',
|
||||||
|
'BLE',
|
||||||
|
'Telefon',
|
||||||
|
'Metallschluessel'
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, membership_data_dict):
|
def __init__(self, membership_data_dict):
|
||||||
self.membership_data_dict = membership_data_dict
|
self.membership_data_dict = membership_data_dict
|
||||||
|
@ -13,6 +19,12 @@ class membership_data_model():
|
||||||
|
|
||||||
def add_edit_fields(self, parent_form):
|
def add_edit_fields(self, parent_form):
|
||||||
mem = self.membership_data_dict
|
mem = self.membership_data_dict
|
||||||
|
|
||||||
|
schliessberechtigung_value = []
|
||||||
|
if 'schliessberechtigung' in mem.keys() and set(mem['schliessberechtigung']).issubset(set(self.schliessberechtigung_values)):
|
||||||
|
for entry in mem['schliessberechtigung']:
|
||||||
|
schliessberechtigung_value.append(self.schliessberechtigung_values.index(entry))
|
||||||
|
|
||||||
status_value = 0
|
status_value = 0
|
||||||
if 'status' in mem.keys() and mem['status'] in self.status_values.keys():
|
if 'status' in mem.keys() and mem['status'] in self.status_values.keys():
|
||||||
status_value = list(self.status_values.keys()).index(mem['status'])
|
status_value = list(self.status_values.keys()).index(mem['status'])
|
||||||
|
@ -27,14 +39,23 @@ class membership_data_model():
|
||||||
value=mem['mitgliedsbeitrag'])
|
value=mem['mitgliedsbeitrag'])
|
||||||
self.forms['spendenbeitrag'] = parent_form.add(npyscreen.TitleText, begin_entry_at=20, use_two_lines=False, name="Spendenbeitrag: ",
|
self.forms['spendenbeitrag'] = parent_form.add(npyscreen.TitleText, begin_entry_at=20, use_two_lines=False, name="Spendenbeitrag: ",
|
||||||
value=mem['spendenbeitrag'])
|
value=mem['spendenbeitrag'])
|
||||||
self.forms['schliessberechtigung'] = parent_form.add(npyscreen.TitleText, begin_entry_at=24, use_two_lines=False, name="Schliessberechtigung: ",
|
self.forms['schliessberechtigung'] = parent_form.add(npyscreen.TitleMultiSelect, name="Schliessberechtigung: ",
|
||||||
value=mem['schliessberechtigung'])
|
values = self.schliessberechtigung_values,
|
||||||
|
value = schliessberechtigung_value,
|
||||||
|
max_height = len(self.schliessberechtigung_values) + 1,
|
||||||
|
scroll_exit = True)
|
||||||
self.forms['scan-antrag'] = parent_form.add(npyscreen.TitleText, begin_entry_at=18, use_two_lines=False, name="URI Scan Antrag: ",
|
self.forms['scan-antrag'] = parent_form.add(npyscreen.TitleText, begin_entry_at=18, use_two_lines=False, name="URI Scan Antrag: ",
|
||||||
value=mem['scan-antrag'])
|
value=mem['scan-antrag'])
|
||||||
|
|
||||||
def get_form_values_dict(self):
|
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 = 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]]
|
membership_data_model['status'] = list(self.status_values.keys())[self.forms['status'].value[0]]
|
||||||
|
|
||||||
|
if self.forms['schliessberechtigung'].get_selected_objects() is not None:
|
||||||
|
membership_data_model['schliessberechtigung'] = list(self.forms['schliessberechtigung'].get_selected_objects())
|
||||||
|
else:
|
||||||
|
membership_data_model['schliessberechtigung'] = []
|
||||||
|
|
||||||
return membership_data_model
|
return membership_data_model
|
||||||
|
|
||||||
def has_changed(self):
|
def has_changed(self):
|
||||||
|
|
Loading…
Reference in a new issue