add id handling & creation to data_form #27
2 changed files with 12 additions and 0 deletions
|
@ -10,6 +10,7 @@ import pathlib
|
|||
from base_data_model import base_data_model
|
||||
from financial_data_model import financial_data_model
|
||||
from membership_data_model import membership_data_model
|
||||
from id import new_id
|
||||
|
||||
|
||||
class FormApp(npyscreen.NPSAppManaged):
|
||||
|
@ -38,6 +39,10 @@ class FormApp(npyscreen.NPSAppManaged):
|
|||
data_dict['finanzdaten'] = self.financial_data.get_form_values_dict()
|
||||
data_dict['mitgliederdaten'] = self.membership_data.get_form_values_dict()
|
||||
data_dict['timestamp'] = datetime.datetime.now().replace(microsecond=0).isoformat()
|
||||
try:
|
||||
data_dict['id'] = self.member['id']
|
||||
except KeyError:
|
||||
data_dict['id'] = new_id()
|
||||
return data_dict
|
||||
|
||||
def data_has_changed(self):
|
||||
|
|
7
id.py
Normal file
7
id.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
import datetime
|
||||
import hashlib
|
||||
|
||||
def new_id():
|
||||
h = hashlib.md5()
|
||||
h.update(datetime.datetime.now().isoformat().encode())
|
||||
return h.hexdigest()[-5:]
|
Loading…
Reference in a new issue