Merge branch 'development' into 'selenium_tests'

Sync Development to selenium tests



See merge request !27
This commit is contained in:
Joachim Lusiardi 2016-07-30 09:23:14 +02:00
commit 49a45ba8a4
4 changed files with 23 additions and 8 deletions

View File

@ -187,6 +187,8 @@ def create_vehicle():
if form.consumables.data: if form.consumables.data:
form.consumables.default = form.consumables.data form.consumables.default = form.consumables.data
else:
form.consumables.default = []
if form.validate_on_submit(): if form.validate_on_submit():
if len(form.consumables.data) == 0: if len(form.consumables.data) == 0:
@ -319,7 +321,7 @@ def delete_pit_stop_form(pid):
@app.route('/pitstops/edit/<int:pid>', methods=['GET', 'POST']) @app.route('/pitstops/edit/<int:pid>', methods=['GET', 'POST'])
@login_required @login_required
def edit_pit_stop_form(pid): def edit_pit_stop_form(pid):
edit_pitstop = Pitstop.query.get(pid).first() edit_pitstop = Pitstop.query.get(pid)
if edit_pitstop is None: if edit_pitstop is None:
return redirect(url_for('get_pit_stops')) return redirect(url_for('get_pit_stops'))
@ -339,14 +341,14 @@ def edit_pit_stop_form(pid):
if form.validate_on_submit(): if form.validate_on_submit():
edit_pitstop.costs = form.costs.data edit_pitstop.costs = form.costs.data
edit_pitstop.date = form.date.data edit_pitstop.date = form.date.data
edit_pitstop.litres = form.litres.data edit_pitstop.amount = form.litres.data
edit_pitstop.odometer = form.odometer.data edit_pitstop.odometer = form.odometer.data
db.session.commit() db.session.commit()
tools.db_log_update(edit_pitstop) tools.db_log_update(edit_pitstop)
return redirect(url_for('get_pit_stops', _anchor='v' + str(vehicle.id))) return redirect(url_for('get_pit_stops', _anchor='v' + str(vehicle.id)))
form.odometer.default = edit_pitstop.odometer form.odometer.default = edit_pitstop.odometer
form.litres.default = edit_pitstop.litres form.litres.default = edit_pitstop.amount
form.date.default = edit_pitstop.date form.date.default = edit_pitstop.date
form.costs.default = edit_pitstop.costs form.costs.default = edit_pitstop.costs
form.process() form.process()
@ -354,7 +356,7 @@ def edit_pit_stop_form(pid):
'date': 'Date must be between %s and %s (including).' % (str(last_pitstop.date), str(date.today())), '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)) 'odometer': 'Odometer must be greater than %s km.' % (str(last_pitstop.odometer))
} }
if edit_pitstop.costs > 0: if edit_pitstop.costs is not None and edit_pitstop.costs > 0:
messages['costs'] = 'Costs must be higher than 0.01 €.' 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=messages)

View File

@ -82,7 +82,7 @@ class CreatePitstopForm(Form):
if self.date.data: if self.date.data:
self.date.default = self.date.data self.date.default = self.date.data
else: else:
self.date.default = self.last_pitstop.date self.date.default = date.today()
if self.odometer.data: if self.odometer.data:
self.odometer.default = self.odometer.data self.odometer.default = self.odometer.data
else: else:

View File

@ -17,11 +17,18 @@
</tr> </tr>
<tr> <tr>
<th style='text-align:right'>Litres</th> <th style='text-align:right'>Litres</th>
<td style='text-align: left'>{{ pitstop.litres }} l</td> <td style='text-align: left'>{{ pitstop.amount }} {{ pitstop.consumable.unit }}</td>
</tr> </tr>
<tr> <tr>
<th style='text-align:right'>Costs (overall)</th> <th style='text-align:right'>Costs (overall)</th>
<td style='text-align: left'>{{ pitstop.costs }} €</td> <td style='text-align: left'>
{% if pitstop.costs %}
{{pitstop.costs}}
{% else %}
--
{% endif %}
</td>
</tr> </tr>
</table> </table>
<form class='form-horizontal' method='POST'> <form class='form-horizontal' method='POST'>

View File

@ -35,7 +35,13 @@
{% if field.type == 'SelectField' %} {% if field.type == 'SelectField' %}
<select id="{{ field.id }}" name="{{ field.id }}" class="form-control"> <select id="{{ field.id }}" name="{{ field.id }}" class="form-control">
{% for choice in field.choices %} {% for choice in field.choices %}
<option value="{{ choice[0] }}">{{ choice[1] }}</option> <option value="{{ choice[0] }}" {% if choice[0] == field.default %}selected="selected"{%endif%}>{{ choice[1] }}</option>
{% endfor %}
</select>
{% elif field.type == 'SelectMultipleField' %}
<select id="{{ field.id }}" name="{{ field.id }}" class="form-control" multiple="multiple">
{% for choice in field.choices %}
<option value="{{ choice[0] }}" {% if choice[0] in field.default %}selected="selected"{%endif%}>{{ choice[1] }}</option>
{% endfor %} {% endfor %}
</select> </select>
{% elif field.type == 'BooleanField' %} {% elif field.type == 'BooleanField' %}