Skip to content

Commit

Permalink
Switch postcode page to post election screen
Browse files Browse the repository at this point in the history
- kicks in after 10 (or on post_election = 1)
- includes form based on postcode to sign up for alerts
  • Loading branch information
ajparsons committed Jul 4, 2024
1 parent 7b4d6d5 commit 1e5331d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
29 changes: 29 additions & 0 deletions markdown/post-election.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# The polls are closed!

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 every year, is run with the equivalent of about two people.

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.
7 changes: 7 additions & 0 deletions www/docs/postcode/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
$data = array();
$errors = array();

// handling to switch the GE message based either on time or a query string

$now = new DateTime();
$election_date = new DateTime('2024-07-04 22:00:00');

$data['post_election_message'] = (($now > $election_date) || (get_http_var("post_election") == 1));

$pc = get_http_var('pc');
if (!$pc) {
postcode_error('Please supply a postcode!');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


<?php ob_start(); ?>
<form class="alerts-form" method="post" action="/alert/by-postcode/">
<input type="hidden" name="add-alert" value="1">
<input type="hidden" name="postcode" id="id_postcode" value="<?= strtoupper($data["pc"]) ?>">

<label for="id_email">Your email address</label>
<input type="text" name="email" id="id_email">

<button type="submit" class="button radius">Set up alerts</button>
</form>
<?php $form = ob_get_clean(); ?>


<?php
$markdown_file = '../../../markdown/post-election.md';
$Parsedown = new \Parsedown();

$text = file_get_contents($markdown_file);
$html = $Parsedown->text($text);

$html = str_replace("{{ form }}", $form, $html);

echo $html;
?>


Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ function member_image_box(string $person_id, string $person_url, string $person_
}
}

include "ge2024.php";
if ($post_election_message) {
include "ge2024-post-election.php";
} else {
include "ge2024.php";
};

# The below is normally the main column, but for now let us make it the sidebar...

Expand Down

0 comments on commit 1e5331d

Please sign in to comment.