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