Skip to content

Commit

Permalink
Add test for missing MP on postcode result page.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jul 4, 2024
1 parent 8181bc8 commit ce412cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions www/docs/postcode/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function pick_multiple($pc, $areas, $area_type, $house) {
$mp['former'] = ($mp['left_house'] != '9999-12-31');
$q = $db->query("SELECT * FROM personinfo where person_id=:person_id AND data_key='standing_down_2024'", [':person_id' => $mp['person_id']]);
$mp['standing_down_2024'] = $q['data_value'] ?? 0;
$mp['name'] = $mp['given_name'] . ' ' . $mp['family_name'];
}

$query_base = "SELECT member.person_id, given_name, family_name, constituency, house
Expand Down Expand Up @@ -183,8 +184,6 @@ function pick_multiple($pc, $areas, $area_type, $house) {
$data['areas'] = $areas;
$data['area_type'] = $area_type;
$data['member_names'] = $member_names;

$mp['name'] = $mp['given_name'] . ' ' . $mp['family_name'];
$data['mp'] = $mp;

$data['MPSURL'] = new \MySociety\TheyWorkForYou\Url('mps');
Expand Down
4 changes: 4 additions & 0 deletions www/includes/easyparliament/templates/html/postcode/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function member_image_box(string $person_id, string $person_url, string $person_
<div id="current">
<h2><?= gettext('Your representatives') ?></h2>
<ul>
<?php if ($mp) { ?>
<li class="postcode-rep-list__item"><span>
<?php if ($mp['former']) {
printf(gettext('Your former <strong>MP</strong> (Member of Parliament) is <a href="%s">%s</a>, %s'), '/mp/?p=' . $mp['person_id'], $mp['name'], gettext($mp['constituency']));
Expand All @@ -63,6 +64,9 @@ function member_image_box(string $person_id, string $person_url, string $person_
</span>
<?php member_image_box($mp["person_id"], '/mp/?p=' . $mp['person_id'], $mp['name']) ?>
</li>
<?php } else { ?>
<li>Your MP is currently unknown.</li>
<?php } ?>

<?php
if (isset($mcon) && !empty($mcon)) {
Expand Down

0 comments on commit ce412cf

Please sign in to comment.