Repository: cal-itp/benefits

Issue:
Create "Previous Page" button includes
## Acceptance Criteria

<!-- Remember to consider edge cases -->

- Not going to worry about alignment part yet
- Add logic to make Previous Page button only show up on these 2 pages

- Eligibility start page (Uses custom template, start.html)
<img width="677" alt="image" src="https://user-images.githubusercontent.com/3673236/192613362-93ec217b-0246-48b5-8941-e53110b37017.png">
- Eligibility confirm page (Uses Page template)
<img width="638" alt="image" src="https://user-images.githubusercontent.com/3673236/192613311-fb7acf4c-1adb-4c7b-8696-19f5d2cc4c10.png">




Discussion:
@machikoyasuda are you working on this? Would it help if I took it?
@thekaveman That would be great!

@angela-tran started how the include will be included here: https://github.com/cal-itp/benefits/pull/1013/files#diff-13b30474536f391a8f3f76ace48017731f8543d0dd40e3a69ff2ec4d11b7ac4eR3-R5
Thanks for pointing that out. I'm going (try) to build on the new grid concept for this following Angela's work there.
For the CSS/Template, you can probably follow a lot of this: https://github.com/cal-itp/benefits/blob/dev/benefits/core/templates/core/includes/sign-out-link.html and then change the right-align to left-align.

Thankfully, there won't be any pages with both Sign Out and Back. 
It seems like you started a lot of work on these pages in #1023 - should I base on that?
Hrm.. basically Angela's PR re-does Eligibility Start, and my PR re-does Eligibility Confirm. And the Back button is on both of those pages. So you can decide whether to PR off of Angela's or mine, I think. It seems it would be chaotic to branch off of both(?!??!)

<img width="915" alt="image" src="https://user-images.githubusercontent.com/3673236/194385221-6d5a4010-b8a6-4c1e-861a-50497c097912.png">


Resolving patch:
diff --git a/benefits/core/viewmodels.py b/benefits/core/viewmodels.py
--- a/benefits/core/viewmodels.py
+++ b/benefits/core/viewmodels.py
@@ -91,6 +91,13 @@ def logout(**kwargs):
         btn = Button.primary(fallback_text="Login.gov", id="login", url=reverse("oauth:logout"), text="", **kwargs)
         return btn
 
+    @staticmethod
+    def previous_page(url):
+        kwargs = {"id": "previous-page-button", "text": _("core.buttons.previous_page"), "url": url}
+        btn = Button(**kwargs)
+        btn.classes.append("btn-outline-dark")
+        return btn
+
 
 class Icon:
     """Represents an icon."""
diff --git a/benefits/eligibility/views.py b/benefits/eligibility/views.py
--- a/benefits/eligibility/views.py
+++ b/benefits/eligibility/views.py
@@ -76,9 +76,7 @@ def index(request):
 def start(request):
     """View handler for the eligibility verification getting started screen."""
 
-    session.update(request, eligibility_types=[], origin=reverse(ROUTE_START))
     verifier = session.verifier(request)
-
     button = viewmodels.Button.primary(text=_("eligibility.buttons.continue"), url=reverse(ROUTE_CONFIRM))
 
     # define the verifier-specific required item
@@ -125,10 +123,14 @@ def start(request):
     )
 
     ctx = page.context_dict()
+    ctx["previous_page_button"] = viewmodels.Button.previous_page(url=reverse(ROUTE_INDEX))
     ctx["start_headline"] = _(verifier.start_headline)
     ctx["start_sub_headline"] = _(verifier.start_sub_headline)
     ctx["media"] = media
 
+    # update origin now, after we've saved the previous page
+    session.update(request, eligibility_types=[], origin=reverse(ROUTE_START))
+
     return TemplateResponse(request, TEMPLATE_START, ctx)
 
 
@@ -166,9 +168,12 @@ def confirm(request):
         form=forms.EligibilityVerificationForm(auto_id=True, label_suffix="", verifier=verifier),
     )
 
+    ctx = page.context_dict()
+    ctx["previous_page_button"] = viewmodels.Button.previous_page(url=reverse(ROUTE_START))
+
     # GET from an unverified user, present the form
     if request.method == "GET":
-        return TemplateResponse(request, TEMPLATE_CONFIRM, page.context_dict())
+        return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)
     # POST form submission, process form data, make Eligibility Verification API call
     elif request.method == "POST":
         analytics.started_eligibility(request, types_to_verify)
@@ -180,7 +185,8 @@ def confirm(request):
                 messages.error(request, "Recaptcha failed. Please try again.")
 
             page.forms = [form]
-            return TemplateResponse(request, TEMPLATE_CONFIRM, page.context_dict())
+            ctx.update(page.context_dict())
+            return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)
 
         # form is valid, make Eligibility Verification request to get the verified types
         verified_types = verify.eligibility_from_api(verifier, form, agency)
@@ -189,7 +195,8 @@ def confirm(request):
         if verified_types is None:
             analytics.returned_error(request, types_to_verify, form.errors)
             page.forms = [form]
-            return TemplateResponse(request, TEMPLATE_CONFIRM, page.context_dict())
+            ctx.update(page.context_dict())
+            return TemplateResponse(request, TEMPLATE_CONFIRM, ctx)
         # no types were verified
         elif len(verified_types) == 0:
             return unverified(request)


Test patch: