Skip to content

Commit

Permalink
Affichage des dépôts de besoins de type sourcing et anonyme côté util…
Browse files Browse the repository at this point in the history
…isateur (#961)

* add field to get be anonymous on tender published

* display response_is_anonymous only if tender is a Project

* external link is required if tender is tender kind

* make tests

* fix migration

* fix migration

* add field to get be anonymous on tender published

* update messages for anonymous tenders

* manage anonymous consultations

* remove siae_has_detail_contact_click_date

* fix bug for test environnement

* fix migration
  • Loading branch information
madjid-asa authored Nov 8, 2023
1 parent 3ecee18 commit d375910
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 68 deletions.
2 changes: 1 addition & 1 deletion lemarche/templates/tenders/_detail_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h1>
{% elif user_partner_can_display_tender_contact_details %}
<hr class="my-5">
{% include "tenders/_detail_contact.html" with tender=tender %}
{% elif user_siae_has_detail_contact_click_date and not tender.deadline_date_outdated %}
{% elif siae_has_detail_contact_click_date and not tender.deadline_date_outdated %}
<!-- for SIAE, contact details are displayed above (see tenders/detail.html) -->
{% endif %}
{% endif %}
Expand Down
15 changes: 11 additions & 4 deletions lemarche/templates/tenders/_detail_cta.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<div class="card c-card rounded-lg shadow-lg">
<div class="card-body">
<h3>{{ tender.cta_card_title_text|safe }}</h3>

<p>{{ tender.cta_card_paragraph_text|safe }}</p>

{% if user_can_click %}
<button type="button" id="show-tender-contact-modal-btn" class="btn btn-primary btn-block" data-toggle="modal" data-target="#detail_contact_click_confirm_modal" data-siae-id="{{ siae_id }}" title="{{ tender.cta_card_button_text|safe }}">
{{ tender.cta_card_button_text|safe }}
</button>
{% if tender_is_anonymous %}
<form method="POST" action="{% url 'tenders:detail-contact-click-stat' tender.slug %}?siae_id={{ siae_id }}">
{% csrf_token %}
<button type="submit" class="btn btn-primary btn-block" name="detail_contact_click_confirm" value="true">{{ tender.cta_card_button_text|safe }}</button>
</form>
{% else %}
<button type="button" id="show-tender-contact-modal-btn" class="btn btn-primary btn-block" data-toggle="modal" data-target="#detail_contact_click_confirm_modal" data-siae-id="{{ siae_id }}" title="{{ tender.cta_card_button_text|safe }}">
{{ tender.cta_card_button_text|safe }}
</button>
{% endif %}
{% else %}
<a href="#" id="show-tender-contact-modal-btn" class="btn btn-primary btn-block" data-toggle="modal" data-target="#login_or_signup_siae_tender_modal" data-next-params="{% url 'tenders:detail' tender.slug %}">
<span>{{ tender.cta_card_button_text|safe }}</span>
Expand Down
52 changes: 52 additions & 0 deletions lemarche/templates/tenders/_detail_side_infos_author.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{% if tender.is_draft %}
<div class="alert alert-warning fade show" role="status">
<div class="row">
<div class="col-auto pr-0">
<i class="ri-information-line ri-xl text-warning"></i>
</div>
<div class="col">
<p class="mb-0">Votre {{ tender_kind_display|default:tender.get_kind_display }} est encore en brouillon. Modifiez-le pour le publier.</p>
</div>
</div>
</div>
<a href="{% url 'tenders:update' tender.slug %}" class="btn btn-primary btn-ico">
<i class="ri-pencil-fill ri-lg font-weight-normal" aria-hidden="true"></i>
<span>Modifier</span>
</a>
{% endif %}
{% if tender.is_pending_validation %}
<div class="alert alert-info fade show" role="status">
<div class="row">
<div class="col-auto pr-0">
<i class="ri-information-line ri-xl text-info"></i>
</div>
<div class="col">
<p class="mb-0">Votre {{ tender_kind_display|default:tender.get_kind_display }} est en cours de validation.</p>
</div>
</div>
</div>
{% endif %}
{% if tender.is_validated %}
<div class="alert alert-success fade show" role="status">
<div class="row">
<div class="col-auto pr-0">
<i class="ri-checkbox-circle ri-xl text-info"></i>
</div>
<div class="col">
<p class="mb-0">Votre {{ tender_kind_display|default:tender.get_kind_display }} est validé et envoyé !</p>
</div>
</div>
</div>
<a href="{% url 'tenders:detail-siae-list' tender.slug %}" id="show-tender-siae-list-from-detail-btn" class="btn btn-primary mb-3">
<i class="ri-focus-2-line"></i>
{{ tender.siae_email_send_date_count }} prestataire{{ tender.siae_email_send_date_count|pluralize }} ciblé{{ tender.siae_email_send_date_count|pluralize }}
</a>
<a href="{% url 'tenders:detail-siae-list' tender.slug "VIEWED" %}" id="show-tender-siae-list-from-detail-btn" class="btn btn-primary mb-3">
<i class="ri-focus-2-line"></i>
{{ tender.siae_email_link_click_date_or_detail_display_date_count }} prestataire{{ tender.siae_email_link_click_date_or_detail_display_date_count|pluralize }} qui {{ tender.siae_email_link_click_date_or_detail_display_date_count|pluralize:'a,ont' }} vu
</a>
<a href="{% url 'tenders:detail-siae-list' tender.slug "INTERESTED" %}" id="show-tender-siae-interested-list-from-detail-btn" class="btn btn-primary mb-3">
<i class="ri-thumb-up-line"></i>
{{ tender.siae_detail_contact_click_date_count }} prestataire{{ tender.siae_detail_contact_click_date_count|pluralize }} intéressé{{ tender.siae_detail_contact_click_date_count|pluralize }}
</a>
{% endif %}
8 changes: 8 additions & 0 deletions lemarche/templates/tenders/_detail_success_contact.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="card c-card rounded-lg shadow-lg">
<div class="card-body">
<h3>Votre intérêt a été signalé au client</h3>

<p>S’il est intéressé, il vous recontactera via vos coordonnées de contact présentes sur votre fiche commerciale (<a href="{% url 'dashboard:home' %}">Vérifier votre fiche</a>).</p>

</div>
</div>
86 changes: 25 additions & 61 deletions lemarche/templates/tenders/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
<section class="s-section">
<div class="s-section__container container">
{# Afficher les contacts en haut + conseil #}
{% if not tender.deadline_date_outdated %}
{% if user_siae_has_detail_contact_click_date or siae_has_detail_contact_click_date %}
{% if not tender.deadline_date_outdated and not tender.response_is_anonymous %}
{% if siae_has_detail_contact_click_date %}
<div class="row">
<div class="col-12 col-lg-8">
<div class="alert alert-info fade show" role="status">
{% include "tenders/_detail_contact.html" with tender=tender source="alert" %}
{% if not tender.response_is_anonymous %}
<div class="col-12 col-lg-8">
<div class="alert alert-info fade show" role="status">
{% include "tenders/_detail_contact.html" with tender=tender source="alert" %}
</div>
</div>
</div>
{% endif %}
<div class="col-12 col-lg-4">
<div class="alert alert-info mt-3 mt-lg-0" role="alert">
<p class="mb-1">
Expand All @@ -58,64 +60,16 @@
</div>
{# Sidebar with actions #}
<div class="col-12 col-lg-4 order-1 order-lg-2">
{% comment %} admin info {% endcomment %}
{% if is_admin %}
{% include "tenders/_detail_admin_extra_info.html" with tender=tender %}
{% endif %}
{% comment %} details author {% endcomment %}
{% if user == tender.author %}
{% if tender.is_draft %}
<div class="alert alert-warning fade show" role="status">
<div class="row">
<div class="col-auto pr-0">
<i class="ri-information-line ri-xl text-warning"></i>
</div>
<div class="col">
<p class="mb-0">Votre {{ tender_kind_display|default:tender.get_kind_display }} est encore en brouillon. Modifiez-le pour le publier.</p>
</div>
</div>
</div>
<a href="{% url 'tenders:update' tender.slug %}" class="btn btn-primary btn-ico">
<i class="ri-pencil-fill ri-lg font-weight-normal" aria-hidden="true"></i>
<span>Modifier</span>
</a>
{% endif %}
{% if tender.is_pending_validation %}
<div class="alert alert-info fade show" role="status">
<div class="row">
<div class="col-auto pr-0">
<i class="ri-information-line ri-xl text-info"></i>
</div>
<div class="col">
<p class="mb-0">Votre {{ tender_kind_display|default:tender.get_kind_display }} est en cours de validation.</p>
</div>
</div>
</div>
{% endif %}
{% if tender.is_validated %}
<div class="alert alert-success fade show" role="status">
<div class="row">
<div class="col-auto pr-0">
<i class="ri-checkbox-circle ri-xl text-info"></i>
</div>
<div class="col">
<p class="mb-0">Votre {{ tender_kind_display|default:tender.get_kind_display }} est validé et envoyé !</p>
</div>
</div>
</div>
<a href="{% url 'tenders:detail-siae-list' tender.slug %}" id="show-tender-siae-list-from-detail-btn" class="btn btn-primary mb-3">
<i class="ri-focus-2-line"></i>
{{ tender.siae_email_send_date_count }} prestataire{{ tender.siae_email_send_date_count|pluralize }} ciblé{{ tender.siae_email_send_date_count|pluralize }}
</a>
<a href="{% url 'tenders:detail-siae-list' tender.slug "VIEWED" %}" id="show-tender-siae-list-from-detail-btn" class="btn btn-primary mb-3">
<i class="ri-focus-2-line"></i>
{{ tender.siae_email_link_click_date_or_detail_display_date_count }} prestataire{{ tender.siae_email_link_click_date_or_detail_display_date_count|pluralize }} qui {{ tender.siae_email_link_click_date_or_detail_display_date_count|pluralize:'a,ont' }} vu
</a>
<a href="{% url 'tenders:detail-siae-list' tender.slug "INTERESTED" %}" id="show-tender-siae-interested-list-from-detail-btn" class="btn btn-primary mb-3">
<i class="ri-thumb-up-line"></i>
{{ tender.siae_detail_contact_click_date_count }} prestataire{{ tender.siae_detail_contact_click_date_count|pluralize }} intéressé{{ tender.siae_detail_contact_click_date_count|pluralize }}
</a>
{% endif %}
{% include "tenders/_detail_side_infos_author.html" %}
{% else %}
{% if not tender.deadline_date_outdated %}
{% comment %} stats of views {% endcomment %}
{% if tender.siae_email_link_click_date_or_detail_display_date_count > 0 %}
<div class="alert alert-warning mt-3 mt-lg-0" role="alert">
<p class="mb-0 fs-sm">
Expand All @@ -124,7 +78,8 @@
</p>
</div>
{% endif %}
{% if user.is_authenticated %}
{% if user.is_authenticated and not tender.response_is_anonymous %}
{% comment %} infos for partner {% endcomment %}
{% if user.kind == user.KIND_PARTNER %}
{% if not user_partner_can_display_tender_contact_details %}
<div class="alert alert-info" role="alert">
Expand All @@ -139,6 +94,7 @@
</p>
</div>
{% endif %}
{% comment %} infos for siaes {% endcomment %}
{% elif user.kind == user.KIND_SIAE %}
{% if not user.has_siae %}
<div class="alert alert-info" role="alert">
Expand All @@ -153,18 +109,26 @@
Besoin d'aide ? contacter le support via le chat en ligne qui se trouve en bas à droite.
</p>
</div>
{% elif not user_siae_has_detail_contact_click_date %}
{% elif not siae_has_detail_contact_click_date %}
{% include "tenders/_detail_cta.html" with tender=tender user_can_click=True %}
{% include "tenders/_detail_cta_cocontracting.html" with tender=tender %}
{% endif %}
{% endif %}
{% elif siae_id %}
{% comment %} if siae_id {% endcomment %}
{% elif siae_id and not tender.response_is_anonymous %}
{% if not siae_has_detail_contact_click_date %}
{% include "tenders/_detail_cta.html" with tender=tender user_can_click=True siae_id=siae_id %}
{% include "tenders/_detail_cta_cocontracting.html" with tender=tender siae_id=siae_id %}
{% else %}
{% include "tenders/_detail_contact.html" with tender=tender %}
{% endif %}
{% comment %} for anonymous tenders {% endcomment %}
{% elif tender.response_is_anonymous and siae_id or tender.response_is_anonymous and user.is_authenticated %}
{% if not siae_has_detail_contact_click_date %}
{% include "tenders/_detail_cta.html" with tender=tender user_can_click=True tender_is_anonymous=True %}
{% else %}
{% include "tenders/_detail_success_contact.html" %}
{% endif %}
{% else %}
{% include "tenders/_detail_cta.html" with tender=tender user_can_click=False %}
{% endif %}
Expand Down
4 changes: 3 additions & 1 deletion lemarche/tenders/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ckeditor.widgets import CKEditorWidget
from django import forms
from django.conf import settings
from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
from django.db import models
Expand Down Expand Up @@ -488,7 +489,8 @@ def response_change(self, request, obj: Tender):
if request.POST.get("_validate_tender"):
update_and_send_tender_task(tender=obj)
self.message_user(request, "Ce dépôt de besoin a été validé et envoyé aux structures")
api_hubspot.create_deal_from_tender(tender=obj)
if settings.BITOUBI_ENV == "prod":
api_hubspot.create_deal_from_tender(tender=obj)

return HttpResponseRedirect(".")
elif request.POST.get("_restart_tender"):
Expand Down
4 changes: 4 additions & 0 deletions lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ def cta_card_paragraph_text(self):
return "Accéder à l'appel d'offres afin d'y répondre."
elif self.kind == tender_constants.KIND_QUOTE:
return "Accéder aux coordonnées du client afin de lui envoyer un devis."
elif self.kind == tender_constants.KIND_PROJECT and self.response_is_anonymous:
return "Manifestez votre intérêt au client. S’il est intéressé, le client vous recontactera via les coordonnées présentes sur votre fiche commerciale." # noqa
elif self.kind == tender_constants.KIND_PROJECT:
return "Accéder aux coordonnées du client afin de lui présenter vos services et produits."
# just in case
Expand All @@ -554,6 +556,8 @@ def cta_card_paragraph_text(self):
def cta_card_button_text(self):
if self.kind == tender_constants.KIND_TENDER:
return "Voir l'appel d'offres"
elif self.kind == tender_constants.KIND_PROJECT and self.response_is_anonymous:
return "Je suis intéressé !"
return "Accéder aux coordonnées"

@cached_property
Expand Down
2 changes: 1 addition & 1 deletion lemarche/www/tenders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def get_context_data(self, **kwargs):
).exists()
if user.is_authenticated:
if user.kind == User.KIND_SIAE:
context["user_siae_has_detail_contact_click_date"] = TenderSiae.objects.filter(
context["siae_has_detail_contact_click_date"] = TenderSiae.objects.filter(
tender=self.object, siae__in=user.siaes.all(), detail_contact_click_date__isnull=False
).exists()
if show_nps:
Expand Down

0 comments on commit d375910

Please sign in to comment.