diff --git a/chicago/models.py b/chicago/models.py index f13adae..37b7a12 100644 --- a/chicago/models.py +++ b/chicago/models.py @@ -4,6 +4,7 @@ import pytz from councilmatic_core.models import Bill, Event, Organization, Person +from chicago.utils import get_alder_extras from dateutil.relativedelta import relativedelta from django.conf import settings from django.db import models @@ -225,24 +226,28 @@ def legislation_count(self): sponsorships__person=self, sponsorships__primary=True ).count() - @property - def election_status(self): - for p in settings.ALDER_EXTRAS: - if ( - self.slug.startswith(p) - and "election-status" in settings.ALDER_EXTRAS[p] - ): - return settings.ALDER_EXTRAS[p]["election-status"] + def extra_props(self, key): + extra = get_alder_extras(self.slug) + if extra and key in extra: + return extra[key] return "" @property def caucus(self): - for p in settings.ALDER_EXTRAS: - if self.slug.startswith(p) and "caucus" in settings.ALDER_EXTRAS[p]: - return settings.ALDER_EXTRAS[p]["caucus"] + return self.extra_props("caucus") - return "" + @property + def candidate_id(self): + return self.extra_props("candidate_id") + + @property + def manual_headshot(self): + image_path = self.extra_props("image") + if image_path: + return f"/static/images/manual-headshots/{image_path}" # noqa + + return "/static/images/headshot_placeholder.png" @property def term_active(self): diff --git a/chicago/settings.py b/chicago/settings.py index 4b7d246..1596711 100644 --- a/chicago/settings.py +++ b/chicago/settings.py @@ -30,7 +30,7 @@ sentry_sdk.init( dsn=os.environ["SENTRY_DSN"], integrations=[DjangoIntegration()], - release=f"{os.environ['HEROKU_RELEASE_VERSION']}-{os.environ['HEROKU_APP_NAME']}", + release=f"{os.environ['HEROKU_RELEASE_VERSION']}-{os.environ['HEROKU_APP_NAME']}", # noqa enable_tracing=True, traces_sample_rate=0.05, ) @@ -326,210 +326,6 @@ "valencia-anna-m-257a68ccbc17": "City Clerk", } -ALDER_EXTRAS = { - "abarca-anabel": {"image": "abarca-anabel.jpg"}, - "arena-john": {"image": "arena-john.jpg"}, - "austin-carrie-m": { - "image": "austin-carrie-m.jpg", - "election-status": "Indicted, Retiring", - "caucus": "Black Caucus", - }, - "beale-anthony": {"image": "beale-anthony.jpg", "caucus": "Black Caucus"}, - "brookins-jr-howard": { - "image": "brookins-jr-howard.jpg", - "caucus": "Black Caucus", - "election-status": "Retiring", - }, - "burke-edward-m": { - "image": "burke-edward-m.jpg", - "election-status": "Indicted, Retiring", - }, - "burnett-jr-walter": {"image": "burnett-jr-walter.jpg", "caucus": "Black Caucus"}, - "burns-william-d": {"image": "burns-william-d.jpg"}, - "cappleman-james": { - "image": "cappleman-james.jpg", - "election-status": "Retiring", - "caucus": "LGBT Caucus", - }, - "cardenas-george-a": {"image": "cardenas-george-a.jpg", "caucus": "Latino Caucus"}, - "cardona-jr-felix": { - "image": "cardona-jr-felix.jpg", - "caucus": "Latino Caucus", - }, - "cochran-willie": {"image": "cochran-willie.jpg"}, - "coleman-stephanie-d": { - "image": "coleman-stephanie-d.jpg", - "caucus": "Black Caucus", - }, - "curtis-derrick-g": {"image": "curtis-derrick-g.jpg", "caucus": "Black Caucus"}, - "dowell-pat": {"image": "dowell-pat.jpg", "caucus": "Black Caucus"}, - "emanuel-rahm": {"image": "emanuel-rahm.jpg"}, - "ervin-jason-c": {"image": "ervin-jason-c.jpg", "caucus": "Black Caucus"}, - "foulkes-toni": {"image": "foulkes-toni.jpg"}, - "gardiner-james-m": {"image": "gardiner-james-m.jpg"}, - "hadden-maria-e": { - "image": "hadden-maria-e.jpg", - "caucus": "Black Caucus, Progressive Caucus, LGBT Caucus", - }, - "hairston-leslie-a": { - "image": "hairston-leslie-a.jpg", - "election-status": "Retiring", - "caucus": "Black Caucus, Progressive Caucus", - }, - "harris-michelle-a": {"image": "harris-michelle-a.jpg", "caucus": "Black Caucus"}, - "hopkins-brian": {"image": "hopkins-brian.jpg"}, - "king-sophia": { - "image": "king-sophia.jpg", - "election-status": "Running for Mayor, not seeking re-election", - "caucus": "Black Caucus, Progressive Caucus", - }, - "knudsen-timothy-r": {"image": "knudsen-timothy-r.jpg", "caucus": "LGBT Caucus"}, - "la-spata-daniel": { - "image": "la-spata-daniel.jpg", - "caucus": "Democratic Socialist, Latino Caucus, Progressive Caucus", - }, - "laurino-margaret": {"image": "laurino-margaret.jpg"}, - "lee-nicole-t": {"image": "lee-nicole-t.jpg"}, - "lopez-raymond-a": {"image": "lopez-raymond-a.jpg", "caucus": "LGBT Caucus"}, - "lightfoot-lori-e": {"image": "lightfoot-lori-e.jpg"}, - "maldonado-roberto": { - "image": "maldonado-roberto.jpg", - "election-status": "Retiring", - "caucus": "Latino Caucus", - }, - "martin-matthew-j": { - "image": "martin-matthew-j.jpg", - "caucus": "Black Caucus, Progressive Caucus", - }, - "mell-deborah": {"image": "mell-deborah.jpg"}, - "mendoza-susana-a": {"image": "mendoza-susana-a.jpg"}, - "mitchell-gregory-i": {"image": "mitchell-gregory-i.jpg", "caucus": "Black Caucus"}, - "mitts-emma": {"image": "mitts-emma.jpg", "caucus": "Black Caucus"}, - "moore-david-h": { - "image": "moore-david-h.jpg", - "caucus": "Black Caucus", - }, - "moore-joseph": {"image": "moore-joseph.jpg"}, - "moreno-proco-joe": {"image": "moreno-proco-joe.jpg"}, - "munoz-ricardo": {"image": "munoz-ricardo.jpg"}, - "napolitano-anthony-v": {"image": "napolitano-anthony-v.jpg"}, - "nugent-samantha": {"image": "nugent-samantha.jpg"}, - "oconnor-patrick": {"image": "oconnor-patrick.jpg"}, - "oshea-matthew-j": {"image": "oshea-matthew-j.jpg"}, - "osterman-harry": {"image": "osterman-harry.jpg", "election-status": "Retiring"}, - "pawar-ameya": {"image": "pawar-ameya.jpg"}, - "quinn-marty": {"image": "quinn-marty.jpg"}, - "ramirez-rosa-carlos": { - "image": "ramirez-rosa-carlos.jpg", - "caucus": "Democratic Socialist, Latino Caucus, Progressive Caucus, LGBT Caucus", # noqa - }, - "reboyras-ariel": { - "image": "reboyras-ariel.jpg", - "caucus": "Latino Caucus", - "election-status": "Retiring", - }, - "reilly-brendan": {"image": "reilly-brendan.jpg"}, - "rodriguez-michael-d": { - "image": "rodriguez-michael-d.jpg", - "caucus": "Latino Caucus, Progressive Caucus", - }, - "rodriguez-sanchez-rossana": { - "image": "rodriguez-sanchez-rossana.jpg", - "caucus": "Democratic Socialist, Latino Caucus, Progressive Caucus", - }, - "sadlowski-garza-susan": { - "image": "sadlowski-garza-susan.jpg", - "election-status": "Retiring", - "caucus": "Latino Caucus, Progressive Caucus", - }, - "santiago-milagros-s": {"image": "santiago-milagros-s.jpg"}, - "sawyer-roderick-t": { - "image": "sawyer-roderick-t.jpg", - "election-status": "Running for Mayor, not seeking re-election", - "caucus": "Black Caucus, Progressive Caucus", - }, - "scott-jr-michael": {"image": "scott-jr-michael.jpg", "caucus": "Black Caucus"}, - "scott-monique-l": {"image": "scott-monique-l.jpg", "caucus": "Black Caucus"}, - "sigcho-lopez-byron": { - "image": "sigcho-lopez-byron.jpg", - "caucus": "Democratic Socialist, Latino Caucus, Progressive Caucus", - }, - "silverstein-debra-l": {"image": "silverstein-debra-l.jpg"}, - "smith-michele": {"image": "smith-michele.jpg", "election-status": "Retiring"}, - "solis-daniel": {"image": "solis-daniel.jpg"}, - "sposato-nicholas": {"image": "sposato-nicholas.png"}, - "tabares-silvana": {"image": "tabares-silvana.jpg", "caucus": "Latino Caucus"}, - "taliaferro-chris": { - "image": "taliaferro-chris.jpg", - "caucus": "Black Caucus", - }, - "taylor-jeanette-b": { - "image": "taylor-jeanette-b.jpg", - "caucus": "Black Caucus, Democratic Socialist, Progressive Caucus", - }, - "thompson-patrick-d": {"image": "thompson-patrick-d.jpg"}, - "tunney-thomas": { - "image": "tunney-thomas.jpg", - "election-status": "Retiring", - "caucus": "LGBT Caucus", - }, - "valencia-anna-m": {"image": "valencia-anna-m.jpg"}, - "vasquez-jr-andre": { - "image": "vasquez-jr-andre.jpg", - "caucus": "Latino Caucus, Progressive Caucus", - }, - "villegas-gilbert": {"image": "villegas-gilbert.jpg", "caucus": "Latino Caucus"}, - "waguespack-scott": { - "image": "waguespack-scott.jpg", - "caucus": "", - }, - "zalewski-michael-r": {"image": "zalewski-michael-r.jpg"}, - "yancy-desmon-c": { - "image": "yancy-desmon-c.jpg", - "caucus": "Black Caucus, Progressive Caucus", - }, - "robinson-lamont": { - "image": "robinson-lamont.jpg", - "caucus": "Black Caucus", - }, - "ramirez-julia-m": { - "image": "ramirez-julia-m.jpg", - "caucus": "Latino Caucus, Progressive Caucus", - }, - "mosley-ronnie-l": { - "image": "mosley-ronnie-l.jpg", - "caucus": "Black Caucus", - }, - "manaa-hoppenworth-leni": {"image": "manaa-hoppenworth-leni.jpg"}, - "lawson-bennett-r": {"image": "lawson-bennett-r.jpg"}, - "hall-william-e": { - "image": "hall-william-e.jpg", - "caucus": "Black Caucus", - }, - "gutierrez-jeylu-b": { - "image": "gutierrez-jeylu-b.jpg", - "caucus": "Latino Caucus, Progressive Caucus", - }, - "fuentes-jessica": { - "image": "fuentes-jessica.jpg", - "caucus": "Latino Caucus, Progressive Caucus", - }, - "cruz-ruth": { - "image": "cruz-ruth.jpg", - "caucus": "Latino Caucus, Progressive Caucus", - }, - "conway-william": {"image": "conway-william.jpg"}, - "clay-angela": { - "image": "clay-angela.jpg", - "caucus": "Progressive Caucus", - }, - "chico-peter": { - "image": "chico-peter.jpg", - "caucus": "Latino Caucus", - }, - "johnson-brandon": {"image": "johnson-brandon.jpg"}, -} - TOPIC_HIERARCHY = [ { "name": "Citywide matters", diff --git a/chicago/templates/compare_council_members.html b/chicago/templates/compare_council_members.html index 59c3dab..6599a6f 100644 --- a/chicago/templates/compare_council_members.html +++ b/chicago/templates/compare_council_members.html @@ -32,7 +32,7 @@