add redirect if vehicle is not configured and flash messages
This commit is contained in:
parent
87b3b02f3e
commit
088d1f24a0
@ -1,6 +1,4 @@
|
||||
from datetime import date
|
||||
|
||||
from flask import Flask
|
||||
from flask import Flask, flash
|
||||
from flask import redirect, g
|
||||
from flask import render_template
|
||||
from flask import url_for
|
||||
@ -241,6 +239,10 @@ def select_consumable_for_new_pitstop(vid):
|
||||
if vehicle is None or vehicle not in current_user.vehicles:
|
||||
return redirect(url_for('select_vehicle_for_new_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('create_pit_stop_form', vid=vid, cid=vehicle.consumables[0].id))
|
||||
|
||||
|
@ -3,7 +3,7 @@ body {
|
||||
}
|
||||
|
||||
.starter-template {
|
||||
padding-top: 30px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 60px;
|
||||
text-align: center;
|
||||
}
|
||||
@ -59,6 +59,14 @@ h3:after{
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.alert {
|
||||
margin-bottom:0px;
|
||||
}
|
||||
|
||||
.topspace {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
// for small devices
|
||||
@media only screen
|
||||
and (min-device-width : 320px)
|
||||
|
@ -5,7 +5,7 @@
|
||||
<div class="col-md-8">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<h3>Edit vehicle</h3>
|
||||
<h3>Edit vehicle '{{vehicle.name}}'</h3>
|
||||
<form class='form-horizontal' method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
{{ render_field_with_errors(form.name) }}
|
||||
|
@ -151,8 +151,23 @@
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
<div class="row topspace">
|
||||
<div class="col-md-4" ></div>
|
||||
<div class="col-md-4">
|
||||
<div class="alert alert-{{category}} alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4" ></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<div class="container topspace">
|
||||
<div class="starter-template">
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user