diff --git a/conf/general-example b/conf/general-example index 8fd538b984..894de7bcac 100644 --- a/conf/general-example +++ b/conf/general-example @@ -161,6 +161,8 @@ define('OPTION_HEARFROMYOURMP_BASE_URL', ''); if (!defined('OPTION_MAPIT_URL')) { define('OPTION_MAPIT_URL', ''); } +define('OPTION_DEMOCRACYCLUB_TOKEN', ''); +define('OPTION_MAPIT_UPRN_LOOKUP', ''); // For seeing if someone is in New Zealand. define('OPTION_GAZE_URL', ''); diff --git a/scripts/mpinfoin.pl b/scripts/mpinfoin.pl index cfdfda0e24..5f66dcea16 100755 --- a/scripts/mpinfoin.pl +++ b/scripts/mpinfoin.pl @@ -87,8 +87,8 @@ $twig->parsefile($pwmembers . "wikipedia-commons.xml", ErrorContext => 2); print " Lords \"\n" if $verbose; $twig->parsefile($pwmembers . "wikipedia-lords.xml", ErrorContext => 2); - #print " MPs standing down\n" if $verbose; - #$twig->parsefile($pwmembers . "wikipedia-standingdown.xml", ErrorContext => 2); + print " MPs standing down\n" if $verbose; + $twig->parsefile($pwmembers . "wikipedia-standingdown.xml", ErrorContext => 2); print " Bishops\n" if $verbose; $twig->parsefile($pwmembers . "diocese-bishops.xml", ErrorContext => 2); print " BBC\n" if $verbose; diff --git a/www/docs/mp/index.php b/www/docs/mp/index.php index 9893284370..32bd236413 100644 --- a/www/docs/mp/index.php +++ b/www/docs/mp/index.php @@ -344,6 +344,7 @@ $data['previous_offices'] = $MEMBER->offices('previous'); $data['register_interests'] = person_register_interests($MEMBER, $MEMBER->extra_info); $data['eu_stance'] = $MEMBER->getEUStance(); +$data['standing_down_2024'] = $MEMBER->extra_info['standing_down_2024'] ?? ''; # People who are or were MPs and Lords potentially have voting records, except Sinn Fein MPs $data['has_voting_record'] = ( ($MEMBER->house(HOUSE_TYPE_COMMONS) && $MEMBER->party() != 'Sinn Féin') || $MEMBER->house(HOUSE_TYPE_LORDS) ); diff --git a/www/docs/postcode/address_list.php b/www/docs/postcode/address_list.php new file mode 100644 index 0000000000..b9fc651a10 --- /dev/null +++ b/www/docs/postcode/address_list.php @@ -0,0 +1,18 @@ +
diff --git a/www/docs/postcode/index.php b/www/docs/postcode/index.php index 259e156d05..8020d6ae67 100644 --- a/www/docs/postcode/index.php +++ b/www/docs/postcode/index.php @@ -5,12 +5,14 @@ include_once '../../includes/easyparliament/init.php'; include_once INCLUDESPATH . 'easyparliament/member.php'; +$data = array(); $errors = array(); $pc = get_http_var('pc'); if (!$pc) { postcode_error('Please supply a postcode!'); } +$data['pc'] = $pc; $pc = preg_replace('#[^a-z0-9]#i', '', $pc); if (!validate_postcode($pc)) { @@ -18,39 +20,60 @@ postcode_error("Sorry, " . _htmlentities($pc) . " isn't a valid postcode"); } -$constituencies = MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($pc); -if ($constituencies == 'CONNECTION_TIMED_OUT') { - postcode_error("Sorry, we couldn't check your postcode right now, as our postcode lookup server is under quite a lot of load."); -} elseif (!$constituencies) { +# 2024 ELECTION EXTRA + +$address = get_http_var('address'); +if ($address) { + $dc_data = democracy_club_address($address); + $constituencies = mapit_address($address); +} else { + $dc_data = democracy_club_postcode($pc); + if ($dc_data->address_picker) { + show_address_list($pc, $dc_data->addresses); + exit; + } + $constituencies = mapit_postcode($pc); +} +if (!$constituencies) { postcode_error("Sorry, " . _htmlentities($pc) . " isn't a known postcode"); } -$out = ''; $sidebars = array(); +$data['ballot'] = null; +foreach ($dc_data->dates as $date) { + if ($date->date != '2024-07-04') continue; + foreach ($date->ballots as $b) { + if ($b->election_id != 'parl.2024-07-04') continue; + $data['ballot'] = $b; + } +} + if (isset($constituencies['SPE']) || isset($constituencies['SPC'])) { - $multi = "scotland"; + $data['multi'] = "scotland"; $MEMBER = fetch_mp($pc, $constituencies); - list($out, $sidebars) = pick_multiple($pc, $constituencies, 'SPE', HOUSE_TYPE_SCOTLAND); + pick_multiple($pc, $constituencies, 'SPE', HOUSE_TYPE_SCOTLAND); } elseif (isset($constituencies['WAE']) || isset($constituencies['WAC'])) { - $multi = "wales"; + $data['multi'] = "wales"; $MEMBER = fetch_mp($pc, $constituencies); - list($out, $sidebars) = pick_multiple($pc, $constituencies, 'WAE', HOUSE_TYPE_WALES); + pick_multiple($pc, $constituencies, 'WAE', HOUSE_TYPE_WALES); } elseif (isset($constituencies['NIE'])) { - $multi = "northern-ireland"; + $data['multi'] = "northern-ireland"; $MEMBER = fetch_mp($pc, $constituencies); - list($out, $sidebars) = pick_multiple($pc, $constituencies, 'NIE', HOUSE_TYPE_NI); + pick_multiple($pc, $constituencies, 'NIE', HOUSE_TYPE_NI); } else { - # Just have an MP, redirect instantly to the canonical page - $multi = "uk"; + $data['multi'] = "uk"; $MEMBER = fetch_mp($pc, $constituencies, 1); - member_redirect($MEMBER); + $data['mp'] = [ + 'name' => $MEMBER->full_name(), + 'person_id' => $MEMBER->person_id(), + 'constituency' => $MEMBER->constituency(), + 'former' => !$MEMBER->current_member(HOUSE_TYPE_COMMONS), + 'standing_down_2024' => $MEMBER->extra_info['standing_down_2024'] ?? '', + ]; + $data['MPSURL'] = new \MySociety\TheyWorkForYou\Url('mps'); } -$PAGE->page_start(); -$PAGE->stripe_start(); -echo $out; -include("repexplain.php"); -$PAGE->stripe_end($sidebars); -$PAGE->page_end(); +$data['mapit_ids'] = $mapit_ids; +MySociety\TheyWorkForYou\Renderer::output('postcode/index', $data); # --- @@ -83,7 +106,7 @@ function fetch_mp($pc, $constituencies, $house=null) { } function pick_multiple($pc, $areas, $area_type, $house) { - global $PAGE; + global $PAGE, $data; $db = new ParlDB; $member_names = \MySociety\TheyWorkForYou\Utility\House::house_to_members($house); @@ -108,9 +131,9 @@ function pick_multiple($pc, $areas, $area_type, $house) { $mp = array(); if ($q) { $mp = $q; - if ($mp['left_house'] != '9999-12-31') { - $mp['former'] = true; - } + $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']; } $a = array_values($areas); @@ -151,77 +174,21 @@ function pick_multiple($pc, $areas, $area_type, $house) { return; } } + $data['mcon'] = $mcon; + $data['mreg'] = $mreg; + $data['house'] = $house; + $data['urlp'] = $urlp; + $data['current'] = $current; + $data['areas'] = $areas; + $data['area_type'] = $area_type; + $data['member_names'] = $member_names; - $out = ''; - $out .= '