mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 19:42:37 +02:00
Add Delivery.contact
This commit is contained in:
parent
c020ec89fa
commit
b6ed2b412b
6 changed files with 21 additions and 4 deletions
|
@ -156,6 +156,7 @@ class Delivery(Base):
|
|||
from_date: datetime_field
|
||||
to_date: datetime_field
|
||||
order_before: datetime_field
|
||||
contact: str
|
||||
description: str = ""
|
||||
instructions: str = ""
|
||||
where: str = "Marché de la Briche"
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
<p>Description des produits</p>
|
||||
<input type="text" name="description" value="{{ delivery.description or '' }}" required>
|
||||
</label>
|
||||
<label>
|
||||
<p>Référent</p>
|
||||
<input type="email" name="contact" value="{{ delivery.contact or request.user.email }}" required>
|
||||
</label>
|
||||
<label>
|
||||
<p>Lieu</p>
|
||||
<input type="text" name="where" value="{{ delivery.where or '' }}" required>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<ul class="delivery-head">
|
||||
<li><i class="icon-basket"></i> <strong>Produits</strong> {{ delivery.description }}</li>
|
||||
<li><i class="icon-streetsign"></i> <strong>Lieu</strong> {{ delivery.where }}</li>
|
||||
<li><i class="icon-strategy"></i> <strong>Référent</strong> <a href="mailto:{{ delivery.contact }}">{{ delivery.contact }}</a></li>
|
||||
<li><i class="icon-clock"></i> <strong>Date de livraison</strong> <time datetime="{{ delivery.from_date }}">{{ delivery.from_date|date }} de {{ delivery.from_date|time }} à {{ delivery.to_date|time }}</time></li>
|
||||
<li><i class="icon-hourglass"></i> {% if delivery.status == delivery.OPEN %}<strong>Date limite de commande</strong> <time datetime="{{ delivery.order_before.date() }}">{{ delivery.order_before|date }}</time>{% elif delivery.status == delivery.ADJUSTMENT %}<strong>Ajustement en cours</strong>{% else %}<strong>Fermée</strong>{% endif %}</li>
|
||||
{% if delivery.instructions %}<li><i class="icon-lightbulb"></i> <strong>À savoir</strong> {{ delivery.instructions }}</li>{% endif %}
|
||||
|
|
|
@ -67,6 +67,7 @@ def app(): # Requested by Roll testing utilities.
|
|||
def delivery():
|
||||
return Delivery(
|
||||
producer="Andines",
|
||||
contact="mister@me.me",
|
||||
from_date=datetime.now() + timedelta(days=10),
|
||||
to_date=datetime.now() + timedelta(days=10),
|
||||
order_before=datetime.now() + timedelta(days=7),
|
||||
|
|
|
@ -11,7 +11,11 @@ now = datetime.now
|
|||
|
||||
def test_can_create_delivery():
|
||||
delivery = Delivery(
|
||||
producer="Andines", from_date=now(), to_date=now(), order_before=now()
|
||||
producer="Andines",
|
||||
from_date=now(),
|
||||
to_date=now(),
|
||||
order_before=now(),
|
||||
contact="some@one.to",
|
||||
)
|
||||
assert delivery.producer == "Andines"
|
||||
assert delivery.where == "Marché de la Briche"
|
||||
|
@ -22,7 +26,11 @@ def test_can_create_delivery():
|
|||
def test_wrong_datetime_raise_valueerror():
|
||||
with pytest.raises(ValueError):
|
||||
Delivery(
|
||||
producer="Andines", order_before=now(), to_date=now(), from_date="pouet"
|
||||
producer="Andines",
|
||||
order_before=now(),
|
||||
to_date=now(),
|
||||
from_date="pouet",
|
||||
contact="some@one.to",
|
||||
)
|
||||
|
||||
|
||||
|
@ -56,6 +64,7 @@ def test_can_create_delivery_with_products():
|
|||
to_date=now(),
|
||||
order_before=now(),
|
||||
products=[Product(name="Lait", ref="123", price=1.5)],
|
||||
contact="some@one.to",
|
||||
)
|
||||
assert len(delivery.products) == 1
|
||||
assert delivery.products[0].ref == "123"
|
||||
|
@ -108,7 +117,7 @@ def test_can_load_delivery(delivery):
|
|||
|
||||
|
||||
def test_person_is_staff_if_email_is_in_config(monkeypatch):
|
||||
monkeypatch.setattr(config, 'STAFF', ["foo@bar.fr"])
|
||||
monkeypatch.setattr(config, "STAFF", ["foo@bar.fr"])
|
||||
person = Person(email="foo@bar.fr")
|
||||
assert person.is_staff
|
||||
person = Person(email="foo@bar.org")
|
||||
|
@ -116,7 +125,7 @@ def test_person_is_staff_if_email_is_in_config(monkeypatch):
|
|||
|
||||
|
||||
def test_person_is_staff_if_no_staff_in_config(monkeypatch):
|
||||
monkeypatch.setattr(config, 'STAFF', [])
|
||||
monkeypatch.setattr(config, "STAFF", [])
|
||||
person = Person(email="foo@bar.fr")
|
||||
assert person.is_staff
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ async def test_create_delivery(client):
|
|||
"from_time": "18:30:00",
|
||||
"to_time": "20:00:00",
|
||||
"order_before": "2019-02-12",
|
||||
"contact": "lucky@you.me",
|
||||
}
|
||||
resp = await client.post("/livraison", body=body)
|
||||
assert resp.status == 302
|
||||
|
|
Loading…
Reference in a new issue