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

[LOGIN IC] gérer les redirections après authentification #413

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions lacommunaute/event/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from lacommunaute.event.forms import EventModelForm
from lacommunaute.event.models import Event
from lacommunaute.users.factories import UserFactory
from lacommunaute.utils.templatetags.str_filters import inclusion_connect_url


faker = Faker()
Expand Down Expand Up @@ -234,8 +233,4 @@ class calendar_test(TestCase):
def test_template(self):
response = self.client.get(reverse("event:calendar"))
self.assertTemplateUsed(response, "event/event_calendar.html")
self.assertContains(response, inclusion_connect_url(reverse("event:create")))

self.client.force_login(UserFactory())
response = self.client.get(reverse("event:calendar"))
self.assertContains(response, reverse("event:create"))
2 changes: 1 addition & 1 deletion lacommunaute/event/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ def calendar_data(request):


def calendar(request):
return TemplateResponse(request, "event/event_calendar.html", {"next_url": reverse("event:create")})
return TemplateResponse(request, "event/event_calendar.html")
4 changes: 2 additions & 2 deletions lacommunaute/forum/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_has_not_liked_TOPIC_ANNOUNCE(self):
self.assertContains(response, '<i class="ri-heart-3-line me-1" aria-hidden="true"></i><span>0</span>')

def test_anonymous_like(self):
params = {"next_url": self.url}
params = {"next": self.url}
url = f"{reverse('inclusion_connect:authorize')}?{urlencode(params)}"

response = self.client.get(self.url)
Expand Down Expand Up @@ -352,7 +352,7 @@ def test_upvote_actions(self):

# anonymous
anonymous_html = (
'<a href="/inclusion_connect/authorize?next_url=%2Fforum%2F'
'<a href="/inclusion_connect/authorize?next=%2Fforum%2F'
f'{child_forum.slug}-{child_forum.pk}%2F%23{child_forum.pk}"'
' rel="nofollow"'
' class="btn btn-sm btn-ico-only btn-link btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top"'
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/forum_conversation/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def test_pluralized_likes(self):

def test_anonymous_like(self):
assign_perm("can_read_forum", AnonymousUser(), self.topic.forum)
params = {"next_url": self.url}
params = {"next": self.url}
url = f"{reverse('inclusion_connect:authorize')}?{urlencode(params)}"

response = self.client.get(self.url)
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/inclusion_connect/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def mock_oauth_dance(
respx.get(constants.INCLUSION_CONNECT_ENDPOINT_AUTHORIZE).respond(302)
authorize_params = {
"previous_url": previous_url,
"next_url": next_url,
"next": next_url,
}
authorize_params = {k: v for k, v in authorize_params.items() if v}

Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/inclusion_connect/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _redirect_to_login_page_on_error(error_msg, request=None):
def inclusion_connect_authorize(request):
# Start a new session.
previous_url = request.GET.get("previous_url", reverse("pages:home"))
next_url = request.GET.get("next_url")
next_url = request.GET.get("next")
sign_in = bool(request.GET.get("sign_in", False))

ic_session = InclusionConnectSession(previous_url=previous_url, next_url=next_url)
Expand Down
14 changes: 4 additions & 10 deletions lacommunaute/templates/event/event_calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,10 @@ <h1 class="s-title-01__title h1"><strong>Les évènements à venir</strong></h1>
<div class="s-section__container container">
<div class="s-section__row row">
<div class="s-section__col col-12">
{% if user.is_authenticated %}
<a href="{% url 'event:create' %}"
role="button" class="btn btn-primary">
{% trans "Post a new Public Event" %}
</a>
{% else %}
<a href="{% inclusion_connect_url next_url %}" rel="nofollow" class="btn btn-primary" data-bs-toggle="tooltip" data--bs-placement="top" title="Connectez-vous pour contribuer">
{% trans "Post a new Public Event" %}
</a>
{% endif %}
<a href="{% url 'event:create' %}" rel="nofollow"
role="button" class="btn btn-primary">
{% trans "Post a new Public Event" %}
</a>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/utils/templatetags/str_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def pluralizefr(value, arg="s"):
def inclusion_connect_url(next_url, anchor=None):
if anchor:
next_url = f"{next_url}#{anchor}"
params = {"next_url": next_url}
params = {"next": next_url}
return f"{reverse('inclusion_connect:authorize')}?{urlencode(params)}"


Expand Down
4 changes: 2 additions & 2 deletions lacommunaute/utils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ def test_inclusion_connect_url(self):
context = Context({"next_url": next_url, "anchor": anchor})

out = Template("{% load str_filters %}{% inclusion_connect_url next_url%}").render(context)
params = {"next_url": next_url}
params = {"next": next_url}
self.assertEqual(out, f"{inclusion_connect_url}?{urlencode(params)}")

out = Template("{% load str_filters %}{% inclusion_connect_url next_url anchor %}").render(context)
params = {"next_url": f"{next_url}#{anchor}"}
params = {"next": f"{next_url}#{anchor}"}
self.assertEqual(out, f"{inclusion_connect_url}?{urlencode(params)}")

def test_relativetimesince_fr(self):
Expand Down