Renew membership implementation + Multiple fixes.
This commit is contained in:
parent
a1beec5cd1
commit
5d76b1f584
35
IFPass.py
35
IFPass.py
@ -112,7 +112,7 @@ def get_fullname(**kwargs): # **kwargs => Optionnal arguments
|
||||
|
||||
if 'surname' in kwargs:
|
||||
surname = kwargs['surname']
|
||||
newsurname = input("Prénom (" + surname + "): ").strip()
|
||||
newsurname = input("Nom (" + surname + "): ").strip()
|
||||
if len(newsurname) != 0:
|
||||
surname = newsurname
|
||||
else:
|
||||
@ -236,6 +236,7 @@ def writeindb(titre, firstname, surname, clientID, dateinsc, dateexp, new):
|
||||
changewith = ";".join([titre, firstname, surname, clientID, dateinsc, dateexp]) + '\n'
|
||||
content.insert(tochange, changewith)
|
||||
content = "".join(content)
|
||||
csvfile.seek(0)
|
||||
csvfile.truncate(0)
|
||||
csvfile.write(content)
|
||||
|
||||
@ -355,7 +356,7 @@ def newmember():
|
||||
def membersearch():
|
||||
with open(clientsfile, 'r', newline='', encoding='utf-8') as csvfile:
|
||||
reader = csv.reader(csvfile, delimiter=';')
|
||||
csvlist = list(map(tuple, reader))
|
||||
csvlist = list(map(list, reader))
|
||||
del csvlist[0] # We dele the first line (Prénom, Nom...)
|
||||
research = input('Entrez une partie du nom, prénom, ou numéro de carte (ou flashez) : ').lower()
|
||||
os.system('cls')
|
||||
@ -405,7 +406,13 @@ def membersearch():
|
||||
|
||||
print('\n1 - Modifier', "2 - Renouveller l'abonnement", '3 - Imprimer la carte', '0 - Menu principal', sep='\n')
|
||||
choix = input('Choix : ')
|
||||
memberdo(choix, member)
|
||||
if choix == '0':
|
||||
os.system('cls')
|
||||
return
|
||||
# We update values with new (edited) values :
|
||||
newtitre, newfirstname, newsurname, newdateexp = memberdo(choix, member)
|
||||
member[0], member[1], member[2], member[5] = newtitre, newfirstname, newsurname, newdateexp
|
||||
|
||||
else:
|
||||
print(colored("Aucun membre n'a été trouvé.", 'red', attrs=['bold']))
|
||||
os.system("pause")
|
||||
@ -424,15 +431,16 @@ def memberdo(choix, member):
|
||||
while "the informations are incorrect": # Loop Filling informations
|
||||
titre, firstname, surname, titrename = get_fullname(titre=titre, firstname=firstname, surname=surname)
|
||||
|
||||
os.system('cls')
|
||||
print("Titre : ", colored(titre, 'green'))
|
||||
print("Prénom : ", colored(firstname, 'green'))
|
||||
print("Nom : ", colored(surname, 'green'))
|
||||
|
||||
correct = yes_or_no("Ces informations sont elles correctes ?")
|
||||
os.system('cls')
|
||||
|
||||
if correct:
|
||||
wantnewpic = yes_or_no("Voulez-vous prendre une nouvelle photo ?")
|
||||
os.system('cls')
|
||||
if wantnewpic:
|
||||
os.system('cls')
|
||||
if version != 'devnocam':
|
||||
@ -455,17 +463,28 @@ def memberdo(choix, member):
|
||||
bkpdb()
|
||||
printcard(cartefilename)
|
||||
writeindb(titre, firstname, surname, clientID, dateinsc, dateexp, new=False)
|
||||
os.system('cls')
|
||||
break
|
||||
|
||||
elif choix == '2': # Renew subscription
|
||||
print(2)
|
||||
dateexp = datetime.strptime(dateexp, '%d/%m/%Y').date()
|
||||
diff = (dateexp - date.today()).days
|
||||
if diff >= 0:
|
||||
dateexp = dateexp + timedelta(days=365)
|
||||
elif diff < 0:
|
||||
dateexp = date.today() + timedelta(days=365)
|
||||
dateexp = dateexp.strftime('%d/%m/%Y')
|
||||
if version not in ('dev', 'devnocam'):
|
||||
bkpdb()
|
||||
printcard(cartefilename)
|
||||
writeindb(titre, firstname, surname, clientID, dateinsc, dateexp, new=False)
|
||||
print(colored("La date d'expiration a bien été mise à jour !\n", 'blue', attrs=['bold']))
|
||||
|
||||
elif choix == '3': # Print card
|
||||
print('Print card')
|
||||
elif choix == '0': # Menu
|
||||
return
|
||||
else:
|
||||
os.system('cls')
|
||||
print(colored('Choix incorrect !\n', 'red', attrs=['bold']))
|
||||
return titre, firstname, surname, dateexp
|
||||
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user