Skip to content

Commit

Permalink
fix(section-switch): do not blindly follow ?next after switch
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeejoee committed Nov 11, 2023
1 parent db39a63 commit 47e9379
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ <h1 class="card-title">My Memberships</h1>
</svg>
{% elif membership.state == membership.State.ACTIVE %}
{% section_membership_activation_url membership as activation_url %}
{# TODO: the ?next may be set here, and we're resetting to home url of section -- maybe the option is to respect ?next to keep the same page before section switch #}
<a href="{{ activation_url }}" type="button" class="btn btn-success">jump in</a>
{% endif %}
</div>
Expand Down
12 changes: 8 additions & 4 deletions fiesta/apps/accounts/templatetags/memberships.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from allauth.account.utils import get_next_redirect_url
from django import template
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.urls import reverse

from apps.sections.middleware.section_space import HttpRequest
Expand All @@ -15,8 +13,14 @@
def section_membership_activation_url(context, membership: SectionMembership):
request: HttpRequest = context["request"]

next_url = get_next_redirect_url(request, REDIRECT_FIELD_NAME) or ""
# TODO: the next cannot blindly follow the source /path, because user probably does have
# a different role in target section, so it probably won't work
# next_url = get_next_redirect_url(request, REDIRECT_FIELD_NAME) or ""
#
# return membership.section.section_base_url(request) + (
# next_url if next_url else (membership.section.section_home_url(membership) or reverse("public:home"))
# )

return membership.section.section_base_url(request) + (
next_url if next_url else (membership.section.section_home_url(membership) or reverse("public:home"))
membership.section.section_home_url(membership) or reverse("public:home")
)

0 comments on commit 47e9379

Please sign in to comment.