Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Prise de rendez vous à l'inscription #1663

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1522873
Add group admin view
Guilouf Feb 14, 2025
440e42d
Add is onboarded field user field
Guilouf Feb 14, 2025
fa1e01e
Template view to book meeting
Guilouf Feb 14, 2025
b9a71f2
Fix tests
Guilouf Feb 14, 2025
3d601f4
Remove useless file
Guilouf Feb 14, 2025
1f9a6b4
Prevent access to dashboard
Guilouf Feb 14, 2025
13af043
Prevent access to favorites
Guilouf Feb 14, 2025
755458d
User is onboard if it creates a Tender
Guilouf Feb 14, 2025
cc54d1f
Try google agenda
Guilouf Feb 17, 2025
d565e4a
Fix anonymous user case
Guilouf Feb 17, 2025
1da6b28
Add wagtail paragraph
Guilouf Feb 18, 2025
d78b358
Add wagtail paragraph
Guilouf Feb 18, 2025
9a3e030
Iframe as varenv
Guilouf Feb 18, 2025
24caf19
test tests
Guilouf Feb 18, 2025
7f6fe33
rebase changes
Guilouf Feb 27, 2025
4e3fc3b
rebase changes
Guilouf Feb 27, 2025
f8864a9
GOOGLE_AGENDA_IFRAME_URL as default var
Guilouf Feb 27, 2025
edfc2f1
typo fix
Guilouf Feb 27, 2025
9dbeb68
fix tests
Guilouf Feb 27, 2025
cfe8d73
Hide tender create for non onboarded users
Guilouf Feb 27, 2025
e35747f
Redirect to book meeting on access denied
Guilouf Feb 27, 2025
f4f88fa
Redirect to book meeting on access denied
Guilouf Feb 27, 2025
7509935
Disable AGENDA feature based on google agenda url presence
Guilouf Feb 27, 2025
632d4f0
custom message with agenda signup
Guilouf Feb 27, 2025
603d2fc
custom message with agenda signup
Guilouf Feb 27, 2025
a23a6d2
login required
Guilouf Feb 27, 2025
0334416
Design stuff
Guilouf Feb 27, 2025
e7a4ee8
Only buyer kind user is concerned by the meeting agenda
Guilouf Feb 27, 2025
32e4236
fix typo
Guilouf Feb 27, 2025
8a9df30
fix tests
Guilouf Feb 27, 2025
909d957
fix tests
Guilouf Feb 27, 2025
4b245eb
fix tests
Guilouf Feb 28, 2025
fddba54
Jump line for message
Guilouf Mar 3, 2025
7851f31
Linear background
Guilouf Mar 4, 2025
2d10e43
White text
Guilouf Mar 4, 2025
6e8f544
Acitvate account link
Guilouf Mar 4, 2025
068fce5
Add access control for already onboarded users
Guilouf Mar 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@
TALLY_BUYER_NPS_FORM_ID = env.str("TALLY_BUYER_NPS_FORM_ID", "")
TALLY_SIAE_NPS_FORM_ID = env.str("TALLY_SIAE_NPS_FORM_ID", "")
PARTNER_APPROCH_USER_ID = env.int("PARTNER_APPROCH_USER_ID", 0)

GOOGLE_AGENDA_IFRAME_URL = env.str("GOOGLE_AGENDA_IFRAME_URL", "")

# Misc
# ------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions env.default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export POSTGRESQL_ADDON_DB=""
export SECRET_KEY="coucou"
export DJANGO_SETTINGS_MODULE="config.settings.dev"
export TRACKER_HOST="https://example.com"
export GOOGLE_AGENDA_IFRAME_URL = ""

# APIs
export API_EMPLOIS_INCLUSION_TOKEN=""
Expand Down
1 change: 1 addition & 0 deletions env.docker_default.local
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ENV=dev
DEBUG=True
SECRET_KEY=[YOUR_SECRET]
TRACKER_HOST=localhost
GOOGLE_AGENDA_IFRAME_URL=""

# MTCAPTCHA
MTCAPTCHA_PRIVATE_KEY=
Expand Down
38 changes: 38 additions & 0 deletions lemarche/cms/migrations/0015_paragraph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 5.1.6 on 2025-02-18 09:33

import wagtail.fields
from django.db import migrations, models


def paragraph_migration(apps, schema_editor):
Paragraph = apps.get_model("cms", "Paragraph")
Paragraph.objects.create(
title="Prise de rendez vous", slug="rdv-signup", content="Prenez un rendez vous s'il vous plaît"
)


class Migration(migrations.Migration):

dependencies = [
("cms", "0014_homepage_sub_header_custom_message"),
]

operations = [
migrations.CreateModel(
name="Paragraph",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("title", models.CharField(max_length=255, verbose_name="Titre de l'encart")),
(
"slug",
models.SlugField(unique=True, help_text="Identifiant", max_length=255, verbose_name="slug"),
),
("content", wagtail.fields.RichTextField(blank=True, verbose_name="Contenu")),
],
options={
"verbose_name": "Paragraphe",
"verbose_name_plural": "Paragraphes",
},
),
migrations.RunPython(paragraph_migration, migrations.RunPython.noop),
]
30 changes: 30 additions & 0 deletions lemarche/cms/snippets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models
from wagtail.admin.panels import FieldPanel
from wagtail.fields import RichTextField
from wagtail.snippets.models import register_snippet


Expand Down Expand Up @@ -88,3 +89,32 @@ class Meta:

def __str__(self):
return self.title


@register_snippet
class Paragraph(models.Model):
title = models.CharField(max_length=255, verbose_name="Titre de l'encart")
slug = models.SlugField(
verbose_name="slug",
unique=True,
max_length=255,
help_text="Identifiant",
)

content = RichTextField(
blank=True,
verbose_name="Contenu",
)

panels = [
FieldPanel("title"),
FieldPanel("slug"),
FieldPanel("content"),
]

class Meta:
verbose_name = "Paragraphe"
verbose_name_plural = "Paragraphes"

def __str__(self):
return self.title
23 changes: 23 additions & 0 deletions lemarche/static/itou_marche/itou_marche.scss
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,26 @@ p.fr-tag--green-emeraude {
background-color: var(--background-action-low-green-emeraude);
color: var(--text-action-high-green-emeraude)
}

.fr-background-alt--orange {
background: linear-gradient(to bottom, #fc5455 50%, transparent 50%);
}

.fr-background-alt--white {
background: #ffffff;
}

.rounded-iframe {
width: 100%;
height: 650px;
border: none;
border-radius: 15px;
}

.text-white {
color: #ffffff;
}

.text-white * {
color: inherit;
}
29 changes: 29 additions & 0 deletions lemarche/templates/auth/meeting_calendar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends BASE_TEMPLATE %}
{% load dsfr_tags process_dict static humanize wagtailcore_tags advert_cms %}
{% block page_title %}
Prise de rendez-vous
{% endblock page_title %}

{% block breadcrumb %}
{% process_dict root_dir=HOME_PAGE_PATH current="Prise de rendez-vous" as breadcrumb_data %}
{% dsfr_breadcrumb breadcrumb_data %}
{% endblock breadcrumb %}
{% block content %}
<div class="fr-container fr-background-alt--orange fr-card--shadow">
<div class="fr-grid-row text-white">
<div class="fr-col-4 fr-mt-2w">
{{ wagtail_paragraph.content | safe }}
</div>
<div class="fr-col-8 fr-mt-2w">
<h2>Prenez rendez-vous pour activer votre compte</h2>
<!-- Google Calendar Appointment Scheduling begin -->
<iframe
class="fr-background-alt--white rounded-iframe fr-mb-2w"
src="{{ agenda_iframe_url }}"
>
</iframe>
<!-- end Google Calendar Appointment Scheduling -->
</div>
</div>
</div>
{% endblock content %}
10 changes: 6 additions & 4 deletions lemarche/templates/includes/_dropdown_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
<button id="my-account" class="fr-btn fr-btn--tertiary fr-icon-account-line fr-btn--icon-left fr-m-md-0" aria-controls="menu-profile" @click="openMenu()">Mon espace</button>
<div id="menu-profile" x-show="isOpen" @click.away="closeMenu()" x-cloak class="fr-menu dropdown-menu__menu">
<ul class="fr-menu__list dropdown-menu__list">
{% if user.is_onboarded %}
<li>
<a id="header-dashboard" class="fr-nav__link fr-icon-table-line fr-btn--icon-left" href="{% url 'dashboard:home' %}" target="_self">
Tableau de bord
</a>
</li>
<li>
<a id="header-profile" class="fr-nav__link fr-icon-user-line fr-btn--icon-left" href="{% url 'dashboard:profile_edit' %}" target="_self">
Mon profil
<a id="header-favorites" class="fr-nav__link fr-icon-star-line fr-btn--icon-left" href="{% url 'dashboard_favorites:list' %}" target="_self">
Favoris <span class="fr-badge fr-badge--sm fr-ml-2v">{{ user.favorite_list_count }}</span>
</a>
</li>
{% endif %}
<li>
<a id="header-favorites" class="fr-nav__link fr-icon-star-line fr-btn--icon-left" href="{% url 'dashboard_favorites:list' %}" target="_self">
Favoris <span class="fr-badge fr-badge--sm fr-ml-2v">{{ user.favorite_list_count }}</span>
<a id="header-profile" class="fr-nav__link fr-icon-user-line fr-btn--icon-left" href="{% url 'dashboard:profile_edit' %}" target="_self">
Mon profil
</a>
</li>
{% if user.kind == user.KIND_SIAE or user.kind == user.KIND_BUYER %}
Expand Down
1 change: 0 additions & 1 deletion lemarche/templates/layouts/_header_dsfr.html

This file was deleted.

20 changes: 13 additions & 7 deletions lemarche/templates/layouts/_header_nav_primary_items.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
Demandes reçues{% if tender_siae_unread_count %}&nbsp;<span class="fr-badge fr-badge--sm fr-ml-2v fr-badge--green-emeraude">{{ tender_siae_unread_count }}</span>{% endif %}
</a>
</li>
{% else %}
<li>
<a class="fr-btn fr-icon-add-circle-line fr-btn--icon-left" href="{% url 'tenders:create' %}" id="header-demande" target="_self">
<span>Publier un besoin d'achat</span>
</a>
</li>
{% elif user.is_onboarded %}
<li>
<a class="fr-btn fr-icon-add-circle-line fr-btn--icon-left" href="{% url 'tenders:create' %}" id="header-demande" target="_self">
<span>Publier un besoin d'achat</span>
</a>
</li>
{% else %}
<li>
<a class="fr-btn fr-btn--icon-left" href="{% url 'auth:booking-meeting-view' %}" id="header-meeting">
<span>Activer mon compte</span>
</a>
</li>
{% endif %}
<li>
{% include "includes/_dropdown_menu.html" %}
Expand Down Expand Up @@ -46,4 +52,4 @@
</li>
{% endif %}
{% endif %}
</ul>
</ul>
10 changes: 8 additions & 2 deletions lemarche/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from ckeditor.widgets import CKEditorWidget
from django import forms
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.admin import GroupAdmin, UserAdmin
from django.contrib.auth.models import Group
from django.contrib.contenttypes.admin import GenericTabularInline
from django.core.exceptions import ValidationError
from django.db import models
Expand All @@ -22,6 +23,11 @@
from lemarche.utils.fields import pretty_print_readonly_jsonfield


@admin.register(Group, site=admin_site)
class GroupAdmin(GroupAdmin):
pass


class HasCompanyFilter(admin.SimpleListFilter):
"""Custom admin filter to target users who are linked to a Company."""

Expand Down Expand Up @@ -308,7 +314,7 @@ class UserAdmin(FieldsetsInlineMixin, UserAdmin):
("API", {"fields": ("api_key", "api_key_last_updated")}),
(
"Permissions",
{"classes": ["collapse"], "fields": ("is_active", "is_staff", "is_superuser", "groups")},
{"classes": ["collapse"], "fields": ("is_onboarded", "is_active", "is_staff", "is_superuser", "groups")},
),
(
"Stats",
Expand Down
18 changes: 18 additions & 0 deletions lemarche/users/migrations/0045_user_is_onboarded.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.1.6 on 2025-02-14 09:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("users", "0044_alter_user_api_key"),
]

operations = [
migrations.AddField(
model_name="user",
name="is_onboarded",
field=models.BooleanField(default=True, verbose_name="L'utilisateur a suivi la procédure d'onboarding"),
),
]
1 change: 1 addition & 0 deletions lemarche/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ class User(AbstractUser):

# is_active, is_staff, is_superuser
is_anonymized = models.BooleanField(verbose_name="L'utilisateur à été anonymisé", default=False)
is_onboarded = models.BooleanField(verbose_name="L'utilisateur a suivi la procédure d'onboarding", default=True)

# date_joined, last_login
created_at = models.DateTimeField(verbose_name="Date de création", default=timezone.now)
Expand Down
15 changes: 10 additions & 5 deletions lemarche/www/auth/tests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.test import override_settings
from django.urls import reverse
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.select import Select

from lemarche.cms.snippets import Paragraph
from lemarche.users.factories import DEFAULT_PASSWORD, UserFactory
from lemarche.users.models import User

Expand All @@ -31,6 +33,7 @@ def element_select_option(driver, element, option=""):
field_select.select_by_visible_text(option)


@override_settings(GOOGLE_AGENDA_IFRAME_URL="some_google_url")
class SignupFormTest(StaticLiveServerTestCase):
@classmethod
def setUpClass(cls):
Expand All @@ -43,6 +46,11 @@ def setUpClass(cls):

def setUp(self):
EXAMPLE_PASSWORD = "c*[gkp`0="
# Static server tests cases erases data from migrations
Paragraph.objects.get_or_create(
slug="rdv-signup",
defaults={"title": "Prise de rendez vous"},
)

self.SIAE = {
"id_kind": 0, # required
Expand Down Expand Up @@ -125,7 +133,7 @@ def _complete_form(self, user_profile: dict, signup_url=reverse("auth:signup"),
scroll_to_and_click_element(self.driver, submit_element)

def _assert_signup_success(self, redirect_url: str, user_kind=None) -> list:
"""Assert the success signup and returns the sucess messages
"""Assert the success signup and returns the success messages

Args:
redirect_url (str): redirect url after signup
Expand All @@ -142,9 +150,6 @@ def _assert_signup_success(self, redirect_url: str, user_kind=None) -> list:
menu_button = self.driver.find_element(By.ID, "my-account")
menu_button.click()

dashboard_link = self.driver.find_element(By.LINK_TEXT, "Tableau de bord")
self.assertIsNotNone(dashboard_link)

notifications_link = self.driver.find_elements(By.LINK_TEXT, "Notifications")
if user_kind in [User.KIND_SIAE, User.KIND_BUYER]:
self.assertTrue(len(notifications_link) > 0)
Expand Down Expand Up @@ -198,7 +203,7 @@ def test_buyer_submits_signup_form_success(self):
scroll_to_and_click_element(self.driver, submit_element)

# should redirect BUYER to search
self._assert_signup_success(redirect_url=reverse("siae:search_results"), user_kind=User.KIND_BUYER)
self._assert_signup_success(redirect_url=reverse("auth:booking-meeting-view"), user_kind=User.KIND_BUYER)

def test_buyer_submits_signup_form_success_extra_data(self):
self._complete_form(user_profile=self.BUYER, with_submit=False)
Expand Down
3 changes: 2 additions & 1 deletion lemarche/www/auth/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib.auth import views as auth_views
from django.urls import path, reverse_lazy

from lemarche.www.auth.views import LoginView, PasswordResetView, SignupView
from lemarche.www.auth.views import LoginView, MeetingCalendarView, PasswordResetView, SignupView


# https://docs.djangoproject.com/en/dev/topics/http/urls/#url-namespaces-and-included-urlconfs
Expand All @@ -11,6 +11,7 @@
path("login/", LoginView.as_view(), name="login"),
path("logout/", auth_views.LogoutView.as_view(template_name="auth/logged_out.html"), name="logout"),
path("signup/", SignupView.as_view(), name="signup"),
path("rendez-vous/", MeetingCalendarView.as_view(), name="booking-meeting-view"),
path("password-reset/", PasswordResetView.as_view(), name="password_reset"),
path(
"password-reset/sent/",
Expand Down
Loading