From da10dbc9284faa8ec5e710b79bd0e2cdf65c891b Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 5 Jul 2024 12:37:59 +0100 Subject: [PATCH] [2024] Remove DC lookup, revert to previous setup. --- markdown/post-election.md | 32 -------- www/docs/postcode/address_list.php | 18 ----- www/docs/postcode/index.php | 73 +------------------ .../html/postcode/ge2024-post-election.php | 43 ----------- .../templates/html/postcode/index.php | 17 ++--- 5 files changed, 11 insertions(+), 172 deletions(-) delete mode 100644 markdown/post-election.md delete mode 100644 www/docs/postcode/address_list.php delete mode 100644 www/includes/easyparliament/templates/html/postcode/ge2024-post-election.php diff --git a/markdown/post-election.md b/markdown/post-election.md deleted file mode 100644 index cbcd343f55..0000000000 --- a/markdown/post-election.md +++ /dev/null @@ -1,32 +0,0 @@ -# The polls are closed! - -{{ rep_link }} - - -The UK general election is now over. - -Through Thursday night and into Friday, the votes will be counted, winners announced - and we will be loading the new MPs into TheyWorkForYou. - -We've prepared a [few blog posts and resources](https://www.mysociety.org/?p=54263) to understand the new Parliament - you can read these [on our blog](https://www.mysociety.org/?p=54263). - -___ - -### Get emails about your MP - -There are many new MPs in this election. You can sign up below to get an email when your new/returning MP has spoken, voted, or received a written answer: - -{{ form }} - -___ - -### Support TheyWorkForYou's work in the coming Parliament - -TheyWorkForYou and WriteToThem are run by [mySociety](https://www.mysociety.org/), a small UK charity. - -We're a very efficient operation and do a lot with a small team. At the moment TheyWorkForYou, which is used by millions of people each year, is run with less than the equivalent of one full-time person. - -If we had [a *bit* more money, we could achieve a *lot* more](/support-us/). - -We want to see a transparent, resilient democracy, with equal access to information, representation and voice for citizens. - -If you believe in this vision [please donate today](/support-us/) to enable greater transparency and accountability of the next government. diff --git a/www/docs/postcode/address_list.php b/www/docs/postcode/address_list.php deleted file mode 100644 index f84593d9ed..0000000000 --- a/www/docs/postcode/address_list.php +++ /dev/null @@ -1,18 +0,0 @@ -
- - -

Please pick your address from the list below: - -

- '; - print ucwords(strtolower($address->address)); - print ''; -} -?> - -

- - -

diff --git a/www/docs/postcode/index.php b/www/docs/postcode/index.php index fdecaab71b..9be4f4b0c4 100644 --- a/www/docs/postcode/index.php +++ b/www/docs/postcode/index.php @@ -24,31 +24,11 @@ # 2024 ELECTION EXTRA -$data['address'] = $address = get_http_var('address'); -if ($address) { - $dc_data = democracy_club_address($address); - $constituencies = mapit_address($address, $pc); -} else { - $dc_data = democracy_club_postcode($pc); - if (!isset($dc_data->error) && $dc_data->address_picker) { - show_address_list($pc, $dc_data->addresses); - exit; - } - $constituencies = mapit_postcode($pc); -} -if (!$constituencies || isset($dc_data->error) || !$dc_data->dates) { +$constituencies = mapit_postcode($pc); +if (!$constituencies) { postcode_error("Sorry, " . _htmlentities($pc) . " isn't a known postcode"); } -$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'])) { $data['multi'] = "scotland"; $MEMBER = fetch_mp($pc, $constituencies); @@ -64,17 +44,9 @@ } else { $data['multi'] = "uk"; $MEMBER = fetch_mp($pc, $constituencies, 1); - $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'); + member_redirect($MEMBER); } -$data['mapit_ids'] = $mapit_ids; MySociety\TheyWorkForYou\Renderer::output('postcode/index', $data); # --- @@ -201,37 +173,12 @@ function member_redirect(&$MEMBER) { } } -function democracy_club_postcode($pc) { - $pc = urlencode($pc); - $data = web_lookup("https://developers.democracyclub.org.uk/api/v1/postcode/$pc/?include_current=1&auth_token=" . OPTION_DEMOCRACYCLUB_TOKEN); - $data = json_decode($data); - return $data; -} - -function democracy_club_address($address) { - $address = urlencode($address); - $data = web_lookup("https://developers.democracyclub.org.uk/api/v1/address/$address/?include_current=1&auth_token=" . OPTION_DEMOCRACYCLUB_TOKEN); - $data = json_decode($data); - return $data; -} - function mapit_postcode($postcode) { $filename = 'postcode/' . rawurlencode($postcode); return mapit_lookup('postcode', $filename); } -function mapit_address($address, $pc) { - $address = urlencode($address); - $url = str_replace('{s}', $address, OPTION_MAPIT_UPRN_LOOKUP); - $file = web_lookup($url); - $r = json_decode($file); - if (isset($r->error)) return mapit_postcode($pc); - $filename = 'point/4326/' . $r->wgs84_lon . ',' . $r->wgs84_lat; - return mapit_lookup('point', $filename); -} - function mapit_lookup($type, $filename) { - global $mapit_ids; $file = web_lookup(OPTION_MAPIT_URL . $filename); $r = json_decode($file); if (isset($r->error)) return ''; @@ -242,12 +189,6 @@ function mapit_lookup($type, $filename) { foreach ($input as $row) { if (in_array($row->type, array('WMC', 'WMCF', 'SPC', 'SPE', 'NIE', 'WAC', 'WAE'))) $areas[$row->type] = $row->name; - if ($row->type == 'WMC') { - $mapit_ids['old'] = $row->id; - } - if ($row->type == 'WMCF') { - $mapit_ids['new'] = $row->id; - } } if (!isset($areas['WMC'])) { return ''; @@ -255,14 +196,6 @@ function mapit_lookup($type, $filename) { return $areas; } -function show_address_list($pc, $addresses) { - global $PAGE; - $PAGE->page_start(); - $PAGE->stripe_start(); - include("address_list.php"); - $PAGE->page_end(); -} - function web_lookup($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); diff --git a/www/includes/easyparliament/templates/html/postcode/ge2024-post-election.php b/www/includes/easyparliament/templates/html/postcode/ge2024-post-election.php deleted file mode 100644 index a6dbf51002..0000000000 --- a/www/includes/easyparliament/templates/html/postcode/ge2024-post-election.php +++ /dev/null @@ -1,43 +0,0 @@ - - - -
- - "> - - - - - -
- - - - -

See your current

- - -text($text); - -$html = str_replace("{{ form }}", $form, $html); -$html = str_replace("{{ rep_link }}", $rep_link , $html); -echo $html; -?> - - diff --git a/www/includes/easyparliament/templates/html/postcode/index.php b/www/includes/easyparliament/templates/html/postcode/index.php index 7f8751d1ef..b48d81ffd2 100644 --- a/www/includes/easyparliament/templates/html/postcode/index.php +++ b/www/includes/easyparliament/templates/html/postcode/index.php @@ -37,17 +37,8 @@ function member_image_box(string $person_id, string $person_url, string $person_ } } -include "ge2024-post-election.php"; - -# The below is normally the main column, but for now let us make it the sidebar... - - ?> - -