Allow anonymous order creation
This commit is contained in:
parent
f0561bcd71
commit
76ac07742e
3 changed files with 9 additions and 12 deletions
15
app/forms.py
15
app/forms.py
|
@ -37,15 +37,12 @@ class OrderForm(Form):
|
||||||
|
|
||||||
def populate(self) -> None:
|
def populate(self) -> None:
|
||||||
"Fill in the options for courier for an Order"
|
"Fill in the options for courier for an Order"
|
||||||
if current_user.is_admin():
|
|
||||||
self.courier_id.choices = [(0, None)] + [
|
self.courier_id.choices = [(0, None)] + (
|
||||||
(u.id, u.username) for u in User.query.order_by("username")
|
[(u.id, u.username) for u in User.query.order_by("username")] if current_user.is_admin()
|
||||||
]
|
else [(current_user.id, current_user.username)] if current_user.is_authenticated()
|
||||||
else:
|
else []
|
||||||
self.courier_id.choices = [
|
)
|
||||||
(0, None),
|
|
||||||
(current_user.id, current_user.username),
|
|
||||||
]
|
|
||||||
self.location_id.choices = [(l.id, l.name) for l in location_definitions]
|
self.location_id.choices = [(l.id, l.name) for l in location_definitions]
|
||||||
if self.stoptime.data is None:
|
if self.stoptime.data is None:
|
||||||
self.stoptime.data = datetime.now() + timedelta(hours=1)
|
self.stoptime.data = datetime.now() + timedelta(hours=1)
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<h4>No orders available.</h4>
|
<h4>No orders available.</h4>
|
||||||
{% if not current_user.is_anonymous() %}
|
{% if form %}
|
||||||
To create an order, fill in the form on the right.
|
To create an order, fill in the form on the right.
|
||||||
{% else %}
|
{% else %}
|
||||||
Login to create an order, or ask someone else.
|
Login to create an order, or ask someone else.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if not current_user.is_anonymous() %}
|
{% if form %}
|
||||||
<div class="col-md-push-1 col-md-6">
|
<div class="col-md-push-1 col-md-6">
|
||||||
<h3>Create new order</h3>
|
<h3>Create new order</h3>
|
||||||
<div class="row darker">
|
<div class="row darker">
|
||||||
|
|
|
@ -31,7 +31,7 @@ order_bp = Blueprint("order_bp", "order")
|
||||||
@order_bp.route("/")
|
@order_bp.route("/")
|
||||||
def orders(form: OrderForm = None) -> str:
|
def orders(form: OrderForm = None) -> str:
|
||||||
"Generate general order view"
|
"Generate general order view"
|
||||||
if form is None and not current_user.is_anonymous():
|
if form is None:
|
||||||
form = OrderForm()
|
form = OrderForm()
|
||||||
location_id = request.args.get("location_id")
|
location_id = request.args.get("location_id")
|
||||||
form.location_id.default = location_id
|
form.location_id.default = location_id
|
||||||
|
|
Loading…
Reference in a new issue