Skip to content

Commit

Permalink
[Dépôt de besoin] Répare l'affichage (ou pas) du montant (#944)
Browse files Browse the repository at this point in the history
* Refactor tender detail row in seperate template

* Add tests on amount visibility
  • Loading branch information
raphodn authored Oct 16, 2023
1 parent eb84297 commit c598a21
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 70 deletions.
28 changes: 28 additions & 0 deletions lemarche/templates/tenders/_list_item_detail_row.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% load get_verbose_name %}

<div class="row">
{% if tender.contact_company_name_display %}
<div class="col-md-4" title="Entreprise">
<i class="ri-building-4-line"></i>
{{ tender.contact_company_name_display }}
</div>
{% endif %}
<div class="col-md-4" title="{% get_verbose_name tender 'location' %}">
{% if tender.perimeters_list_string %}
<i class="ri-map-pin-2-line"></i>
{{ tender.location_display|safe }}
{% endif %}
</div>
<div class="col-md-4" title="{% get_verbose_name tender 'sectors' %} : {{ tender.sectors_full_list_string|safe }}">
{% if tender.sectors.count %}
<i class="ri-award-line"></i>
{{ tender.sectors_list_string|safe }}
{% endif %}
</div>
{% if tender.accept_share_amount %}
<div class="col-md-4" title="{% get_verbose_name tender 'amount' %}">
<i class="ri-money-euro-circle-line"></i>
{{ tender.get_amount_display|default:"-" }}
</div>
{% endif %}
</div>
60 changes: 20 additions & 40 deletions lemarche/templates/tenders/_list_item_network.html
Original file line number Diff line number Diff line change
@@ -1,54 +1,34 @@
{% load static humanize get_verbose_name %}
{% load static humanize %}

<div class="card c-card c-card--marche c-card--link siae-card" role="button" data-url="{% url 'dashboard_networks:tender_detail' network.slug tender.slug %}">
<div class="card-body">
<div class="row">
<div class="col-md-8" style="border-right:1px solid;">
<p class="mb-1">
Date de clôture : {{ tender.deadline_date|default:"" }}
{% if tender.deadline_date_is_outdated %}
<span class="badge badge-sm badge-base badge-pill badge-pilotage">Clôturé</span>
{% endif %}
<span class="float-right badge badge-base badge-pill badge-emploi">
{% if tender.kind == "PROJ" %}
{{ title_kind_sourcing_siae|default:tender.get_kind_display }}
{% else %}
{{ tender.get_kind_display }}
{% endif %}
</span>
</p>
<div class="row">
<div class="col-md-12">
<p class="mb-1">
Date de clôture : {{ tender.deadline_date|default:"" }}
{% if tender.deadline_date_is_outdated %}
<span class="badge badge-sm badge-base badge-pill badge-pilotage">Clôturé</span>
{% endif %}
<span class="float-right badge badge-base badge-pill badge-emploi">
{% if tender.kind == "PROJ" %}
{{ title_kind_sourcing_siae|default:tender.get_kind_display }}
{% else %}
{{ tender.get_kind_display }}
{% endif %}
</span>
</p>
</div>
</div>

<h2 class="py-2">{{ tender.title }}</h2>

<hr />

<div class="row">
{% if tender.contact_company_name_display %}
<div class="col-md-4" title="Entreprise">
<i class="ri-building-4-line"></i>
{{ tender.contact_company_name_display }}
</div>
{% endif %}
<div class="col-md-4" title="{% get_verbose_name tender 'location' %}">
{% if tender.perimeters_list_string %}
<i class="ri-map-pin-2-line"></i>
{{ tender.location_display|safe }}
{% endif %}
</div>
<div class="col-md-4" title="{% get_verbose_name tender 'sectors' %} : {{ tender.sectors_full_list_string|safe }}">
{% if tender.sectors.count %}
<i class="ri-award-line"></i>
{{ tender.sectors_list_string|safe }}
{% endif %}
</div>
<div class="col-md-4" title="{% get_verbose_name tender 'amount' %}">
{% if tender.amount %}
<i class="ri-money-euro-circle-line"></i>
{{ tender.get_amount_display|default:"-" }}
{% endif %}
</div>
</div>
{% include "tenders/_list_item_detail_row.html" with tender=tender %}
</div>

<div class="col-md-4 text-center my-auto">
<hr class="d-md-none" />
<div class="row">
Expand Down
29 changes: 2 additions & 27 deletions lemarche/templates/tenders/_list_item_siae.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static humanize get_verbose_name %}
{% load static humanize %}

<div class="card c-card c-card--marche c-card--link siae-card" role="button" data-url="{% url 'tenders:detail' tender.slug %}">
<div class="card-body">
Expand Down Expand Up @@ -27,31 +27,6 @@ <h2 class="py-2">{{ tender.title }}</h2>

<hr />

<div class="row">
{% if tender.contact_company_name_display %}
<div class="col-md-4" title="Entreprise">
<i class="ri-building-4-line"></i>
{{ tender.contact_company_name_display }}
</div>
{% endif %}
<div class="col-md-4" title="{% get_verbose_name tender 'location' %}">
{% if tender.perimeters_list_string %}
<i class="ri-map-pin-2-line"></i>
{{ tender.location_display|safe }}
{% endif %}
</div>
<div class="col-md-4" title="{% get_verbose_name tender 'sectors' %} : {{ tender.sectors_full_list_string|safe }}">
{% if tender.sectors.count %}
<i class="ri-award-line"></i>
{{ tender.sectors_list_string|safe }}
{% endif %}
</div>
<div class="col-md-4" title="{% get_verbose_name tender 'amount' %}">
{% if tender.amount %}
<i class="ri-money-euro-circle-line"></i>
{{ tender.get_amount_display|default:"-" }}
{% endif %}
</div>
</div>
{% include "tenders/_list_item_detail_row.html" with tender=tender %}
</div>
</div>
6 changes: 5 additions & 1 deletion lemarche/www/dashboard_networks/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ def setUpTestData(cls):
cls.network_2 = NetworkFactory(name="Liste 2")
cls.user_network_1 = UserFactory(kind=User.KIND_PARTNER, partner_network=cls.network_1)
cls.user_network_2 = UserFactory(kind=User.KIND_PARTNER, partner_network=cls.network_2)
cls.user_buyer = UserFactory(kind=User.KIND_BUYER)
cls.user_buyer = UserFactory(kind=User.KIND_BUYER, company_name="Entreprise Buyer")
cls.user_without_network = UserFactory(kind=User.KIND_PARTNER)
cls.siae_1 = SiaeFactory(networks=[cls.network_1])
cls.siae_2 = SiaeFactory()
cls.tender_1 = TenderFactory(
author=cls.user_buyer,
amount=tender_constants.AMOUNT_RANGE_100_150,
accept_share_amount=False,
status=tender_constants.STATUS_VALIDATED,
validated_at=timezone.now(),
deadline_date=timezone.now() - timedelta(days=5),
Expand Down Expand Up @@ -94,6 +96,8 @@ def test_tender_list_in_network_tender_list(self):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.tender_1.title)
self.assertContains(response, "Entreprise Buyer")
self.assertNotContains(response, "K€") # !accept_share_amount
self.assertContains(response, "1 adhérent notifié")
self.assertNotContains(response, self.tender_2.title)

Expand Down
9 changes: 7 additions & 2 deletions lemarche/www/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TenderCreateViewTest(TestCase):
@classmethod
def setUpTestData(cls):
cls.user_siae = UserFactory(kind=User.KIND_SIAE)
cls.user_buyer = UserFactory(kind=User.KIND_BUYER, company_name="Test")
cls.user_buyer = UserFactory(kind=User.KIND_BUYER, company_name="Entreprise Buyer")
cls.sectors = [SectorFactory().slug for _ in range(3)]
cls.location_slug = PerimeterFactory().slug

Expand Down Expand Up @@ -343,7 +343,7 @@ def setUpTestData(cls):
cls.siae_1 = SiaeFactory()
cls.siae_2 = SiaeFactory(post_code=perimeter.post_codes[0])
cls.siae_user_2 = UserFactory(kind=User.KIND_SIAE, siaes=[cls.siae_1])
cls.user_buyer_1 = UserFactory(kind=User.KIND_BUYER)
cls.user_buyer_1 = UserFactory(kind=User.KIND_BUYER, company_name="Entreprise Buyer")
cls.user_buyer_2 = UserFactory(kind=User.KIND_BUYER)
cls.user_partner = UserFactory(kind=User.KIND_PARTNER)
cls.tender = TenderFactory(author=cls.user_buyer_1, validated_at=timezone.now(), perimeters=[perimeter])
Expand All @@ -352,6 +352,8 @@ def setUpTestData(cls):
)
cls.tender_3 = TenderFactory(
author=cls.user_buyer_1,
amount=tender_constants.AMOUNT_RANGE_100_150,
accept_share_amount=False,
validated_at=timezone.now(),
deadline_date=timezone.now() - timedelta(days=5),
perimeters=[perimeter],
Expand Down Expand Up @@ -386,6 +388,9 @@ def test_siae_user_should_see_matching_tenders(self):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context["tenders"]), 1)
self.assertContains(response, self.tender_3.title)
self.assertContains(response, "Entreprise Buyer")
self.assertNotContains(response, "K€") # !accept_share_amount
self.assertNotContains(response, "2 prestataires ciblés") # tender_3, but only visible to author
self.assertNotContains(response, "1 prestataire intéressé") # tender_3, but only visible to author

Expand Down

0 comments on commit c598a21

Please sign in to comment.