def table(database,table): global new_table if new_table == None: new_table = client.getDataBaseByName(database).getTable(table) if request.method == 'POST': if request.form['submit_button'] == 'Back': new_table = None return redirect(url_for('database',database=database)) elif request.form['submit_button'] == 'Save': for i,row in enumerate(new_table.rows): for j,cell in enumerate(row): if str(i)+'.'+str(j) in request.form: cell.data = request.form[str(i)+'.'+str(j)] client.updateTable(database,table,new_table) new_table = None return redirect(url_for('database',database=database)) elif request.form['submit_button'] == 'Add row': for i,row in enumerate(new_table.rows): for j,cell in enumerate(row): cell.data = request.form[str(i)+'.'+str(j)] row = [] for column in new_table.columns: cell = Cell() cell.type = column.type cell.optionalInfo = column.optionalInfo row.append(cell) new_table.rows.append(row) print(new_table.__dict__) form = Form(request.form) form.table = new_table return render_template('table.html',form=form)
def newTable(): form = Form(request.form) global new_table if new_table == None: new_table = Table() if request.method == 'POST': if request.form['submit_button'] == 'Create': new_table.name = request.form['table_name'] new_database.addTable(new_table) new_table = None return redirect('/newdatabase') elif request.form['submit_button'] == 'Add column': new_table.name = request.form['table_name'] column = Column(request.form['column_header'],DataType.fromDict(request.form['column_type'])) if request.form['column_type'] == 'realinvl': column.optionalInfo = ['interval',[request.form['bottom'],request.form['top']]] new_table.addColumn(column) elif request.method == 'GET': new_table = Table() form.table = new_table return render_template('newtable.html', form=form)