Edit member ongoing

This commit is contained in:
Jordan ERNST 2019-02-28 09:25:06 +01:00
parent 0ce5ed334c
commit d651a4973a

View File

@ -85,7 +85,13 @@ def initialisation():
return IFPassDBdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, templatesdir, pdftemplate, pngtemplate, fonttemplate
def get_fullname():
def get_fullname(**kwargs): # **kwargs => Optionnal arguments
if 'firstname' in kwargs:
firstname = kwargs['firstname']
newfirstname = input("Prénom (" + firstname + "): ").strip()
if len(newfirstname) != 0:
firstname = newfirstname
else:
while "Empty firstname":
firstname = input("Prénom : ").strip()
if len(firstname) == 0:
@ -102,6 +108,13 @@ def get_fullname():
pos = firstname.find(" ")
firstname = firstname[:pos + 1] + firstname[pos + 1].upper() + \
firstname[pos + 2:] # Check if compound name
if 'surname' in kwargs:
surname = kwargs['surname']
newsurname = input("Prénom (" + surname + "): ").strip()
if len(newsurname) != 0:
surname = newsurname
else:
while "Empty surname":
surname = input("Nom : ").upper().strip()
if len(surname) == 0:
@ -213,7 +226,7 @@ def bkpdb():
copyfile(clientsfile, clientsbkpfile)
def fillcard(clientID, titrename, firstname, dateexp, barcode):
def fillcard(clientID, titrename, firstname, dateexp, barcode, picture):
print("Création de la carte avec les informations...", end='')
try:
im = Image.open(pngtemplate)
@ -307,11 +320,10 @@ def newmember():
if correct:
os.system('cls')
if version != 'devnocam':
global picture
picture = getpic()
clientID = getclientID()
barcode = barcode_gen(clientID)
fillcard(clientID, titrename, firstname, dateexp, barcode)
fillcard(clientID, titrename, firstname, dateexp, barcode, picture)
cartefilename = mergepdf(clientID)
if version not in ('dev', 'devnocam'):
bkpdb()
@ -382,10 +394,14 @@ def membersearch():
def memberdo(choix, member):
titre = member[0]
firstname = member[1]
surname = member[2]
clientID = member[3]
dateinsc = member[4]
dateexp = member[5]
os.system('cls')
if choix == '1': # Edit member
while "the informations are incorrect": # Loop Filling informations
titre, firstname, surname, titrename = get_fullname()
titre, firstname, surname, titrename = get_fullname(titre=titre, firstname=firstname, surname=surname)
os.system('cls')
print("Titre : ", colored(titre, 'green'))
@ -395,20 +411,23 @@ def memberdo(choix, member):
correct = yes_or_no("Ces informations sont elles correctes ?")
if correct:
newpic = yes_or_no("Voulez-vous prendre une nouvelle photo ?")
if newpic:
wantnewpic = yes_or_no("Voulez-vous prendre une nouvelle photo ?")
if wantnewpic:
os.system('cls')
if version != 'devnocam':
global picture
picture = getpic()
clientID = member[3]
barcode = barcode_gen(clientID)
fillcard(barcode)
fillcard(clientID, titrename, firstname, dateexp, barcode, picture)
cartefilename = mergepdf()
if version not in ('dev', 'devnocam'):
bkpdb()
printcard(cartefilename)
writeindb(titre, firstname, surname, clientID, dateinsc, dateexp)
break
else:
# We crop pic from the previous card
pass
elif choix == '2': # Renew subscription
print(2)
@ -422,7 +441,6 @@ def memberdo(choix, member):
def main():
# global titre, firstname, surname, titrename, dateinsc, dateexp, clientID, clientsfile, IFPassDBdir, clientsfile, imgdir, clientsbkpfile, templatesdir, pngtemplate, fonttemplate, picture, pdftemplate, printername, AcrobatReader
global IFPassDBdir, clientsfile, imgdir, clientsbkpfile, templatesdir, pngtemplate, fonttemplate, pdftemplate, printername, AcrobatReader
while "The program is running":
init() # Initialisation of colorama