def edit_register(email_): if request.method == 'POST' and 'edit' in request.form: user = Database.find_one_by('participants', {"email": email_}) full_name = user['full_name'] email = email_ password = user['password'] tickets_amount = request.form['tickets_amount'] mat, instrument, food, camp = False, False, False, False if request.form.get('mat'): mat = request.form.get('mat') if request.form.get('instrument'): instrument = request.form.get('instrument') if request.form.get('food'): food = request.form.get('food') if request.form.get('camp'): camp = request.form.get('camp') items = Users.toJson(full_name, email, password, tickets_amount, mat, instrument, food, camp) Database.update('participants', {"email": email}, items) return render_template('user/confirm_editing.html', name=full_name, email=email) elif request.method == 'POST': email = request.form['email'] password = request.form['password'] if Database.find_one_by('participants', {"email": email}) is None: return render_template('user/unsuccessful_register.html', message='דואר אלקטרוני זה אינו קיים במערכת', url='edit_register', email_='$') if not Users.login_valid(email, password): return render_template('user/unsuccessful_register.html', message='סיסמא שגויה', url='edit_register', email_='$') user = Database.find_one_by('participants', {"email": email}) return render_template('user/edit_registration.html', email_=email, user=user) else: return render_template('user/edit_registration.html', email_='$')
def cancel_register(): if request.method == 'POST': email = request.form['email'] password = request.form['password'] if Database.find_one_by('participants', {"email": email}) is None: return render_template('user/unsuccessful_register.html', message='דואר אלקטרוני זה אינו קיים במערכת', url='cancel_register') if not Users.login_valid(email, password): return render_template('user/unsuccessful_register.html', message='סיסמא שגויה', url='cancel_register') Database.remove('participants', {"email": email}) return render_template('user/confirm_cancelation.html') else: return render_template('user/cancel_registration.html')