Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: remove Transit Agency viewmodel #1541

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions benefits/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

def _agency_context(agency):
return {
"long_name": agency.long_name,
"short_name": agency.short_name,
"eligibility_index_url": agency.eligibility_index_url,
"info_url": agency.info_url,
"long_name": agency.long_name,
"phone": agency.phone,
"short_name": agency.short_name,
"slug": agency.slug,
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="container text-center">
<h3 id="{{ aria_labelledby_id }}" class="modal-title">{% translate "core.pages.index.agency_selector.headline" %}</h3>
<div class="row gx-lg-5 mx-lg-1 d-flex flex-column flex-lg-row text-start text-lg-center">
{% for agency in agencies %}
{% for agency in active_agencies %}
<div class="col">
<a href="{{ agency.eligibility_index_url }}" class="card mt-lg-4 mx-lg-auto">
<div class="card-body d-flex flex-row-reverse flex-lg-column justify-content-center align-items-center">
Expand Down
2 changes: 1 addition & 1 deletion benefits/core/templates/core/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
{% block call-to-action %}
{% translate "core.pages.index.button" as trigger_text %}
{% include "core/includes/modal-trigger.html" with id="agency-selector" classes="btn btn-lg btn-primary" text=trigger_text %}
{% include "core/includes/modal--agency-selector.html" with id="agency-selector" agencies=agencies %}
{% include "core/includes/modal--agency-selector.html" with id="agency-selector" %}
{% endblock call-to-action %}
24 changes: 0 additions & 24 deletions benefits/core/viewmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"""
from django.utils.translation import gettext_lazy as _

from benefits.core import models


class Button:
"""
Expand Down Expand Up @@ -128,25 +126,3 @@ def __init__(self, **kwargs):
def context_dict(self):
"""Return a context dict for a Page."""
return {"page": self}


class TransitAgency:
"""
Represents a core.models.TransitAgency:
* model: core.models.TransitAgency
"""

def __init__(self, model):
if isinstance(model, models.TransitAgency):
self.slug = model.slug
self.short_name = model.short_name
self.long_name = model.long_name
self.agency_id = model.agency_id
self.merchant_id = model.merchant_id
self.info_url = model.info_url
self.phone = model.phone
self.eligibility_index_url = model.eligibility_index_url

def context_dict(self):
"""Return a context dict for a TransitAgency."""
return {"agency": self}
3 changes: 1 addition & 2 deletions benefits/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.urls import reverse
from django.utils.translation import pgettext, gettext as _

from . import models, session, viewmodels
from . import session, viewmodels
from .middleware import pageview_decorator, index_or_agencyindex_origin_decorator

ROUTE_ELIGIBILITY = "eligibility:index"
Expand Down Expand Up @@ -35,7 +35,6 @@ def index(request):
)

ctx = page.context_dict()
ctx["agencies"] = [viewmodels.TransitAgency(a) for a in models.TransitAgency.all_active()]

return TemplateResponse(request, TEMPLATE_INDEX, ctx)

Expand Down