Skip to content

Commit

Permalink
feat: harmonisation des liens de connexion (#844)
Browse files Browse the repository at this point in the history
## Description

🎸 Reliquat de liens pointant directement sur
`openid_connect:authorize` et non `users:login`
🎸 Harmonisation des boutons d'actions

## Type de changement

🎢 Nouvelle fonctionnalité (changement non cassant qui ajoute une
fonctionnalité).
🎨 changement d'UI

### Points d'attention

🦺 suppression de gabarits dépréciés, dont un faisant reférence au
template tag

### Captures d'écran

`SeekersListView` anonyme

![image](https://github.com/user-attachments/assets/eb3b2e02-b656-4065-8a54-2423bb42e86b)

`SeekersListView` connecté

![image](https://github.com/user-attachments/assets/40d52f33-4f14-4e5f-a0ee-eeec5b8a3fa9)

`DSPCreateView` anonyme

![image](https://github.com/user-attachments/assets/13ca5e23-218b-4101-82d7-93fca9d27a51)

`EventMonthArchiveView` anonyme

![image](https://github.com/user-attachments/assets/3f9c06d1-3fb9-47eb-ad3b-b16ba05c64a3)

`EventMonthArchiveView` connecté

![image](https://github.com/user-attachments/assets/a7a907be-80c7-4219-a642-9e8077521ad7)

`TopicListView` anonyme

![image](https://github.com/user-attachments/assets/07f1ed33-db8b-4854-880f-4337f84da5a8)
  • Loading branch information
vincentporte authored Dec 4, 2024
1 parent fa5d0d4 commit fb50472
Show file tree
Hide file tree
Showing 23 changed files with 304 additions and 178 deletions.
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
MIDDLEWARE = DJANGO_MIDDLEWARE + THIRD_PARTIES_MIDDLEWARE + LOCAL_MIDDLEWARE

ROOT_URLCONF = "config.urls"
LOGIN_URL = "/pro_connect/authorize"
LOGIN_URL = "/users/login/"
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"

Expand Down
56 changes: 56 additions & 0 deletions lacommunaute/event/tests/__snapshots__/tests_views.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# serializer version: 1
# name: TestEventMonthArchiveView.test_action_box[False-anonymous][anonymous]
'''
<section class="s-section" id="action-box">
<div class="s-section__container container">

<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">
Je suis l'organisateur d'un évènement à destination des CIP pour les aider à améliorer leur pratique professionnelle ?
<br/>
Je me connecte pour ajouter un évènement public dans le calendrier de la communauté
</div>
<div class="col-lg-auto col-12">


<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=%2Fcalendar%2Fcreate%2F">Se connecter | S'inscrire</a>

</div>
</div>
</div>
</div>
</div>

</div>
</section>
'''
# ---
# name: TestEventMonthArchiveView.test_action_box[True-authenticated][authenticated]
'''
<section class="s-section" id="action-box">
<div class="s-section__container container">

<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">
Je suis l'organisateur d'un évènement à destination des CIP pour les aider à améliorer leur pratique professionnelle ?
<br/>
J'ajoute un évènement public dans le calendrier de la communauté
</div>
<div class="col-lg-auto col-12">
<a class="btn btn-primary" href="/calendar/create/">Ajouter un évènement public</a>
</div>
</div>
</div>
</div>
</div>

</div>
</section>
'''
# ---
23 changes: 20 additions & 3 deletions lacommunaute/event/tests/tests_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime, timedelta

import pytest
from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.test import TestCase
Expand All @@ -12,6 +13,7 @@
from lacommunaute.event.forms import EventModelForm
from lacommunaute.event.models import Event
from lacommunaute.users.factories import UserFactory
from lacommunaute.utils.testing import parse_response_to_soup


faker = Faker()
Expand Down Expand Up @@ -75,7 +77,7 @@ def setUpTestData(cls):
def test_login_is_required(self):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse("openid_connect:authorize") + "?next=" + self.url)
self.assertEqual(response.url, reverse("users:login") + "?next=" + self.url)

def test_event_is_created(self):
self.client.force_login(self.user)
Expand Down Expand Up @@ -191,7 +193,7 @@ def setUpTestData(cls):
def test_login_is_required(self):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse("openid_connect:authorize") + "?next=" + self.url)
self.assertEqual(response.url, reverse("users:login") + "?next=" + self.url)

self.client.force_login(self.user)
response = self.client.get(self.url)
Expand Down Expand Up @@ -221,7 +223,6 @@ def test_view_wo_args(self):
response = self.client.get(reverse("event:current"))
self.assertContains(response, event.name, status_code=200)
self.assertContains(response, reverse("event:detail", kwargs={"pk": event.pk}))
self.assertContains(response, reverse("event:create"))

def test_view_with_args(self):
event = EventFactory(date=timezone.now())
Expand Down Expand Up @@ -272,3 +273,19 @@ def test_navbar(self):
),
status_code=200,
)


class TestEventMonthArchiveView:
@pytest.mark.parametrize(
"authenticated,snapshot_name",
[
(False, "anonymous"),
(True, "authenticated"),
],
)
def test_action_box(self, client, db, authenticated, snapshot_name, snapshot):
if authenticated:
client.force_login(UserFactory())
response = client.get(reverse("event:current"))
content = parse_response_to_soup(response, selector="#action-box")
assert str(content) == snapshot(name=snapshot_name)
14 changes: 7 additions & 7 deletions lacommunaute/forum/tests/__snapshots__/tests_views.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-10000%2F%2310000" rel="nofollow" title="Connectez-vous pour sauvegarder">
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-10000%2F%2310000" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>0</span>
</a>

Expand Down Expand Up @@ -486,7 +486,7 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour sauvegarder">
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>0</span>
</a>

Expand All @@ -499,7 +499,7 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour sauvegarder">
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>0</span>
</a>

Expand Down Expand Up @@ -528,7 +528,7 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour sauvegarder">
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>1</span>
</a>

Expand All @@ -541,7 +541,7 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour sauvegarder">
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>1</span>
</a>

Expand Down Expand Up @@ -570,7 +570,7 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour sauvegarder">
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>2</span>
</a>

Expand All @@ -583,7 +583,7 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour sauvegarder">
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>2</span>
</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@
</small>
'''
# ---
# name: TestTopicListView.test_anonymous_content[anonymous_action_box]
'''
<section class="s-section" id="action-box">
<div class="s-section__container container">
<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">Je me connecte pour accéder à toutes mes thématiques</div>
<div class="col-lg-auto col-12">


<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=%2Ftopics%2F">Se connecter | S'inscrire</a>

</div>
</div>
</div>
</div>
</div>
</div>
</section>
'''
# ---
# name: TestTopicListView.test_clickable_tags[10-query_param1-clickable_tags_page2][clickable_tags_page2]
'<button class="tag bg-info-lighter text-info matomo-event" data-matomo-action="filter" data-matomo-category="engagement" data-matomo-option="topics" hx-get="/topics/?tag=tag&amp;filter=ALL" hx-push-url="true" hx-swap="outerHTML" hx-target="#topicsarea" id="filtertopics-button">tag</button>'
# ---
Expand Down
5 changes: 5 additions & 0 deletions lacommunaute/forum_conversation/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,11 @@ def test_filter_dropdown_with_tags(self, client, db, public_forum_with_topic, to
content = parse_response_to_soup(response, selector="#filterTopicsDropdown")
assert str(content) == snapshot(name="filter_dropdown_with_tags")

def test_anonymous_content(self, client, db, topics_url, snapshot):
response = client.get(topics_url)
content = parse_response_to_soup(response, selector="#action-box")
assert str(content) == snapshot(name="anonymous_action_box")


class TestPosterTemplate:
def test_topic_in_topics_view(self, client, db, topics_url, snapshot):
Expand Down
74 changes: 74 additions & 0 deletions lacommunaute/forum_member/tests/__snapshots__/tests_view.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# serializer version: 1
# name: TestSeekersListView.test_update_profil_link[False-anonymous_user][anonymous_user]
'''
<section class="s-section" id="action-box">
<div class="s-section__container container">

<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">Je me connecte pour mettre à jour mon profil</div>
<div class="col-lg-auto col-12">


<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=%2Fmembers%2Fprofile%2Fedit%2F">Se connecter | S'inscrire</a>

</div>
</div>
</div>
</div>
</div>

<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="row row-cols-1 row-cols-md-2 g-4">

<div class="col">
<p>No body yet…</p>
</div>

</div>

</div>
</div>
</div>
</section>
'''
# ---
# name: TestSeekersListView.test_update_profil_link[True-authenticated_user][authenticated_user]
'''
<section class="s-section" id="action-box">
<div class="s-section__container container">

<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">
<p>Je suis CIP en recherche d'un stage ou d'une alternance ? Je complète mon profil pour me faire connaitre.</p>
</div>
<div class="col-lg-auto col-12">
<a class="btn btn-primary" href="/members/profile/edit/">Mettre à jour mon profil</a>
</div>
</div>
</div>
</div>
</div>

<div class="s-section__row row">
<div class="s-section__col col-12">
<div class="row row-cols-1 row-cols-md-2 g-4">

<div class="col">
<p>No body yet…</p>
</div>

</div>

</div>
</div>
</div>
</section>
'''
# ---
11 changes: 11 additions & 0 deletions lacommunaute/forum_member/tests/tests_view.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from django.test import RequestFactory, TestCase
from django.urls import reverse
from machina.core.loading import get_class
Expand All @@ -7,6 +8,8 @@
from lacommunaute.forum_member.models import ForumProfile
from lacommunaute.forum_member.shortcuts import get_forum_member_display_name
from lacommunaute.forum_member.views import ForumProfileUpdateView
from lacommunaute.users.factories import UserFactory
from lacommunaute.utils.testing import parse_response_to_soup


PermissionHandler = get_class("forum_permission.handler", "PermissionHandler")
Expand Down Expand Up @@ -55,6 +58,14 @@ def test_sorted_profils(self, client, db):
assert response.context_data["forum_profiles"][0] == ForumProfile.objects.last()
assert response.context_data["forum_profiles"][1] == ForumProfile.objects.first()

@pytest.mark.parametrize("authenticated,snapshot_name", [(True, "authenticated_user"), (False, "anonymous_user")])
def test_update_profil_link(self, client, db, authenticated, snapshot_name, snapshot):
if authenticated:
client.force_login(UserFactory())
response = client.get(reverse("members:seekers"))
content = parse_response_to_soup(response, selector="#action-box")
assert str(content) == snapshot(name=snapshot_name)


class TestForumProfileDetailView:
def test_show_linkedin_link(self, client, db):
Expand Down
10 changes: 8 additions & 2 deletions lacommunaute/pages/tests/__snapshots__/test_homepage.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@
</li>

<li>
<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=/" rel="nofollow">Se connecter | S'inscrire</a>


<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=%2F">Se connecter | S'inscrire</a>

</li>

</ul>
Expand Down Expand Up @@ -257,7 +260,10 @@
<nav aria-label="Menu de navigation principale pour mobile" role="navigation">

<div>
<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=/" rel="nofollow">Se connecter | S'inscrire</a>


<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=%2F">Se connecter | S'inscrire</a>

</div>

</nav>
Expand Down
26 changes: 26 additions & 0 deletions lacommunaute/surveys/tests/__snapshots__/test_views.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
# serializer version: 1
# name: TestDSPCreateView.test_action_box[action_box]
'''
<section class="s-section" id="action-box">
<div class="s-section__container container">

<div class="s-section__row row">
<div class="s-section__col col-lg-8 col-12">
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">Je me connecte pour accéder à l'aide au diagnostic pour le parcours IAE</div>
<div class="col-lg-auto col-12">


<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=%2Fsurveys%2Fdsp%2Fcreate%2F">Se connecter | S'inscrire</a>

</div>
</div>
</div>
</div>
</div>


</div>
</section>
'''
# ---
# name: TestDSPDetailView.test_suggested_services[level_1]
'''
<main class="s-main" id="main" role="main">
Expand Down
Loading

0 comments on commit fb50472

Please sign in to comment.