Skip to content

feat: allow dynamic prevent-going-back conditions#947

Merged
jhpyle merged 3 commits into
jhpyle:masterfrom
jpagh:prevent_going_back
May 4, 2026
Merged

feat: allow dynamic prevent-going-back conditions#947
jhpyle merged 3 commits into
jhpyle:masterfrom
jpagh:prevent_going_back

Conversation

@jpagh
Copy link
Copy Markdown
Contributor

@jpagh jpagh commented Apr 30, 2026

This PR makes prevent going back work like back button or other interview keys that evaluate a Python expression for truthiness. It works on one line, or with a scalar.

prevent going back: user_has_signed or payment_processed

or

prevent going back: |
  user_has_signed or payment_processed

In my case, I want this added because I want to be able to do this for development so that I can go back, but my users in production can't:

prevent going back: not user_has_privilege(["developer", "admin"])

Copilot AI review requested due to automatic review settings April 30, 2026 22:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the prevent going back directive so it can be driven by a dynamic Python expression (similar to back button), allowing the “Back” navigation to be conditionally enabled/disabled per question render.

Changes:

  • Parse prevent going back as either a boolean or an evaluatable Python expression and compute can_go_back at ask-time.
  • Plumb can_go_back through the question result payload into InterviewStatus.
  • Update HTML rendering to respect status.can_go_back (evaluated) instead of question.can_go_back (could be a code object).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
docassemble_base/docassemble/base/standardformatter.py Uses evaluated status.can_go_back to decide whether to render the back button.
docassemble_base/docassemble/base/parse.py Computes/evaluates dynamic “prevent going back” conditions and propagates the result into InterviewStatus.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docassemble_base/docassemble/base/parse.py Outdated
Comment thread docassemble_base/docassemble/base/parse.py Outdated
@jhpyle jhpyle merged commit e32dc7c into jhpyle:master May 4, 2026
3 checks passed
@jpagh jpagh deleted the prevent_going_back branch May 4, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants