Skip to content

Commit

Permalink
change header links on siae home
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Apr 10, 2024
1 parent d3a0e1a commit f4a1694
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 86 deletions.
38 changes: 38 additions & 0 deletions lemarche/fixtures/django/20_cms.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,33 @@
"alias_of": null
}
},
{
"model": "wagtailcore.page",
"pk": 26,
"fields": {
"path": "000100030002",
"depth": 3,
"numchild": 0,
"translation_key": "0130778f-b6be-4452-b77e-7e77caa90905",
"locale": 1,
"live": true,
"first_published_at": "2024-03-21T13:54:56.071Z",
"last_published_at": "2024-04-10T09:25:21.128Z",
"title": "accueil-structure",
"draft_title": "accueil-structure",
"slug": "accueil-structure",
"content_type": [
"cms",
"homepage"
],
"url_path": "/accueil/accueil-structure/",
"owner": null,
"seo_title": "",
"show_in_menus": false,
"search_description": "",
"alias_of": null
}
},
{
"model": "cms.articlecategory",
"pk": 1,
Expand Down Expand Up @@ -729,5 +756,16 @@
"banner_cta_section": "[{\"id\": \"3db2bf05-a9c7-4e38-b81f-e49c4fcf56e3\", \"type\": \"cta_primary\", \"value\": {\"cta_id\": \"home-demande\", \"cta_href\": \"/besoins/ajouter/\", \"cta_icon\": \"ri-mail-send-line\", \"cta_text\": \"Publier votre besoin d'achat\"}}, {\"id\": \"b736600e-2ef4-4ae3-8c29-3f0eabbfe59d\", \"type\": \"cta_secondary\", \"value\": {\"cta_id\": \"home-siae-search\", \"cta_href\": \"/prestataires/\", \"cta_icon\": \"ri-search-line\", \"cta_text\": \"Rechercher un prestataire\"}}]",
"content": "[{\"id\": \"bd7d5806-3595-4326-b296-056ab6d32f14\", \"type\": \"website_stats\", \"value\": {}}, {\"id\": \"d7a2467a-3cb9-4523-873c-0db0d6390a78\", \"type\": \"section_why_call_siaes\", \"value\": {\"title\": \"Pourquoi faire appel \\u00e0 un prestataire inclusif ?\"}}, {\"id\": \"a7c18544-3e7b-466a-addc-b0322aec9018\", \"type\": \"section_our_ressources\", \"value\": {\"title\": \"Nos ressources\"}}]"
}
},
{
"model": "cms.homepage",
"pk": 26,
"fields": {
"banner_title": "Recevez gratuitement des opportunités commerciales",
"banner_subtitle": "",
"banner_arguments_list": "[{\"id\": \"af0cf07b-f716-4783-a89a-9013f41ae692\", \"type\": \"item\", \"value\": \"R\\u00e9f\\u00e9rencez votre structure inclusive gratuitement\"}, {\"id\": \"d73c95ef-5fef-47c4-9ea6-5d8240961a27\", \"type\": \"item\", \"value\": \"Recevez des demandes de clients directement dans votre bo\\u00eete e-mail\"}, {\"id\": \"768e3efd-aebe-40b6-a9c3-7461c66423be\", \"type\": \"item\", \"value\": \"D\\u00e9veloppez votre activit\\u00e9 commerciale\"}]",
"banner_cta_section": "[{\"id\": \"da4ce9a4-14fa-4392-ba81-44e212ff06b7\", \"type\": \"cta_primary\", \"value\": {\"cta_id\": \"accueil-deconnecte-btn-referencer-structure\", \"cta_href\": \"/accounts/signup/\", \"cta_icon\": \"ri-building-4-line\", \"cta_text\": \"R\\u00e9f\\u00e9rencer ma structure\"}}, {\"id\": \"03a01e39-c9b7-4084-8b95-37d4566983f2\", \"type\": \"cta_secondary\", \"value\": {\"cta_id\": \"accueil-deconnecte-btn-reserver-demo\", \"cta_href\": \"/\", \"cta_icon\": \"ri-calendar-line\", \"cta_text\": \"R\\u00e9server une d\\u00e9mo\"}}, {\"id\": \"b3ae7b98-9b43-4729-aabc-c7e6793fbda0\", \"type\": \"cta_primary_auth\", \"value\": {\"cta_id\": \"accueil-connecte-btn-reserver-demo\", \"cta_href\": \"/\", \"cta_icon\": \"ri-calendar-line\", \"cta_text\": \"R\\u00e9server une d\\u00e9mo\"}}]",
"content": "[{\"id\": \"474fec81-6fa7-4044-b161-e065a84600bf\", \"type\": \"section_what_find_here\", \"value\": {\"cards\": [{\"id\": \"06fabc8c-6159-457b-aa89-0fe15d679f21\", \"type\": \"card\", \"value\": {\"ico\": \"ico-bicro-marche-main\", \"text\": \"Recevez des opportunit\\u00e9s commerciales directement dans votre boite email\"}}, {\"id\": \"fc38faca-24d7-4f86-9b07-4a1e2207b9eb\", \"type\": \"card\", \"value\": {\"ico\": \"ico-bicro-marche-presta\", \"text\": \"Acc\\u00e9dez aux coordonn\\u00e9es de contact du client et contactez-le rapidement\"}}, {\"id\": \"9b58a8de-af3f-4415-b9ec-16898a7a0ade\", \"type\": \"card\", \"value\": {\"ico\": \"ico-bicro-marche-contrat\", \"text\": \"Mettez toutes les chances de votre c\\u00f4t\\u00e9 en envoyant votre meilleure offre au client.\"}}], \"title\": \"Comment \\u00e7a marche ?\"}}]"
}
}
]
124 changes: 63 additions & 61 deletions lemarche/templates/auth/_login_or_signup_modal.html
Original file line number Diff line number Diff line change
@@ -1,74 +1,76 @@
{% load static %}
{% load theme_inclusion %}

<style>
.remix {
width: 24px;
height: 24px;
fill: #333;
}
</style>
<div class="modal fade modal-siae" id="login_or_signup_modal" tabindex="-1" role="dialog" aria-modal="true" data-backdrop="static" data-keyboard="false" aria-labelledby="exampleModalLabel">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="exampleModalLabel">Profitez gratuitement du Marché</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
<i class="ri-close-line"></i>
</button>
</div>
<div class="modal-body home-content-body">
<p class="mb-4">
Ce ne sera pas long ! Inscrivez-vous et accédez à toutes les fonctionnalités du marché.
</p>
<ul class="list-unstyled mb-5">
<li class="d-flex mb-2">
<i class="text-success ri-checkbox-circle-fill display-2"></i>
<span class="font-weight-bold ml-2">Publiez vos besoins auprès des structures, et retrouvez celles qui sont intéressées.</span>
</li>
<li class="d-flex mb-2">
<i class="text-success ri-checkbox-circle-fill display-2"></i>
<span class="font-weight-bold ml-2">Téléchargez la liste complète des structures figurant sur le marché.</span>
</li>
<li class="d-flex mb-2">
<i class="text-success ri-checkbox-circle-fill display-2"></i>
<span class="font-weight-bold ml-2">Créez des listes d'achat et sauvegardez vos structures favorites.</span>
</li>
<li class="d-flex mb-2">
<i class="text-success ri-checkbox-circle-fill display-2"></i>
<span class="font-weight-bold ml-2">Accédez aux coordonnées des structures.</span>
</li>
</ul>
<div class="text-center">
<a href="{% url 'auth:signup' %}?next=next-params-to-replace" id="auth-link" class="btn btn-sm btn-primary">Créer un compte</a>
{% if not user.is_authenticated %}
<style>
.remix {
width: 24px;
height: 24px;
fill: #333;
}
</style>
<div class="modal fade modal-siae" id="login_or_signup_modal" tabindex="-1" role="dialog" aria-modal="true" data-backdrop="static" data-keyboard="false" aria-labelledby="exampleModalLabel">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="exampleModalLabel">Profitez gratuitement du Marché</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
<i class="ri-close-line"></i>
</button>
</div>
<hr class="my-5" data-text="ou" />
<div class="text-center">
<p class="mb-0">Vous avez déjà un compte ?</p>
<a href="{% url 'auth:login' %}?next=next-params-to-replace" id="auth-link" class="btn btn-sm btn-link">Se connecter</a>
<div class="modal-body home-content-body">
<p class="mb-4">
Ce ne sera pas long ! Inscrivez-vous et accédez à toutes les fonctionnalités du marché.
</p>
<ul class="list-unstyled mb-5">
<li class="d-flex mb-2">
<i class="text-success ri-checkbox-circle-fill display-2"></i>
<span class="font-weight-bold ml-2">Publiez vos besoins auprès des structures, et retrouvez celles qui sont intéressées.</span>
</li>
<li class="d-flex mb-2">
<i class="text-success ri-checkbox-circle-fill display-2"></i>
<span class="font-weight-bold ml-2">Téléchargez la liste complète des structures figurant sur le marché.</span>
</li>
<li class="d-flex mb-2">
<i class="text-success ri-checkbox-circle-fill display-2"></i>
<span class="font-weight-bold ml-2">Créez des listes d'achat et sauvegardez vos structures favorites.</span>
</li>
<li class="d-flex mb-2">
<i class="text-success ri-checkbox-circle-fill display-2"></i>
<span class="font-weight-bold ml-2">Accédez aux coordonnées des structures.</span>
</li>
</ul>
<div class="text-center">
<a href="{% url 'auth:signup' %}?next=next-params-to-replace" id="auth-link" class="btn btn-sm btn-primary">Créer un compte</a>
</div>
<hr class="my-5" data-text="ou" />
<div class="text-center">
<p class="mb-0">Vous avez déjà un compte ?</p>
<a href="{% url 'auth:login' %}?next=next-params-to-replace" id="auth-link" class="btn btn-sm btn-link">Se connecter</a>
</div>
</div>
</div>
</div>
</div>
</div>

<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
const MODAL_ID = '#login_or_signup_modal';
$(MODAL_ID).on('show.bs.modal', function (event) {
// Button that triggered the modal
var button = $(event.relatedTarget);
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
const MODAL_ID = '#login_or_signup_modal';
$(MODAL_ID).on('show.bs.modal', function (event) {
// Button that triggered the modal
var button = $(event.relatedTarget);

// Extract info from data-* attributes
var nextParams = button.data('next-params');
// Extract info from data-* attributes
var nextParams = button.data('next-params');

// Update the modal's content
// - replace next param for login & signup
var modal = document.querySelector(MODAL_ID);
modal.querySelectorAll('#auth-link').forEach(link => {
var linkUrl = link.getAttribute('href');
link.setAttribute('href', linkUrl.replace('next-params-to-replace', nextParams));
// Update the modal's content
// - replace next param for login & signup
var modal = document.querySelector(MODAL_ID);
modal.querySelectorAll('#auth-link').forEach(link => {
var linkUrl = link.getAttribute('href');
link.setAttribute('href', linkUrl.replace('next-params-to-replace', nextParams));
});
});
});
});
</script>
</script>
{% endif %}
66 changes: 41 additions & 25 deletions lemarche/templates/layouts/_header_nav_primary_items.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
Demandes reçues{% if tender_siae_unread_count %} <span class="badge badge-pill badge-important fs-xs">{{ tender_siae_unread_count }}</span>{% endif %}
</a>
</li>
{% else %}
<li>
<a href="{% url 'tenders:create' %}" id="header-demande" class="btn btn-primary btn-ico">
<i class="ri-mail-send-line ri-lg"></i>
<span>Publier un besoin d'achat</span>
</a>
</li>
{% endif %}
<li>
<a href="{% url 'tenders:create' %}" id="header-demande" class="btn btn-primary btn-ico">
<i class="ri-mail-send-line ri-lg"></i>
<span>Publier un besoin d'achat</span>
</a>
</li>
<li>
<div class="dropdown">
<button class="btn btn-outline-primary dropdown-toggle{% if is_mobile %} mb-3" type="button{% endif %}"
Expand Down Expand Up @@ -42,24 +43,39 @@
</div>
</li>
{% else %}
<li>
<a href="{% url 'tenders:create' %}" id="header-demande"
class="btn btn-link btn-ico {% if is_mobile %}mh-auto p-0{% endif %}">
<i class="ri-mail-send-line ri-lg"></i>
<span>Publier un besoin d'achat</span>
</a>
</li>
<li>
<a href="{% url 'auth:signup' %}" id="h_signup" class="btn btn-outline-primary btn-ico">
<i class="ri-user-add-line ri-lg"></i>
<span>S'inscrire</span>
</a>
</li>
<li>
<a href="{% url 'auth:login' %}" id="h_login" class="btn btn-primary btn-ico">
<i class="ri-login-box-line ri-lg"></i>
<span>Se connecter</span>
</a>
</li>
{% if page and page.slug == "accueil-structure" %}
<li>
<a href="{% url 'auth:signup' %}" id="header-signup-siae" class="btn btn-primary btn-ico">
<i class="ri-building-line ri-lg"></i>
<span>Référencé ma structure</span>
</a>
</li>
<li>
<a href="{% url 'auth:login' %}" id="h_login" class="btn btn-outline-primary btn-ico">
<i class="ri-login-box-line ri-lg"></i>
<span>Se connecter</span>
</a>
</li>
{% else %}
<li>
<a href="{% url 'tenders:create' %}" id="header-demande"
class="btn btn-link btn-ico {% if is_mobile %}mh-auto p-0{% endif %}">
<i class="ri-mail-send-line ri-lg"></i>
<span>Publier un besoin d'achat</span>
</a>
</li>
<li>
<a href="{% url 'auth:signup' %}" id="h_signup" class="btn btn-outline-primary btn-ico">
<i class="ri-user-add-line ri-lg"></i>
<span>S'inscrire</span>
</a>
</li>
<li>
<a href="{% url 'auth:login' %}" id="h_login" class="btn btn-primary btn-ico">
<i class="ri-login-box-line ri-lg"></i>
<span>Se connecter</span>
</a>
</li>
{% endif %}
{% endif %}
</ul>
99 changes: 99 additions & 0 deletions lemarche/www/pages/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from django.test import TestCase
from django.urls import reverse

from lemarche.siaes.factories import SiaeFactory
from lemarche.users.factories import UserFactory
from lemarche.users.models import User


class PagesHeaderLinkTest(TestCase):
fixtures = [
"lemarche/fixtures/django/0a_networks.json",
"lemarche/fixtures/django/0e_companies.json",
"lemarche/fixtures/django/02_users.json",
"lemarche/fixtures/django/20_cms.json",
]

@classmethod
def setUpTestData(cls):
cls.siae = SiaeFactory()
cls.siae_user = UserFactory(kind=User.KIND_SIAE, siaes=[cls.siae])
cls.user_buyer = UserFactory(kind=User.KIND_BUYER, company_name="Entreprise Buyer")

def test_anonymous_user_home(self):
response = self.client.get("/")

self.assertContains(response, "Publier un besoin d'achat")
self.assertContains(response, reverse("tenders:create"))

self.assertContains(response, "S'inscrire")
self.assertNotContains(response, "Référencé ma structure")
self.assertContains(response, reverse("auth:signup"))

self.assertContains(response, "Se connecter")
self.assertContains(response, reverse("auth:login"))

self.assertNotContains(response, "Demandes reçues")
self.assertNotContains(response, f'"{reverse("tenders:list")}"')

self.assertNotContains(response, "Mon espace")
self.assertNotContains(response, reverse("dashboard:home"))

def test_anonymous_user_home_for_siae(self):
response = self.client.get("/accueil-structure/")

self.assertContains(response, "Publier un besoin d")
self.assertContains(response, reverse("tenders:create"))

self.assertNotContains(response, "S'inscrire")
self.assertContains(response, "Référencé ma structure")
self.assertContains(response, reverse("auth:signup"))

self.assertContains(response, "Se connecter")
self.assertContains(response, reverse("auth:login"))

self.assertNotContains(response, "Demandes reçues")
self.assertNotContains(response, f'"{reverse("tenders:list")}"')

self.assertNotContains(response, "Mon espace")
self.assertNotContains(response, reverse("dashboard:home"))

def test_siae_user_home(self):
self.client.force_login(self.siae_user)
response = self.client.get("/")

self.assertContains(response, "Publier un besoin d'achat")
self.assertContains(response, reverse("tenders:create"))

self.assertNotContains(response, "S'inscrire")
self.assertNotContains(response, "Référencé ma structure")
self.assertNotContains(response, reverse("auth:signup"))

self.assertNotContains(response, "Se connecter")
self.assertNotContains(response, reverse("auth:login"))

self.assertContains(response, "Demandes reçues")
self.assertContains(response, f'"{reverse("tenders:list")}"')

self.assertContains(response, "Mon espace")
self.assertContains(response, reverse("dashboard:home"))

def test_buyer_user_home(self):
self.client.force_login(self.user_buyer)
response = self.client.get("/")

self.assertContains(response, "Publier un besoin d'achat")
self.assertContains(response, reverse("tenders:create"))

self.assertNotContains(response, "S'inscrire")
self.assertNotContains(response, "Référencé ma structure")
self.assertNotContains(response, reverse("auth:signup"))

self.assertNotContains(response, "Se connecter")
self.assertNotContains(response, reverse("auth:login"))

self.assertNotContains(response, "Demandes reçues")
self.assertNotContains(response, f'"{reverse("tenders:list")}"')

self.assertContains(response, "Mon espace")
self.assertContains(response, reverse("dashboard:home"))

0 comments on commit f4a1694

Please sign in to comment.