ciclos

commit 5c83a95aea88b5af60ccc7fdfb4df288a5c13d1e

Author: Pedro Lucas Porcellis <pedrolucasporcellis@gmail.com>

Add configuration and some small fixes

 src/blueprints/cycles.py | 4 +++-
 src/templates/cycle.html | 2 +-
 src/templates/index.html | 13 +++++++++----
 src/templates/new_cycle.html | 17 ++++++-----------


diff --git a/src/blueprints/cycles.py b/src/blueprints/cycles.py
index 624abe4b980bc8ab98de54ecba7d60c3da4a1fff..0bda01eff46ef11f9516551112598db57c0fbb2d 100644
--- a/src/blueprints/cycles.py
+++ b/src/blueprints/cycles.py
@@ -7,6 +7,7 @@
 from ..types.cycle import Cycle, CycleStatus
 from ..types.product import Product
 from ..types.order import OrderStatus
+from ..types.configuration import Configuration
 
 @cycles.route('/', methods = ['GET', 'POST'])
 def index():
@@ -21,7 +22,8 @@
 @cycles.route('/new', methods = ['GET'])
 def new():
     cycle_status_options = [(cycle.value, cycle.name) for cycle in CycleStatus]
-    return render_template('new_cycle.html', cycles = cycle_status_options, title = "Abrir novo Ciclo - Feira Virtual Bem da Terra")
+    configuration = Configuration.query.first()
+    return render_template('new_cycle.html', configuration = configuration, cycles = cycle_status_options, title = "Abrir novo Ciclo - Feira Virtual Bem da Terra")
 
 @cycles.route('/<id>', methods = ['GET'])
 def show(id):




diff --git a/src/templates/cycle.html b/src/templates/cycle.html
index 3503356f190fa069893922720f5c15adc1dab657..1069bc4e5150644e8d1de7d62891168e9b574bfe 100644
--- a/src/templates/cycle.html
+++ b/src/templates/cycle.html
@@ -10,7 +10,7 @@  Seu pedido está {{ current_order.status.value }} Deseja reabrir?
 {% endif %}
 
 <section>
-  {% if not current_order %}
+  {% if not current_order and cycle.status.value == 'published' %}
   <strong>Você não tem um pedido nesse ciclo. <a href="{{ url_for('orders.create') }}">Abrir um</a></strong>
   {% endif %}
 </section>




diff --git a/src/templates/index.html b/src/templates/index.html
index 1fcea08e525ab131e6a306b47acfbea2854be306..3dde944c619e6faff93e3818f73f012ef46960fd 100644
--- a/src/templates/index.html
+++ b/src/templates/index.html
@@ -17,11 +17,16 @@ 
 
 <section>
   {% if current_user.is_authenticated %}
-    <h2>Gerenciamento</h2>
+    {% if current_user.is_admin() %}
+      <h2>Gerenciamento</h2>
+      <ul>
+        <li> <a href="{{url_for('groups.index')}}">Ver Fornecedores cadastrados </a> </li>
+        <li> <a href="{{url_for('products.index')}}">Ver produtos cadastrados </a> </li>
+        <li> <a href="{{url_for('product_categories.index')}}">Ver categorias</a> </li>
+      </ul>
+    {% endif %}
+      
     <ul>
-      <li> <a href="{{url_for('groups.index')}}">Ver Fornecedores cadastrados </a> </li>
-      <li> <a href="{{url_for('products.index')}}">Ver produtos cadastrados </a> </li>
-      <li> <a href="{{url_for('product_categories.index')}}">Ver categorias</a> </li>
       <li> <a href="{{url_for('cycles.index')}}">Ver ciclos</a> </li>
     </ul>
   {% else %}




diff --git a/src/templates/new_cycle.html b/src/templates/new_cycle.html
index aa6522312473783a540b7c0889e239a11c8ad28d..3fc26aa645bce92d19694867abf1734edb8838b5 100644
--- a/src/templates/new_cycle.html
+++ b/src/templates/new_cycle.html
@@ -12,19 +12,14 @@       
     </div>
     <div class="form-section">
       <label for="">Start At</label>
-      <input name="start_at" type="text" />
-    </div>
-    <div class="form-section">
-      <label for="">Ends At</label>
-      <input name="end_at" type="text" />
+      <input name="start_at" type="date" />
+      <small>O Ciclo está configurado para ter duração de {{ configuration.purchase_duration }} {{ configuration.purchase_duration_type }} apartir da data informada.</small>
     </div>
     <div class="form-section">
       <label for="">Delivery Start At</label>
-      <input name="delivery_start_at" type="text" />
-    </div>
-    <div class="form-section">
-      <label for="">Delivery Ends At</label>
-      <input name="delivery_end_at" type="text" />
+      <input name="delivery_start_at" type="date" />
+      <small>O período de entrega está configurado para ter duração de {{ configuration.delivery_duration }} {{ configuration.delivery_duration_type }} apartir da data informada.</small>
+
     </div>
   
     <div class="form-section">
@@ -42,7 +37,7 @@       
     </div>
     
     <div class="form-action">
-      <button type="submit">Criar Ciclo</button>
+      <button class="btn btn-primary" type="submit">Criar Ciclo</button>
     </div>
   </form>
 {% endblock %}