aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Cobrand/Harrogate.pm199
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm4
-rw-r--r--templates/email/harrogate/submit.txt43
-rw-r--r--web/cobrands/harrogate/base.scss6
4 files changed, 229 insertions, 23 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Harrogate.pm b/perllib/FixMyStreet/Cobrand/Harrogate.pm
index 3d48a5e52..8690557ef 100644
--- a/perllib/FixMyStreet/Cobrand/Harrogate.pm
+++ b/perllib/FixMyStreet/Cobrand/Harrogate.pm
@@ -3,6 +3,7 @@ use base 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
+use feature 'say';
sub council_id { return 2407; }
sub council_area { return 'Harrogate'; }
@@ -54,35 +55,187 @@ Can run with a script or command line like:
=cut
+sub temp_email_to_update {
+ return 'test@example.com';
+}
+
sub temp_update_contacts {
my $self = shift;
- my $category = 'Potholes';
- my $contact = $self->{c}->model('DB::Contact')
- ->search({
- body_id => $self->council_id,
- category => $category,
- })->first
- or die "No such category: $category";
-
- my $fields = [
- {
- 'code' => 'detail_size', # there is already builtin handling for this field in Report::New
- 'variable' => 'true',
- 'order' => '1',
- 'description' => 'Size of the pothole?',
- 'required' => 'true',
- 'datatype' => 'singlevaluelist',
- 'datatype_description' => {},
- 'values' => {
- 'value' => $self->POTHOLE_SIZES,
+ my $contact_rs = $self->{c}->model('DB::Contact');
+
+ my $email = $self->temp_email_to_update;
+ my $_update = sub {
+ my ($category, $field, $category_details) = @_;
+ # NB: we're accepting just 1 field, but supply as array [ $field ]
+
+ my $contact = $contact_rs->find_or_create(
+ {
+ body_id => $self->council_id,
+ category => $category,
+
+ confirmed => 1,
+ deleted => 0,
+ email => $email,
+ editor => 'automated script',
+ note => '',
+ send_method => '',
+ whenedited => \'NOW()',
+ %{ $category_details || {} },
},
+ {
+ key => 'contacts_body_id_category_idx'
+ }
+ );
+
+ say "Editing category: $category";
+
+ my %default = (
+ variable => 'true',
+ order => '1',
+ required => 'no',
+ datatype => 'string',
+ datatype_description => 'a string',
+ );
+
+ if ($field->{datatype} || '' eq 'boolean') {
+ my $description = $field->{description};
+ %default = (
+ %default,
+ datatype => 'singlevaluelist',
+ datatype_description => 'Yes or No',
+ values => { value => [
+ { key => ['No'], name => ['No'] },
+ { key => ['Yes'], name => ['Yes'] },
+ ] },
+ );
}
- ];
- # require IO::String; require RABX;
- # RABX::wire_wr( $fields, IO::String->new(my $extra) );
- $contact->update({ extra => $fields });
+ $contact->update({
+ extra => [ { %default, %$field } ],
+ confirmed => 1,
+ deleted => 0,
+ editor => 'automated script',
+ whenedited => \'NOW()',
+ note => 'Edited by script as per requirements Dec 2014',
+ });
+ };
+
+ $_update->( 'Abandoned vehicles', {
+ code => 'registration',
+ description => 'Vehicle Registration number:',
+ });
+
+ $_update->( 'Dead animals', {
+ code => 'INFO_TEXT',
+ variable => 'false',
+ description => 'We do not remove small species, e.g. squirrels, rabbits, and small birds.',
+ });
+
+ $_update->( 'Flyposting', {
+ code => 'offensive',
+ description => 'Is it offensive?',
+ datatype => 'boolean', # mapped onto singlevaluelist
+ });
+
+ $_update->( 'Flytipping', {
+ code => 'size',
+ description => 'Size?',
+ datatype => 'singlevaluelist',
+ values => { value => [
+ { key => ['Single Item'], name => ['Single item'] },
+ { key => ['Car boot load'], name => ['Car boot load'] },
+ { key => ['Small van load'], name => ['Small van load'] },
+ { key => ['Transit van load'], name => ['Transit van load'] },
+ { key => ['Tipper lorry load'], name => ['Tipper lorry load'] },
+ { key => ['Significant load'], name => ['Significant load'] },
+ ] },
+ });
+
+ $_update->( 'Graffiti', {
+ code => 'offensive',
+ description => 'Is it offensive?',
+ datatype => 'boolean', # mapped onto singlevaluelist
+ });
+
+ $_update->( 'Parks and playgrounds', {
+ code => 'dangerous',
+ description => 'Is it dangerous or could cause injury?',
+ datatype => 'boolean', # mapped onto singlevaluelist
+ });
+
+ $_update->( 'Trees', {
+ code => 'dangerous',
+ description => 'Is it dangerous or could cause injury?',
+ datatype => 'boolean', # mapped onto singlevaluelist
+ });
+
+ # also ensure that the following categories are created:
+ for my $category (
+ 'Car parking',
+ 'Dog and litter bins',
+ 'Dog fouling',
+ 'Other',
+ 'Rubbish (refuse and recycling)',
+ 'Street cleaning',
+ 'Street lighting',
+ 'Street nameplates',
+ ) {
+ say "Creating $category if required";
+ my $contact = $contact_rs->find_or_create(
+ {
+ body_id => $self->council_id,
+ category => $category,
+ confirmed => 1,
+ deleted => 0,
+ email => $email,
+ editor => 'automated script',
+ note => 'Created by script as per requirements Dec 2014',
+ send_method => '',
+ whenedited => \'NOW()',
+ }
+ );
+ }
+
+ my @to_delete = (
+ 'Parks/landscapes', # delete in favour of to parks and playgrounds
+ 'Public toilets', # as no longer in specs
+ );
+ say sprintf "Deleting: %s (if present)", join ',' => @to_delete;
+ $contact_rs->search({
+ body_id => $self->council_id,
+ category => \@to_delete,
+ deleted => 0
+ })->update({
+ deleted => 1,
+ editor => 'automated script',
+ whenedited => \'NOW()',
+ note => 'Deleted by script as per requirements Dec 2014',
+ });
+}
+
+sub contact_email {
+ my $self = shift;
+ return join( '@', 'customerservices', 'harrogate.gov.uk' );
+}
+
+sub process_additional_metadata_for_email {
+ my ($self, $problem, $h) = @_;
+
+ my $additional = '';
+ if (my $extra = $problem->extra) {
+ $additional = join "\n\n", map {
+ if ($_->{name} eq 'INFO_TEXT') {
+ ();
+ }
+ else {
+ sprintf '%s: %s', $_->{description}, $_->{value};
+ }
+ } @$extra;
+ $additional = "\n\n$additional" if $additional;
+ }
+
+ $h->{additional_information} = $additional;
}
1;
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 5d70bf47d..d3c016be6 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -323,6 +323,10 @@ sub send_reports {
$h{user_details} .= sprintf(_('Email: %s'), $row->user->email) . "\n\n";
}
+ if ($cobrand->can('process_additional_metadata_for_email')) {
+ $cobrand->process_additional_metadata_for_email($row, \%h);
+ }
+
my %reporters = ();
my ( $sender_count );
if ($site eq 'emptyhomes') {
diff --git a/templates/email/harrogate/submit.txt b/templates/email/harrogate/submit.txt
new file mode 100644
index 000000000..87df45c0c
--- /dev/null
+++ b/templates/email/harrogate/submit.txt
@@ -0,0 +1,43 @@
+Subject: Problem Report: <?=$values['title']?>
+
+Dear <?=$values['bodies_name']?>,
+
+<?=$values['missing']?><?=$values['multiple']?>A user of
+FixMyStreet has submitted the following report
+of a local problem that they believe might require your attention.
+
+<?=$values['fuzzy']?>, or to provide an update on the problem,
+please visit the following link:
+
+ <?=$values['url']?>
+
+<?=$values['has_photo']?>----------
+
+Name: <?=$values['name']?>
+
+Email: <?=$values['email']?>
+
+<?=$values['phone_line']?><?=$values['category_line']?>Subject: <?=$values['title']?>
+
+<?=$values['detail']?> <?=$values['additional_information']?>
+
+<?=$values['easting_northing']?>Latitude: <?=$values['latitude']?>
+
+Longitude: <?=$values['longitude']?>
+
+<?=$values['closest_address']?>----------
+
+Replies to this email will go to the user who submitted the problem.
+
+<?=$values['signature']?>
+
+This message was sent via FixMyStreet, a project of UKCOD, registered charity
+number 1076346. If there is a more appropriate email address for messages about
+<?=$values['category_footer']?>, please let us know by visiting <https://www.fixmystreet.com/contact>.
+This will help improve the service for local people. We
+also welcome any other feedback you may have.
+
+FixMyStreet is now available for full integration into council
+websites, making life easier for both you and your residents.
+Read more here: https://www.mysociety.org/services/fixmystreet-for-councils/
+
diff --git a/web/cobrands/harrogate/base.scss b/web/cobrands/harrogate/base.scss
index 118f0b8b7..94dd39ee7 100644
--- a/web/cobrands/harrogate/base.scss
+++ b/web/cobrands/harrogate/base.scss
@@ -34,3 +34,9 @@ body.frontpage #site-logo,
color: $nav_fg;
}
}
+
+label[for=form_INFO_TEXT] {
+ background: yellow;
+ border: solid 1px black;
+ padding: 1em;
+}