Skip to content

Commit

Permalink
Merge pull request #647 from praekeltfoundation/fix-onboarding-skip-t…
Browse files Browse the repository at this point in the history
…o-menu

Split state in two so that clearing and redirecting is separate
  • Loading branch information
fritzbrand authored Jul 31, 2023
2 parents 247b99b + 09c3044 commit 63452d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions yal/assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ async def state_stop_assessment_reminders_confirm(self):
Choice("start", self._("Start questions")),
],
next={
"skip": "state_stop_assessment_reminders",
"skip": "state_stop_assessment_reminders_clear_fields",
"start": f"state_{assessment_reminder_name}_assessment",
},
error=self._(get_generic_error()),
Expand All @@ -508,13 +508,13 @@ async def state_stop_assessment_reminders_confirm(self):
Choice("start", self._("Start questions")),
],
next={
"skip": "state_stop_assessment_reminders",
"skip": "state_stop_assessment_reminders_clear_fields",
"start": f"state_{assessment_reminder_name}_assessment",
},
error=self._(get_generic_error()),
)

async def state_stop_assessment_reminders(self):
async def state_stop_assessment_reminders_clear_fields(self):
msisdn = utils.normalise_phonenumber(self.inbound.from_addr)
whatsapp_id = msisdn.lstrip(" + ")
assessment_name = None
Expand All @@ -538,7 +538,15 @@ async def state_stop_assessment_reminders(self):
if error:
return await self.go_to_state("state_error")

if assessment_name != "locus_of_control":
self.save_metadata("last_assessment_reminder_cleared_name", assessment_name)
return await self.go_to_state("state_stop_assessment_reminders")

async def state_stop_assessment_reminders(self):
last_assessment_reminder_cleared_name = self.user.metadata.get(
"last_assessment_reminder_cleared_name"
)
self.delete_metadata("last_assessment_reminder_cleared_name")
if last_assessment_reminder_cleared_name != "locus_of_control":
return WhatsAppButtonState(
self,
question=self._(
Expand Down
1 change: 1 addition & 0 deletions yal/tests/states_dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
| state_sexual_health_literacy_send_risk_message | TRUE | Text | TRUE | Sends the user a message based on their risk score, takes in "yes" and "no" |
| state_handle_assessment_reminder_response | FALSE | | | Handles the response to the assessment reminders |
| state_stop_assessment_reminders_confirm | TRUE | Text | TRUE | Confirms that the user no longer wants assessment reminders |
| state_stop_assessment_reminders_clear_fields | FALSE | Text | FALSE | Clears the users assessment reminders, then send user on to next state to determine where they want to go
| state_stop_assessment_reminders | TRUE | Text | TRUE | Sets the user to no longer get assessment reminders, asks user if they would like to go to menu or aaq |
| state_reschedule_assessment_reminder | | | | Schedules the assessment reminders |
| state_remind_tomorrow | TRUE | Text | TRUE | Lets the user know we will remind them tomorrow, asks the user if they would like to go to the mainmenu |
Expand Down

0 comments on commit 63452d7

Please sign in to comment.