def uwp_comp(): dsn = app.config['dsn'] page = UWP(dsn) if request.method == 'GET': return page.show_page_comp() elif 'Add' in request.form: name = request.form['Name'] surname = request.form['Surname'] country = request.form['Country'] role = request.form['Role'] if name and surname: return page.add_competitor(name, surname, country, role) else: flash("You need to enter a name and a surname!") return page.show_page_comp() elif 'Delete' in request.form: id = request.form.get('select', '') if id: return page.delete_competitor(id) else: flash( "You need to select the competitor you want to delete using the radio buttons!" ) return page.show_page_comp() elif 'Update' in request.form: id = request.form.get('select', '') name = request.form['Name'] surname = request.form['Surname'] country = request.form['Country'] role = request.form['Role'] if id and name and surname: return page.update_competitor(name, surname, country, role, id) else: if not id: flash( "You need to select the competitor you want to update using the radio buttons!" ) if not name or not surname: flash("You need to enter a name and a surname!") return page.show_page_comp() elif 'Reset' in request.form: return page.reset_table()
def uwp_comp(): dsn = app.config['dsn'] page = UWP(dsn) if request.method == 'GET': return page.show_page_comp() elif 'Add' in request.form: name = request.form['Name'] surname = request.form['Surname'] country = request.form['Country'] role = request.form['Role'] if name and surname: return page.add_competitor(name, surname, country, role) else: flash("You need to enter a name and a surname!") return page.show_page_comp() elif 'Delete' in request.form: id = request.form.get('select', '') if id: return page.delete_competitor(id) else: flash("You need to select the competitor you want to delete using the radio buttons!") return page.show_page_comp() elif 'Update' in request.form: id = request.form.get('select', '') name = request.form['Name'] surname = request.form['Surname'] country = request.form['Country'] role = request.form['Role'] if id and name and surname: return page.update_competitor(name, surname, country, role, id) else: if not id: flash("You need to select the competitor you want to update using the radio buttons!") if not name or not surname: flash("You need to enter a name and a surname!") return page.show_page_comp() elif 'Reset' in request.form: return page.reset_table()