2020-03-06 23:37:21 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
import npyscreen
|
|
|
|
import json
|
2020-03-14 12:40:15 +01:00
|
|
|
import datetime
|
2020-03-06 23:37:21 +01:00
|
|
|
from sys import argv
|
|
|
|
|
|
|
|
|
|
|
|
class FormApp(npyscreen.NPSAppManaged):
|
|
|
|
def __init__(self, member_struct):
|
|
|
|
super().__init__()
|
|
|
|
self.member = member_struct
|
|
|
|
|
|
|
|
def main(self):
|
|
|
|
f = npyscreen.Form(name='Edit Member data')
|
|
|
|
|
|
|
|
sd = self.member['stammdaten']
|
2020-03-10 16:00:18 +01:00
|
|
|
self.sd2 = {}
|
|
|
|
self.sd2['fullname'] = f.add(npyscreen.TitleText, name="Name: ", value=sd['fullname'])
|
|
|
|
self.sd2['nickname'] = f.add(npyscreen.TitleText, name="Nickname: ",
|
2020-03-06 23:37:21 +01:00
|
|
|
value=sd['nickname'])
|
2020-03-10 16:00:18 +01:00
|
|
|
self.sd2['address_street'] = f.add(
|
|
|
|
npyscreen.TitleText, name="Adresse - Straße: ", value=sd['address_street'])
|
|
|
|
self.sd2['address_locality'] = f.add(
|
|
|
|
npyscreen.TitleText, name="Adresse - Stadt: ", value=sd['address_locality'])
|
|
|
|
self.sd2['address_code'] = f.add(npyscreen.TitleText,
|
|
|
|
name="Adresse - PLZ: ", value=sd['address_code'])
|
|
|
|
self.sd2['address_country'] = f.add(
|
|
|
|
npyscreen.TitleText, name="Adresse - Land: ", value=sd['address_country'])
|
|
|
|
self.sd2['birth_date'] = f.add(npyscreen.TitleText,
|
|
|
|
name="Geburtstag: ", value=sd['birth_date'])
|
|
|
|
self.sd2['birth_location'] = f.add(
|
|
|
|
npyscreen.TitleText, name="Geburtsort: ", value=sd['birth_location'])
|
|
|
|
self.sd2['email'] = f.add(npyscreen.TitleText,
|
2020-03-06 23:37:21 +01:00
|
|
|
name="email: ", value=sd['email'])
|
2020-03-10 16:00:18 +01:00
|
|
|
self.sd2['pgp-key'] = f.add(npyscreen.TitleText, name="URI PGP Key: ", value=sd['pgp-key'])
|
|
|
|
self.sd2['ssh-key'] = f.add(npyscreen.TitleText, name="URI SSH Key: ", value=sd['ssh-key'])
|
2020-03-06 23:37:21 +01:00
|
|
|
|
|
|
|
fin = self.member['finanzdaten']
|
2020-03-10 16:00:18 +01:00
|
|
|
self.fin2 = {}
|
|
|
|
self.fin2['iban'] = f.add(npyscreen.TitleText, name="IBAN: ", value=fin['iban'])
|
|
|
|
self.fin2['bic'] = f.add(npyscreen.TitleText, name="BIC: ", value=fin['bic'])
|
|
|
|
self.fin2['holder'] = f.add(npyscreen.TitleText, name="Kontoinhaber: ", value=fin['holder'])
|
|
|
|
self.fin2['issuance'] = f.add(npyscreen.TitleText, name="Tag der Erteilung Lastschriftmandat: ",
|
2020-03-06 23:37:21 +01:00
|
|
|
value=fin['issuance'])
|
2020-03-10 16:00:18 +01:00
|
|
|
self.fin2['reference'] = f.add(npyscreen.TitleText, name="Mandatsreferenznummer: ",
|
2020-03-06 23:37:21 +01:00
|
|
|
value=fin['reference'])
|
2020-03-10 16:00:18 +01:00
|
|
|
self.fin2['scan-sepa-mandate'] = f.add(npyscreen.TitleText, name="URI Scan SEPA-Mandat: ",
|
2020-03-06 23:37:21 +01:00
|
|
|
value=fin['scan-sepa-mandate'])
|
|
|
|
|
|
|
|
mem = self.member['mitgliederdaten']
|
2020-03-10 16:00:18 +01:00
|
|
|
self.mem2 = {}
|
|
|
|
self.mem2['status'] = f.add(npyscreen.TitleText, name="Status: ", value=mem['status'])
|
|
|
|
self.mem2['von'] = f.add(npyscreen.TitleText, name="Von: ", value=mem['von'])
|
|
|
|
self.mem2['bis'] = f.add(npyscreen.TitleText, name="Bis: ", value=mem['bis'])
|
|
|
|
self.mem2['mitgliedsbeitrag'] = f.add(npyscreen.TitleText, name="Mitgliedsbeitrag: ",
|
2020-03-06 23:37:21 +01:00
|
|
|
value=mem['mitgliedsbeitrag'])
|
2020-03-10 16:00:18 +01:00
|
|
|
self.mem2['schliessberechtigung'] = f.add(npyscreen.TitleText, name="Schliessberechtigung: ",
|
2020-03-06 23:37:21 +01:00
|
|
|
value=mem['schliessberechtigung'])
|
2020-03-10 16:00:18 +01:00
|
|
|
self.mem2['scan-antrag'] = f.add(npyscreen.TitleText, name="URI Scan Antrag: ",
|
2020-03-06 23:37:21 +01:00
|
|
|
value=mem['scan-antrag'])
|
|
|
|
|
|
|
|
f.edit()
|
|
|
|
|
|
|
|
|
|
|
|
def main(*_args):
|
|
|
|
if len(argv) > 1:
|
|
|
|
member_struct = json.load(open(argv[1], 'r'))
|
|
|
|
else:
|
|
|
|
member_struct = json.load(open('example.json', 'r'))
|
|
|
|
app = FormApp(member_struct)
|
|
|
|
app.run()
|
2020-03-10 16:00:18 +01:00
|
|
|
new_data = {}
|
|
|
|
new_data['stammdaten'] = dict(zip(app.sd2.keys(), map(lambda f: f.value, app.sd2.values())))
|
|
|
|
new_data['finanzdaten'] = dict(zip(app.fin2.keys(), map(lambda f: f.value, app.fin2.values())))
|
|
|
|
new_data['mitgliederdaten'] = dict(zip(app.mem2.keys(), map(lambda f: f.value, app.mem2.values())))
|
2020-03-14 12:40:15 +01:00
|
|
|
new_data['timestamp'] = datetime.datetime.now().replace(microsecond=0).isoformat()
|
2020-03-14 11:01:19 +01:00
|
|
|
|
2020-03-14 13:03:17 +01:00
|
|
|
outfile_name = '{}_{}.json'.format('_'.join(new_data['stammdaten']['fullname'].split()),datetime.datetime.now().replace(microsecond=0).isoformat())
|
2020-03-10 16:11:51 +01:00
|
|
|
with open(outfile_name, 'w') as outfile:
|
2020-03-10 16:00:18 +01:00
|
|
|
json.dump(new_data, outfile, sort_keys=True, indent=4)
|
2020-03-06 23:37:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
npyscreen.wrapper_basic(main)
|