Author: Pedro Lucas Porcellis <pedrolucasporcellis@gmail.com>
Make pages extend from default layout and cancel order
src/templates/cycle.html | 18 ++++++++++++------ src/templates/cycles.html | 5 ++++-
diff --git a/src/templates/cycle.html b/src/templates/cycle.html index 312de3222cfff4188aca04b4c0f92c6b58a68b02..949ebaf85d56554ca93ab813a91f9eac19dad2d7 100644 --- a/src/templates/cycle.html +++ b/src/templates/cycle.html @@ -2,10 +2,10 @@ {% extends 'layout.html' %} {% block body %} <section class="a"> <h1>{{ cycle.name }}</h1> - <em>{{ cycle.description }}</em> + <em class="white-space-pre">{{ cycle.description }}</em> </section> -{% if current_order.status.value == 'confirmed' %} +{% if current_order and current_order.status.value == 'confirmed' %} <strong> Seu pedido está {{ current_order.status.value }} <a href="{{ url_for('orders.reopen', id = current_order.id) }}">Deseja reabrir?</a></strong> {% endif %} @@ -28,7 +28,7 @@Preço </tr> </thead> <tbody> - {% with selected_product_ids = current_order.selected_product_ids() %} + {% with selected_product_ids = current_order.selected_product_ids() if current_order else [] %} {% for product in products %} <tr> <td> @@ -39,13 +39,14 @@ <td> {{ product.title }} </td> <td> {{ product.group.name }} </td> <td> {{ product.category.name }}</td> - <td> {{ product.price_on(current_order.cycle) | as_currency }} </td> + <td> {{ product.price_on(cycle) | as_currency }} </td> </tr> {% endfor %} {% endwith %} </tbody> </table> + {% if current_order %} <section> <h4> O que você vai levar: </h4> <ul> @@ -58,11 +59,16 @@Total: <em>{{ current_order.total() | as_currency }}</em> </div> </section> + {% endif %} <div class="form-action"> - <button type="submit" {{ "disabled" if current_order.status.value == 'confirmed' }} name="confirm" rel="button">Confirmar produtos</button> - {% if current_order.status.value == 'draft' %} + <button type="submit" {{ "disabled" if current_order and current_order.status.value == 'confirmed' }} name="confirm" rel="button">Confirmar produtos</button> + {% if current_order and current_order.status.value == 'draft' %} <button type="submit" name="draft" rel="button">Salvar pedido como rascunho</button> + {% endif %} + + {% if current_order %} + <a href="{{url_for('orders.cancel', id = current_order.id)}}">Cancelar Pedido</a> {% endif %} </div> </form> diff --git a/src/templates/cycles.html b/src/templates/cycles.html index c6607b52187021b8def0d3820cdf93cc4effa201..c8a514c74f73e89babd87325259f564512cdcd62 100644 --- a/src/templates/cycles.html +++ b/src/templates/cycles.html @@ -1,9 +1,12 @@ +{% extends "layout.html" %} +{% block body %} <section class="cycles"> <h1>Ciclo em aberto</h1> <div class="cycle"> <h2>{{ current_cycle.title }}</h2> - <p>{{ current_cycle.description }}</p> + <p class="white-space-pre">{{ current_cycle.description }}</p> <a href="{{url_for('cycles.show', id = current_cycle.id)}}">Ver ciclo</a> <a href="{{url_for('cycles.close', id = current_cycle.id)}}">Fechar ciclo</a> </div> </section> +{% endblock %}