Skip to content

Commit

Permalink
Reset some signup selections when you go back a page
Browse files Browse the repository at this point in the history
  • Loading branch information
janbaykara committed Jan 17, 2024
1 parent ec53d6d commit 200c20f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
),
### V2 signup flow
# CreateMembershipView
# SelectReadpingSpeedView
# SelectReadingSpeedView
# SelectSyllabusView
# SelectShippingCountryView
# SelectBillingPlanView
Expand All @@ -174,7 +174,7 @@
),
path(
"signup/reading-speed/",
views.SelectReadpingSpeedView.as_view(),
views.SelectReadingSpeedView.as_view(),
name="signup_reading_speed",
),
path(
Expand Down
25 changes: 22 additions & 3 deletions app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ def retry_job(self, retry_job_id):
CreateMembershipView (alias) ->
SelectReadpingSpeedView
SelectReadingSpeedView
- List of MembershipPlanPage.filter(display_in_quiz_flow=True)
SelectSyllabusView
Expand Down Expand Up @@ -994,7 +994,7 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
return context


class SelectReadpingSpeedView(OneAtATimeFormViewStoredToSession):
class SelectReadingSpeedView(OneAtATimeFormViewStoredToSession):
template_name = "app/signup/select_reading_speed.html"
form_class = SelectReadingSpeedForm
success_url = reverse_lazy("signup_syllabus")
Expand All @@ -1003,6 +1003,15 @@ class SelectReadpingSpeedView(OneAtATimeFormViewStoredToSession):
def get_context_data(self, **kwargs):
from app.models.wagtail import ReadingOption

for key in [
# SessionKey.reading_option_id,
SessionKey.membership_plan_id,
# SessionKey.country,
SessionKey.membership_plan_price,
# SessionKey.donation_amount,
]:
self.request.session[key.value] = None

context = super().get_context_data(**kwargs)
context["reading_options"] = ReadingOption.objects.all()
context["steps"] = [
Expand All @@ -1015,7 +1024,7 @@ def get_context_data(self, **kwargs):
return context


class CreateMembershipView(SelectReadpingSpeedView):
class CreateMembershipView(SelectReadingSpeedView):
def get(self, request: HttpRequest, *args: str, **kwargs: Any) -> HttpResponse:
# Because sometimes the session hasn't been initialised
# https://stackoverflow.com/a/39188274/1053937
Expand All @@ -1040,6 +1049,16 @@ class SelectSyllabusView(OneAtATimeFormViewStoredToSession):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)

for key in [
# SessionKey.reading_option_id,
# SessionKey.membership_plan_id,
# SessionKey.country,
SessionKey.membership_plan_price,
# SessionKey.donation_amount,
]:
self.request.session[key.value] = None

context["syllabus_options"] = self.reading_option.plans.all()
context["steps"] = [
{
Expand Down

0 comments on commit 200c20f

Please sign in to comment.