all pit stops can now be edited and deleted
not only the last pit stop can be edited and deleted.
This commit is contained in:
@@ -135,7 +135,13 @@ def edit_pit_stop_form(pid):
|
||||
|
||||
form = EditPitstopForm()
|
||||
form.set_pitstop(last_pitstop)
|
||||
|
||||
data = get_event_line_for_vehicle(vehicle)
|
||||
form.set_pitstops(data)
|
||||
if not form.is_submitted():
|
||||
form.odometer.default = edit_pitstop.odometer
|
||||
form.litres.default = edit_pitstop.amount
|
||||
form.date.default = edit_pitstop.date
|
||||
form.costs.default = edit_pitstop.costs
|
||||
if form.validate_on_submit():
|
||||
edit_pitstop.costs = form.costs.data
|
||||
edit_pitstop.date = form.date.data
|
||||
@@ -145,18 +151,9 @@ def edit_pit_stop_form(pid):
|
||||
db_log_update(edit_pitstop)
|
||||
return redirect(url_for('get_pit_stops', _anchor='v' + str(vehicle.id)))
|
||||
|
||||
form.odometer.default = edit_pitstop.odometer
|
||||
form.litres.default = edit_pitstop.amount
|
||||
form.date.default = edit_pitstop.date
|
||||
form.costs.default = edit_pitstop.costs
|
||||
form.preinit_with_data()
|
||||
form.process()
|
||||
messages = {
|
||||
'date': 'Date must be between %s and %s (including).' % (str(last_pitstop.date), str(date.today())),
|
||||
'odometer': 'Odometer must be greater than %s km.' % (str(last_pitstop.odometer))
|
||||
}
|
||||
if edit_pitstop.costs is not None and edit_pitstop.costs > 0:
|
||||
messages['costs'] = 'Costs must be higher than 0.01 €.'
|
||||
return render_template('editPitStopForm.html', form=form, vehicle=vehicle, messages=messages)
|
||||
return render_template('editPitStopForm.html', form=form, vehicle=vehicle, messages=form.get_hint_messages())
|
||||
|
||||
|
||||
@app.route('/pitstops', methods=['GET'])
|
||||
|
||||
Reference in New Issue
Block a user