diff --git a/base_data_model.py b/base_data_model.py new file mode 100644 index 0000000..1951e77 --- /dev/null +++ b/base_data_model.py @@ -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() \ No newline at end of file diff --git a/financial_data_model.py b/financial_data_model.py new file mode 100644 index 0000000..3773b90 --- /dev/null +++ b/financial_data_model.py @@ -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() \ No newline at end of file diff --git a/membership_data_model.py b/membership_data_model.py index e9c8fec..800f2b2 100644 --- a/membership_data_model.py +++ b/membership_data_model.py @@ -1,19 +1,27 @@ +import npyscreen + class membership_data_model(): 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.TitleText, name="Status: ", value=mem['status']) 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: ", 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: ", value=mem['schliessberechtigung']) self.forms['scan-antrag'] = parent_form.add(npyscreen.TitleText, name="URI Scan Antrag: ", value=mem['scan-antrag']) def get_form_values_dict(self): - membership_data_model = dict(zip(app.mem2.keys(), map(lambda f: f.value, app.mem2.values()))) - return membership_data_model \ No newline at end of file + membership_data_model = dict(zip(self.forms.keys(), map(lambda f: f.value, self.forms.values()))) + return membership_data_model + + def has_changed(self): + return self.membership_data_dict != self.get_form_values_dict() \ No newline at end of file