Repository: cal-itp/benefits

Issue:
Update main layout to show large image by default
The application layout received an update with the Courtesy Cards feature set; the default is to show the large "rider tapping" image on the left and the content on the right, for *most* pages (including the forms).

However the Help and Payment Options pages are still full screen / no image, so we need the option to "turn it off".


Discussion:

Resolving patch:
diff --git a/benefits/core/viewmodels.py b/benefits/core/viewmodels.py
--- a/benefits/core/viewmodels.py
+++ b/benefits/core/viewmodels.py
@@ -74,22 +74,12 @@ def outline_primary(**kwargs):
         return Button(classes=classes, **kwargs)
 
 
-class Image:
-    """Represents a generic image."""
-
-    def __init__(self, src, alt):
-        self.src = src
-        if not self.src.startswith("http"):
-            self.src = f"img/{self.src}"
-
-        self.alt = alt
-
-
-class Icon(Image):
+class Icon:
     """Represents an icon."""
 
     def __init__(self, icon, alt):
-        super().__init__(src=f"icon/{icon}.svg", alt=alt)
+        self.src = f"img/icon/{icon}.svg"
+        self.alt = alt
 
 
 class MediaItem:
@@ -110,7 +100,7 @@ class Page:
     """
     Represents a page of content:
     * title: str
-    * image: core.viewmodels.Image
+    * noimage: bool
     * icon: core.viewmodels.Icon
     * content_title: str
     * media: core.viewmodels.MediaItem[]
@@ -129,7 +119,7 @@ def __init__(self, **kwargs):
         else:
             self.title = f"{_('core.pages.index.title')}: {self.title}"
 
-        self.image = kwargs.get("image")
+        self.noimage = kwargs.get("noimage", False)
         self.icon = kwargs.get("icon")
         self.content_title = kwargs.get("content_title")
         self.media = kwargs.get("media", [])
@@ -151,7 +141,8 @@ def __init__(self, **kwargs):
         self.classes = kwargs.get("classes", [])
         if not isinstance(self.classes, list):
             self.classes = self.classes.split(" ")
-        if isinstance(self.image, Image):
+        if not self.noimage:
+            self.image = "img/ridertappingbankcard.png"
             self.classes.append("with-image")
 
     def context_dict(self):
diff --git a/benefits/core/views.py b/benefits/core/views.py
--- a/benefits/core/views.py
+++ b/benefits/core/views.py
@@ -20,11 +20,6 @@ def _index_content_title():
     return _("core.pages.index.content_title")
 
 
-def _index_image():
-    """Helper returns a viewmodels.Image for the common index page."""
-    return viewmodels.Image("ridertappingbankcard.png", pgettext("image alt text", "core.pages.index.image"))
-
-
 def _index_paragraphs():
     """Helper returns the content paragraphs for the common index page."""
     return [_("core.pages.index.p[0]"), _("core.pages.index.p[1]"), _("core.pages.index.p[2]")]
@@ -49,7 +44,6 @@ def index(request):
     page = viewmodels.Page(
         content_title=_index_content_title(),
         paragraphs=_index_paragraphs(),
-        image=_index_image(),
         buttons=buttons,
         classes="home",
     )
@@ -66,7 +60,6 @@ def agency_index(request, agency):
     page = viewmodels.Page(
         content_title=_index_content_title(),
         paragraphs=_index_paragraphs(),
-        image=_index_image(),
         button=viewmodels.Button.primary(text=_("core.pages.index.continue"), url=reverse("eligibility:index")),
         classes="home",
     )
@@ -91,6 +84,7 @@ def help(request):
         paragraphs=[_("core.pages.help.p[0]"), _("core.pages.help.p[1]")],
         buttons=buttons,
         classes="text-lg-center",
+        noimage=True,
     )
 
     return TemplateResponse(request, "core/help.html", page.context_dict())
@@ -104,6 +98,7 @@ def payment_options(request):
         icon=viewmodels.Icon("bankcard", pgettext("image alt text", "core.icons.bankcard")),
         content_title=_("core.buttons.payment_options"),
         buttons=viewmodels.Button.home(request, text=_("core.buttons.back")),
+        noimage=True,
     )
 
     return TemplateResponse(request, "core/payment-options.html", page.context_dict())
diff --git a/benefits/eligibility/views.py b/benefits/eligibility/views.py
--- a/benefits/eligibility/views.py
+++ b/benefits/eligibility/views.py
@@ -9,7 +9,7 @@
 
 from benefits.core import middleware, recaptcha, session, viewmodels
 from benefits.core.models import EligibilityVerifier
-from benefits.core.views import PageTemplateResponse, _index_image
+from benefits.core.views import PageTemplateResponse
 from . import analytics, api, forms
 
 
@@ -26,7 +26,6 @@ def index(request):
         title=_("eligibility.pages.index.title"),
         content_title=_("eligibility.pages.index.content_title"),
         forms=forms.EligibilityVerifierSelectionForm(agency=agency),
-        image=_index_image(),
     )
 
     if request.method == "POST":
@@ -77,7 +76,6 @@ def start(request):
             ),
         ],
         paragraphs=[_(verifier.start_blurb)],
-        image=_index_image(),
         button=viewmodels.Button.primary(text=_("eligibility.buttons.continue"), url=reverse("eligibility:confirm")),
     )
 


Test patch: