From 1c1e0bc7a5123ed7a8145901cc998fb753825ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 7 Apr 2021 18:50:44 +0200 Subject: [PATCH 1/4] Update flash.min.js to not depend on font-awesome. Fixes #10 --- copanier/static/flash.min.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/copanier/static/flash.min.css b/copanier/static/flash.min.css index f8fcdac..1564cba 100644 --- a/copanier/static/flash.min.css +++ b/copanier/static/flash.min.css @@ -1 +1 @@ -.flash-container{position:fixed;top:75px;right:15px;z-index:1000;max-width:25%}.flash-container .flash-message{position:relative;opacity:0;min-height:28px;-webkit-transform:translateX(-20px);-ms-transform:translateX(-20px);transform:translateX(-20px);-webkit-transition:all .5s;-o-transition:all .5s;transition:all .5s;background-color:#fff;color:#2c3433;-webkit-border-radius:0;border-radius:0;-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;margin-bottom:10px;padding:5px 35px 5px 20px;-webkit-box-shadow:2px 2px 33px 8px rgba(0,0,0,.1);box-shadow:2px 2px 33px 8px rgba(0,0,0,.1);line-height:1.4;cursor:pointer}.flash-container .flash-message .flash-progress{position:absolute;right:0;top:auto;bottom:0;left:0;width:0;height:3px;opacity:1;background-color:rgba(0,0,0,.15);-webkit-transition:opacity .1s;-o-transition:opacity .1s;transition:opacity .1s}.flash-container .flash-message .flash-progress.is-hidden{opacity:0}.flash-container .flash-message .flash-progress.flash-progress-top{top:0;bottom:auto}.flash-container .flash-message:before{position:absolute;content:"";width:7px;height:100%;top:0;bottom:0;left:-7px;background-color:transparent;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px}.flash-container .flash-message:after{position:absolute;content:"";font-family:fontAwesome;top:5px;right:8px;text-align:center;vertical-align:middle;color:#9e9e9e}.flash-container .flash-message.is-visible{opacity:1;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.flash-container .flash-message.flash-success .flash-progress{background-color:rgba(76,175,80,.15)}.flash-container .flash-message.flash-success:before{background-color:#4caf50}.flash-container .flash-message.flash-success:after{color:rgba(76,175,80,.5);content:"\F058"}.flash-container .flash-message.flash-warning .flash-progress{background-color:rgba(255,133,27,.15)}.flash-container .flash-message.flash-warning:before{background-color:#ff851b}.flash-container .flash-message.flash-warning:after{color:rgba(255,133,27,.5);content:"\F071"}.flash-container .flash-message.flash-danger .flash-progress,.flash-container .flash-message.flash-error .flash-progress{background-color:rgba(255,65,54,.15)}.flash-container .flash-message.flash-danger:before,.flash-container .flash-message.flash-error:before{background-color:#ff4136}.flash-container .flash-message.flash-danger:after,.flash-container .flash-message.flash-error:after{color:rgba(255,65,54,.5);content:"\F06A"}.flash-container .flash-message.flash-info .flash-progress{background-color:rgba(0,116,217,.15)}.flash-container .flash-message.flash-info:before{background-color:#0074d9}.flash-container .flash-message.flash-info:after{color:rgba(0,116,217,.5);content:"\F05A"}.flash-container .flash-message.flash-bug .flash-progress{background-color:rgba(138,43,226,.15)}.flash-container .flash-message.flash-bug:before{background-color:#8a2be2}.flash-container .flash-message.flash-bug:after{color:rgba(138,43,226,.5);content:"\F188"}.flash-container .flash-message.flash-disabled .flash-progress{background-color:hsla(0,0%,67%,.15)}.flash-container .flash-message.flash-disabled:before{background-color:#aaa}.flash-container .flash-message.flash-disabled:after{color:hsla(0,0%,67%,.5);content:"\F05E"}.flash-container .flash-message.flash-default{padding-right:20px}@media (max-width:1280px){.flash-container{max-width:33.334%}}@media (max-width:768px){.flash-container{max-width:50%}}@media (max-width:480px){.flash-container{right:10px;left:10px;max-width:100%}}.flash-container .flash-message.dark-theme{background-color:#2c3433;color:#fff}.flash-container .flash-message.dark-theme .flash-progress{background-color:hsla(0,0%,100%,.5)} \ No newline at end of file +.flash-container{position:fixed;top:75px;right:15px;z-index:1000;max-width:25%}.flash-container .flash-message{position:relative;opacity:0;min-height:28px;-webkit-transform:translateX(-20px);-ms-transform:translateX(-20px);transform:translateX(-20px);-webkit-transition:all .5s;-o-transition:all .5s;transition:all .5s;background-color:#fff;color:#2c3433;-webkit-border-radius:0;border-radius:0;-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;margin-bottom:10px;padding:5px 35px 5px 20px;-webkit-box-shadow:2px 2px 33px 8px rgba(0,0,0,.1);box-shadow:2px 2px 33px 8px rgba(0,0,0,.1);line-height:1.4;cursor:pointer}.flash-container .flash-message .flash-progress{position:absolute;right:0;top:auto;bottom:0;left:0;width:0;height:3px;opacity:1;background-color:rgba(0,0,0,.15);-webkit-transition:opacity .1s;-o-transition:opacity .1s;transition:opacity .1s}.flash-container .flash-message .flash-progress.is-hidden{opacity:0}.flash-container .flash-message .flash-progress.flash-progress-top{top:0;bottom:auto}.flash-container .flash-message:before{position:absolute;content:"";width:7px;height:100%;top:0;bottom:0;left:-7px;background-color:transparent;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px}.flash-container .flash-message:after{position:absolute;content:"";font-family:fontAwesome;top:5px;right:8px;text-align:center;vertical-align:middle;color:#9e9e9e}.flash-container .flash-message.is-visible{opacity:1;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.flash-container .flash-message.flash-success .flash-progress{background-color:rgba(76,175,80,.15)}.flash-container .flash-message.flash-success:before{background-color:#4caf50}.flash-container .flash-message.flash-success:after{color:rgba(76,175,80,.5);content:"✓"}.flash-container .flash-message.flash-warning .flash-progress{background-color:rgba(255,133,27,.15)}.flash-container .flash-message.flash-warning:before{background-color:#ff851b}.flash-container .flash-message.flash-warning:after{color:rgba(255,133,27,.5);content:"⚠"}.flash-container .flash-message.flash-danger .flash-progress,.flash-container .flash-message.flash-error .flash-progress{background-color:rgba(255,65,54,.15)}.flash-container .flash-message.flash-danger:before,.flash-container .flash-message.flash-error:before{background-color:#ff4136}.flash-container .flash-message.flash-danger:after,.flash-container .flash-message.flash-error:after{color:rgba(255,65,54,.5);content:"⚠"}.flash-container .flash-message.flash-info .flash-progress{background-color:rgba(0,116,217,.15)}.flash-container .flash-message.flash-info:before{background-color:#0074d9}.flash-container .flash-message.flash-info:after{color:rgba(0,116,217,.5);content:"ℹ"}.flash-container .flash-message.flash-bug .flash-progress{background-color:rgba(138,43,226,.15)}.flash-container .flash-message.flash-bug:before{background-color:#8a2be2}.flash-container .flash-message.flash-bug:after{color:rgba(138,43,226,.5);content:"❌"}.flash-container .flash-message.flash-disabled .flash-progress{background-color:hsla(0,0%,67%,.15)}.flash-container .flash-message.flash-disabled:before{background-color:#aaa}.flash-container .flash-message.flash-disabled:after{color:hsla(0,0%,67%,.5);content:"\F05E"}.flash-container .flash-message.flash-default{padding-right:20px}@media (max-width:1280px){.flash-container{max-width:33.334%}}@media (max-width:768px){.flash-container{max-width:50%}}@media (max-width:480px){.flash-container{right:10px;left:10px;max-width:100%}}.flash-container .flash-message.dark-theme{background-color:#2c3433;color:#fff}.flash-container .flash-message.dark-theme .flash-progress{background-color:hsla(0,0%,100%,.5)} \ No newline at end of file From ed0bd05114cf82d186fbe480e85dd941b00f9c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 7 Apr 2021 20:15:28 +0200 Subject: [PATCH 2/4] Make progress easier to follow --- copanier/models.py | 13 +++++ copanier/static/app.css | 55 +++++++++++++++++++ .../templates/delivery/show_delivery.html | 2 + .../templates/includes/delivery_head.html | 2 +- 4 files changed, 71 insertions(+), 1 deletion(-) diff --git a/copanier/models.py b/copanier/models.py index f01f184..66d559b 100644 --- a/copanier/models.py +++ b/copanier/models.py @@ -315,6 +315,7 @@ class Delivery(PersistedBase): NEED_PRICE_UPDATE = 1 OPEN = 2 ADJUSTMENT = 3 + WAITING_PRODUCTS = 4 name: str from_date: datetime_field @@ -343,6 +344,9 @@ class Delivery(PersistedBase): return self.OPEN if self.needs_adjustment: return self.ADJUSTMENT + if self.is_waiting_products: + return self.WAITING_PRODUCTS + return self.CLOSED def products_need_price_update(self, products=None): @@ -375,6 +379,15 @@ class Delivery(PersistedBase): @property def is_open(self): return datetime.now().date() <= self.order_before.date() + + @property + def is_waiting_products(self): + return ( + datetime.now().date() >= self.order_before.date() + and + datetime.now().date() <= self.from_date.date() + ) + @property def is_foreseen(self): diff --git a/copanier/static/app.css b/copanier/static/app.css index 18fce1c..bd04af8 100644 --- a/copanier/static/app.css +++ b/copanier/static/app.css @@ -728,4 +728,59 @@ small { .header { padding-bottom: 2em !important; +} + +@media screen and (max-width: 1100px) { + .progressbar { + display: none !important; + } +} + +.progressbar { + counter-reset: step; +} +.progressbar li { + list-style-type: none; + width: 13%; + float: left; + font-size: 12px; + position: relative; + text-align: center; + text-transform: uppercase; + color: #7d7d7d; +} +.progressbar li:before { + width: 32px; + height: 32px; + content: counter(step); + counter-increment: step; + line-height: 30px; + border: 2px solid #7d7d7d; + display: block; + text-align: center; + margin: 0 auto 10px auto; + border-radius: 50%; + background-color: white; +} +.progressbar li:after { + width: 100%; + height: 2px; + content: ''; + position: absolute; + background-color: #7d7d7d; + top: 15px; + left: -50%; + z-index: -1; +} +.progressbar li:first-child:after { + content: none; +} +.progressbar li.active { + color: green; +} +.progressbar li.active:before { + border-color: #55b776; +} +.progressbar li.active + li:after { + background-color: #55b776; } \ No newline at end of file diff --git a/copanier/templates/delivery/show_delivery.html b/copanier/templates/delivery/show_delivery.html index 94fb77f..7c9c2fd 100644 --- a/copanier/templates/delivery/show_delivery.html +++ b/copanier/templates/delivery/show_delivery.html @@ -4,6 +4,8 @@

{{ delivery.name }}

+ {% include "includes/delivery_progress.html" %} +

{% if delivery.products %} {% include "includes/delivery_status.html" %} {% endif %} diff --git a/copanier/templates/includes/delivery_head.html b/copanier/templates/includes/delivery_head.html index 4aa5fc2..7f0b148 100644 --- a/copanier/templates/includes/delivery_head.html +++ b/copanier/templates/includes/delivery_head.html @@ -1,4 +1,4 @@ -
    +
      {% if delivery.description %}
    • Produits {{ delivery.description }}
    • {% endif %}
    • Distribution le
    • Commandes avant le
    • From 0ba6dfcc45d6c9cd3ed682907a3f30fdbd16abe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 7 Apr 2021 21:19:13 +0200 Subject: [PATCH 3/4] Add missing file --- copanier/static/app.css | 3 ++- copanier/templates/includes/delivery_progress.html | 10 ++++++++++ copanier/templates/includes/order_summary.html | 5 +++-- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 copanier/templates/includes/delivery_progress.html diff --git a/copanier/static/app.css b/copanier/static/app.css index bd04af8..c0f4cd2 100644 --- a/copanier/static/app.css +++ b/copanier/static/app.css @@ -566,7 +566,8 @@ details summary { } .rupture { - background-color: #ff000083; + background-color: #ff000083 !important; + text-decoration: line-through; } .list-emails { diff --git a/copanier/templates/includes/delivery_progress.html b/copanier/templates/includes/delivery_progress.html new file mode 100644 index 0000000..af4d04d --- /dev/null +++ b/copanier/templates/includes/delivery_progress.html @@ -0,0 +1,10 @@ +
        +
      • Mise à jour des référent·es
      • +
      • Mise à jour des prix
      • +
      • Commande
      • +
      • Ajustements
      • +
      • Récupération des commandes
      • +
      • Distribution
      • +
      • Répartition des paiements
      • +
      +
      \ No newline at end of file diff --git a/copanier/templates/includes/order_summary.html b/copanier/templates/includes/order_summary.html index d7554a7..efd1581 100644 --- a/copanier/templates/includes/order_summary.html +++ b/copanier/templates/includes/order_summary.html @@ -2,10 +2,11 @@ Produit{% if display_prices %}Prix unitaire{% endif %}Quantité {% for product in delivery.products %} {% if order[product].quantity %} - - {{ product }} + + {{ product }}{% if product.rupture %} (rupture){% endif %} {% if display_prices %}{{ product.price | round(2) }} €{% endif %}{{ order[product].quantity }} x {{ product.unit }} + {% if product.rupture %}{% endif %} {% endif %} {% endfor %} From b26f07ab5a2e6965b2e763b46e9570dddf5c6aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 7 Apr 2021 22:07:03 +0200 Subject: [PATCH 4/4] Display shipping prices in the order summary --- copanier/models.py | 13 ++++++++----- copanier/templates/includes/order_summary.html | 13 +++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/copanier/models.py b/copanier/models.py index 66d559b..bd4bdaf 100644 --- a/copanier/models.py +++ b/copanier/models.py @@ -293,12 +293,15 @@ class Order(Base): p.quantity * _get_price(ref) for ref, p in self.products.items() ) - total_shipping = 0 - if include_shipping: - for producer in producers: - total_shipping = total_shipping + delivery.shipping_for(email, producer) + shipping = self.compute_shipping(delivery, producers, email) if include_shipping else 0 - return round(total_products + total_shipping, 2) + return round(total_products + shipping, 2) + + def compute_shipping(self, delivery, producers, email): + total_shipping = 0 + for producer in producers: + total_shipping = total_shipping + delivery.shipping_for(email, producer) + return total_shipping @property def has_adjustments(self): diff --git a/copanier/templates/includes/order_summary.html b/copanier/templates/includes/order_summary.html index efd1581..4b2ff41 100644 --- a/copanier/templates/includes/order_summary.html +++ b/copanier/templates/includes/order_summary.html @@ -1,13 +1,18 @@ - {% if display_prices %}{% endif %} + {% if display_prices %}{% endif %}{% if display_prices %}{% endif %} {% for product in delivery.products %} {% if order[product].quantity %} - {% if display_prices %}{% endif %} + {% if display_prices %} + + {% endif %} + + {% if display_prices %} + + {% endif %} - {% if product.rupture %}{% endif %} {% endif %} {% endfor %}
      ProduitPrix unitaireQuantité
      ProduitPrix unitaire (€)QuantitéSomme (€)
      {{ product }}{% if product.rupture %} (rupture){% endif %}{{ product.price | round(2) }} €{{ order[product].quantity }} x {{ product.unit }}{{ product.price | round(2) }} €{{ order[product].quantity }} x {{ product.unit }}{{ order.total([product], delivery, group_id, False) }}
      -

      Total: {{ order.total(delivery.products, delivery, group_id) if order else 0 }} €

      +

      Total: {{ order.total(delivery.products, delivery, group_id) if order else 0 }} € (dont {{ order.compute_shipping(delivery, delivery.producers, group_id) | round(2) }} de port)