Merge pull request #124 from ZeusWPI/feature/120/order-button-on-location-page

Adds a button on the location/ and locations/ page to start a new order
This commit is contained in:
Tom Naessens 2019-05-31 08:51:00 +12:00 committed by GitHub
commit 4e143b9b97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View file

@ -9,8 +9,11 @@
<h3>Location: {{ location.name }}</h3> <h3>Location: {{ location.name }}</h3>
<span class="glyphicon glyphicon-home"></span>: {{ location.address }} <br/> <span class="glyphicon glyphicon-home"></span>: {{ location.address }} <br/>
<span class="glyphicon glyphicon-phone"></span>: {{ location.telephone }} <br/> <span class="glyphicon glyphicon-phone"></span>: {{ location.telephone }} <br/>
<span class="glyphicon glyphicon-link"></span>: <a href="{{ location.website}}">{{ location.website }}</a> <span class="glyphicon glyphicon-link"></span>: <a href="{{ location.website}}">{{ location.website }}</a> <br/>
<a href="{{ url_for("order_bp.orders", location_id=location.id) }}" class="btn btn-primary btn-sm">Create order</a>
</div> </div>
</div>
<div class="row">
<div class="col-md-push-1 col-md-10 darker"> <div class="col-md-push-1 col-md-10 darker">
<h3 id="order-title">Products</h3> <h3 id="order-title">Products</h3>
<table class="table table-hover table-condensed"> <table class="table table-hover table-condensed">

View file

@ -9,7 +9,7 @@
<h3>Locations</h3> <h3>Locations</h3>
<table class="table table-hover table-condensed"> <table class="table table-hover table-condensed">
<thead> <thead>
<tr><th>Name</th><th>Address</th><th></th></tr> <tr><th>Name</th><th>Address</th><th></th><th></th><th></th></tr>
</thead> </thead>
<tbody> <tbody>
{% for loc in locations -%} {% for loc in locations -%}
@ -17,6 +17,9 @@
<td><a href="{{ url_for('location', id=loc.id) }}">{{ loc.name }}</a></td> <td><a href="{{ url_for('location', id=loc.id) }}">{{ loc.name }}</a></td>
<td>{{ loc.address }}<td> <td>{{ loc.address }}<td>
<td><a href="{{ loc.website}}"><span class="glyphicon glyphicon-link"></span></a></td> <td><a href="{{ loc.website}}"><span class="glyphicon glyphicon-link"></span></a></td>
<td>
<a href="{{ url_for("order_bp.orders", location_id=loc.id) }}" class="btn btn-primary btn-xs">Create order</a>
</td>
</tr> </tr>
{%- endfor %} {%- endfor %}
</tbody> </tbody>

View file

@ -17,6 +17,9 @@ order_bp = Blueprint('order_bp', 'order')
def orders(form=None): def orders(form=None):
if form is None and not current_user.is_anonymous(): if form is None and not current_user.is_anonymous():
form = OrderForm() form = OrderForm()
location_id = request.args.get('location_id')
form.location_id.default = location_id
form.process()
form.populate() form.populate()
return render_template('orders.html', orders=get_orders(), form=form) return render_template('orders.html', orders=get_orders(), form=form)