react to closed stations
This commit is contained in:
parent
9427ed50ad
commit
543d3e1658
|
@ -49,27 +49,6 @@ def select_consumable_for_new_pitstop(vid):
|
||||||
return render_template('selectConsumableForVehicle.html', vehicle=vehicle, form=form)
|
return render_template('selectConsumableForVehicle.html', vehicle=vehicle, form=form)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/pitstops/vehicle/<int:vid>/consumable/<int:cid>/plan', methods=['GET', 'POST'])
|
|
||||||
@login_required
|
|
||||||
def plan_pit_stop_form(vid, cid):
|
|
||||||
vehicle = Vehicle.query.get(vid)
|
|
||||||
if vehicle is None or vehicle not in current_user.vehicles:
|
|
||||||
return redirect(url_for('select_vehicle_for_new_pitstop'))
|
|
||||||
|
|
||||||
consumable = Consumable.query.get(cid)
|
|
||||||
if consumable not in vehicle.consumables:
|
|
||||||
return redirect(url_for('select_consumable_for_new_pitstop', vid=vid))
|
|
||||||
|
|
||||||
update_filling_station_prices([x.id for x in current_user.favourite_filling_stations])
|
|
||||||
|
|
||||||
offers = []
|
|
||||||
for fs in current_user.favourite_filling_stations:
|
|
||||||
if fs.open:
|
|
||||||
offers.append((fs, getattr(fs, consumable.ext_id),))
|
|
||||||
|
|
||||||
return render_template('planPitStopForm.html', vehicle=vehicle, consumable=consumable, offers=offers)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/pitstops/vehicle/<int:vid>/consumable/<int:cid>/create', methods=['GET', 'POST'])
|
@app.route('/pitstops/vehicle/<int:vid>/consumable/<int:cid>/create', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def create_pit_stop_form(vid, cid):
|
def create_pit_stop_form(vid, cid):
|
||||||
|
@ -202,3 +181,64 @@ def get_pit_stops():
|
||||||
user['vehicles'].append(v)
|
user['vehicles'].append(v)
|
||||||
|
|
||||||
return render_template('pitstops.html', user=user)
|
return render_template('pitstops.html', user=user)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/pitstops/plan/vehicle/select', methods=['GET', 'POST'])
|
||||||
|
@login_required
|
||||||
|
def select_vehicle_for_plan_pitstop():
|
||||||
|
if len(current_user.vehicles) == 1:
|
||||||
|
return redirect(url_for('select_consumable_for_plan_pitstop', vid=current_user.vehicles[0].id))
|
||||||
|
|
||||||
|
form = SelectVehicleForm()
|
||||||
|
form.vehicle.choices = [(g.id, g.name) for g in current_user.vehicles]
|
||||||
|
|
||||||
|
if form.validate_on_submit():
|
||||||
|
return redirect(url_for('select_consumable_for_plan_pitstop', vid=form.vehicle.data))
|
||||||
|
|
||||||
|
return render_template('selectVehicle.html', form=form)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/pitstops/plan/vehicle/<int:vid>/consumable/select', methods=['GET', 'POST'])
|
||||||
|
@login_required
|
||||||
|
def select_consumable_for_plan_pitstop(vid):
|
||||||
|
vehicle = Vehicle.query.get(vid)
|
||||||
|
if vehicle is None or vehicle not in current_user.vehicles:
|
||||||
|
return redirect(url_for('select_consumable_for_plan_pitstop'))
|
||||||
|
|
||||||
|
if len(vehicle.consumables) == 0:
|
||||||
|
flash('Please choose at least one consumable!', 'warning')
|
||||||
|
return redirect(url_for('edit_vehicle', vid=vid))
|
||||||
|
|
||||||
|
if len(vehicle.consumables) == 1:
|
||||||
|
return redirect(url_for('plan_pit_stop_form', vid=vid, cid=vehicle.consumables[0].id))
|
||||||
|
|
||||||
|
form = SelectConsumableForm()
|
||||||
|
form.consumable.choices = [(g.id, g.name) for g in vehicle.consumables]
|
||||||
|
|
||||||
|
if form.validate_on_submit():
|
||||||
|
return redirect(url_for('plan_pit_stop_form', vid=vid, cid=form.consumable.data))
|
||||||
|
|
||||||
|
return render_template('selectConsumableForVehicle.html', vehicle=vehicle, form=form)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/pitstops/plan/vehicle/<int:vid>/consumable/<int:cid>', methods=['GET', 'POST'])
|
||||||
|
@login_required
|
||||||
|
def plan_pit_stop_form(vid, cid):
|
||||||
|
vehicle = Vehicle.query.get(vid)
|
||||||
|
if vehicle is None or vehicle not in current_user.vehicles:
|
||||||
|
return redirect(url_for('select_vehicle_for_new_pitstop'))
|
||||||
|
|
||||||
|
consumable = Consumable.query.get(cid)
|
||||||
|
if consumable not in vehicle.consumables:
|
||||||
|
return redirect(url_for('select_consumable_for_new_pitstop', vid=vid))
|
||||||
|
|
||||||
|
update_filling_station_prices([x.id for x in current_user.favourite_filling_stations])
|
||||||
|
|
||||||
|
offers = []
|
||||||
|
for fs in current_user.favourite_filling_stations:
|
||||||
|
# if fs.open:
|
||||||
|
offers.append((fs, getattr(fs, consumable.ext_id),))
|
||||||
|
|
||||||
|
return render_template('planPitStopForm.html', vehicle=vehicle, consumable=consumable, offers=offers)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -121,3 +121,6 @@ th.headerSortDown {
|
||||||
background-image: url(../img/up.gif);
|
background-image: url(../img/up.gif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filling_station_closed {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
{% macro navigation() -%}
|
{% macro navigation() -%}
|
||||||
{% if current_user.email %}
|
{% if current_user.email %}
|
||||||
|
<li><a id='plan_pitstop_link' href='{{ url_for('select_vehicle_for_plan_pitstop') }}'>Plan Pitstop</a></li>
|
||||||
<li><a id='new_pitstop_link' href='{{ url_for('select_vehicle_for_new_pitstop') }}'>Create Pitstop</a></li>
|
<li><a id='new_pitstop_link' href='{{ url_for('select_vehicle_for_new_pitstop') }}'>Create Pitstop</a></li>
|
||||||
<li><a id='new_service_link' href='{{ url_for('select_vehicle_for_new_service') }}'>Create Service</a></li>
|
<li><a id='new_service_link' href='{{ url_for('select_vehicle_for_new_service') }}'>Create Service</a></li>
|
||||||
<li><a id='statistics_limk' href='{{ url_for('get_statistics') }}'>Statistics</a></li>
|
<li><a id='statistics_limk' href='{{ url_for('get_statistics') }}'>Statistics</a></li>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
{% for offer in offers %}
|
{% for offer in offers %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div class="row filling_station_info" style="border: 0px">
|
<div class="row filling_station_info " style="border: 0px">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div>{{ offer[0].name }}</div>
|
<div>{{ offer[0].name }}</div>
|
||||||
<div>{{ offer[0].street }} {{ offer[0].houseNumber }}</div>
|
<div>{{ offer[0].street }} {{ offer[0].houseNumber }}</div>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="filling_station_{{ 'open' if offer[0].open else 'closed'}}">
|
||||||
{{ offer[1] }} €/{{ consumable.unit }}
|
{{ offer[1] }} €/{{ consumable.unit }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -190,9 +190,10 @@ def update_filling_station_prices(ids):
|
||||||
id = price
|
id = price
|
||||||
station_status = prices[id]
|
station_status = prices[id]
|
||||||
print(id, station_status)
|
print(id, station_status)
|
||||||
map[id].diesel = station_status['diesel']
|
|
||||||
map[id].e10 = station_status['e10']
|
|
||||||
map[id].e5 = station_status['e5']
|
|
||||||
map[id].open = station_status['status'] == 'open'
|
map[id].open = station_status['status'] == 'open'
|
||||||
|
if map[id].open:
|
||||||
|
map[id].diesel = station_status['diesel']
|
||||||
|
map[id].e10 = station_status['e10']
|
||||||
|
map[id].e5 = station_status['e5']
|
||||||
map[id].last_update = datetime.now()
|
map[id].last_update = datetime.now()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
Loading…
Reference in New Issue