add data models
This commit is contained in:
parent
7ed933da9c
commit
363c710a81
3 changed files with 70 additions and 2 deletions
35
base_data_model.py
Normal file
35
base_data_model.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import npyscreen
|
||||||
|
|
||||||
|
class base_data_model():
|
||||||
|
def __init__(self, base_data_dict):
|
||||||
|
self.base_data_dict = base_data_dict
|
||||||
|
self.forms = {}
|
||||||
|
|
||||||
|
def add_edit_fields(self, form):
|
||||||
|
base_data = self.base_data_dict
|
||||||
|
self.forms['fullname'] = form.add(npyscreen.TitleText, name="Name: ", value=base_data['fullname'])
|
||||||
|
self.forms['nickname'] = form.add(npyscreen.TitleText, name="Nickname: ",
|
||||||
|
value=base_data['nickname'])
|
||||||
|
self.forms['address_street'] = form.add(
|
||||||
|
npyscreen.TitleText, name="Adresse - Straße: ", value=base_data['address_street'])
|
||||||
|
self.forms['address_locality'] = form.add(
|
||||||
|
npyscreen.TitleText, name="Adresse - Stadt: ", value=base_data['address_locality'])
|
||||||
|
self.forms['address_code'] = form.add(npyscreen.TitleText,
|
||||||
|
name="Adresse - PLZ: ", value=base_data['address_code'])
|
||||||
|
self.forms['address_country'] = form.add(
|
||||||
|
npyscreen.TitleText, name="Adresse - Land: ", value=base_data['address_country'])
|
||||||
|
self.forms['birth_date'] = form.add(npyscreen.TitleText,
|
||||||
|
name="Geburtstag: ", value=base_data['birth_date'])
|
||||||
|
self.forms['birth_location'] = form.add(
|
||||||
|
npyscreen.TitleText, name="Geburtsort: ", value=base_data['birth_location'])
|
||||||
|
self.forms['email'] = form.add(npyscreen.TitleText,
|
||||||
|
name="email: ", value=base_data['email'])
|
||||||
|
self.forms['pgp-key'] = form.add(npyscreen.TitleText, name="URI PGP Key: ", value=base_data['pgp-key'])
|
||||||
|
self.forms['ssh-key'] = form.add(npyscreen.TitleText, name="URI SSH Key: ", value=base_data['ssh-key'])
|
||||||
|
|
||||||
|
def get_form_values_dict(self):
|
||||||
|
base_data = dict(zip(self.forms.keys(), map(lambda f: f.value, self.forms.values())))
|
||||||
|
return base_data
|
||||||
|
|
||||||
|
def has_changed(self):
|
||||||
|
return self.base_data_dict != self.get_form_values_dict()
|
25
financial_data_model.py
Normal file
25
financial_data_model.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import npyscreen
|
||||||
|
|
||||||
|
class financial_data_model():
|
||||||
|
def __init__(self, financial_data_dict):
|
||||||
|
self.financial_data_dict = financial_data_dict
|
||||||
|
self.forms = {}
|
||||||
|
|
||||||
|
def add_edit_fields(self, form):
|
||||||
|
fin = self.financial_data_dict
|
||||||
|
self.forms['iban'] = form.add(npyscreen.TitleText, name="IBAN: ", value=fin['iban'])
|
||||||
|
self.forms['bic'] = form.add(npyscreen.TitleText, name="BIC: ", value=fin['bic'])
|
||||||
|
self.forms['holder'] = form.add(npyscreen.TitleText, name="Kontoinhaber: ", value=fin['holder'])
|
||||||
|
self.forms['issuance'] = form.add(npyscreen.TitleText, name="Tag der Erteilung Lastschriftmandat: ",
|
||||||
|
value=fin['issuance'])
|
||||||
|
self.forms['reference'] = form.add(npyscreen.TitleText, name="Mandatsreferenznummer: ",
|
||||||
|
value=fin['reference'])
|
||||||
|
self.forms['scan-sepa-mandate'] = form.add(npyscreen.TitleText, name="URI Scan SEPA-Mandat: ",
|
||||||
|
value=fin['scan-sepa-mandate'])
|
||||||
|
|
||||||
|
def get_form_values_dict(self):
|
||||||
|
financial_data_model = dict(zip(self.forms.keys(), map(lambda f: f.value, self.forms.values())))
|
||||||
|
return financial_data_model
|
||||||
|
|
||||||
|
def has_changed(self):
|
||||||
|
return self.financial_data_dict != self.get_form_values_dict()
|
|
@ -1,19 +1,27 @@
|
||||||
|
import npyscreen
|
||||||
|
|
||||||
class membership_data_model():
|
class membership_data_model():
|
||||||
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
|
||||||
self.forms = {}
|
self.forms = {}
|
||||||
|
|
||||||
def add_edit_fields(self, parent_form):
|
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.TitleText, name="Status: ", value=mem['status'])
|
||||||
self.forms['von'] = parent_form.add(npyscreen.TitleText, name="Von: ", value=mem['von'])
|
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['bis'] = parent_form.add(npyscreen.TitleText, name="Bis: ", value=mem['bis'])
|
||||||
self.forms['mitgliedsbeitrag'] = parent_form.add(npyscreen.TitleText, name="Mitgliedsbeitrag: ",
|
self.forms['mitgliedsbeitrag'] = parent_form.add(npyscreen.TitleText, name="Mitgliedsbeitrag: ",
|
||||||
value=mem['mitgliedsbeitrag'])
|
value=mem['mitgliedsbeitrag'])
|
||||||
|
self.forms['spendenbeitrag'] = parent_form.add(npyscreen.TitleText, name="Spendenbeitrag: ",
|
||||||
|
value=mem['spendenbeitrag'])
|
||||||
self.forms['schliessberechtigung'] = parent_form.add(npyscreen.TitleText, name="Schliessberechtigung: ",
|
self.forms['schliessberechtigung'] = parent_form.add(npyscreen.TitleText, name="Schliessberechtigung: ",
|
||||||
value=mem['schliessberechtigung'])
|
value=mem['schliessberechtigung'])
|
||||||
self.forms['scan-antrag'] = parent_form.add(npyscreen.TitleText, name="URI Scan Antrag: ",
|
self.forms['scan-antrag'] = parent_form.add(npyscreen.TitleText, 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(app.mem2.keys(), map(lambda f: f.value, app.mem2.values())))
|
membership_data_model = dict(zip(self.forms.keys(), map(lambda f: f.value, self.forms.values())))
|
||||||
return membership_data_model
|
return membership_data_model
|
||||||
|
|
||||||
|
def has_changed(self):
|
||||||
|
return self.membership_data_dict != self.get_form_values_dict()
|
Loading…
Reference in a new issue