aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-12-11 16:26:16 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-12-19 17:02:04 +0000
commit584b6297f229f5fa2e1c0b44d9078a7b09e83e63 (patch)
tree72ec475e98874cabae576cc31ad1aa2887b05364
parentcfb0dd09a7be10d6443995930cbb8739f4d1ecc7 (diff)
[Buckinghamshire] Get topic when reporting abuse.
-rw-r--r--perllib/FixMyStreet/Cobrand/Buckinghamshire.pm19
-rw-r--r--t/app/controller/contact.t136
-rw-r--r--templates/web/buckinghamshire/contact/who.html48
3 files changed, 129 insertions, 74 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
index 1b437b2c5..055e481d9 100644
--- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
@@ -358,5 +358,24 @@ sub lookup_site_code_config { {
}
} }
+sub extra_contact_validation {
+ my $self = shift;
+ my $c = shift;
+
+ # Don't care about dest unless reporting abuse
+ return () unless $c->stash->{problem};
+
+ my %errors;
+
+ $c->stash->{dest} = $c->get_param('dest');
+
+ if (!$c->get_param('dest')) {
+ $errors{dest} = "Please enter a topic of your message";
+ } elsif ( $c->get_param('dest') eq 'council' || $c->get_param('dest') eq 'update' ) {
+ $errors{not_for_us} = 1;
+ }
+
+ return %errors;
+}
1;
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t
index 3fa83be9b..fe67e89ec 100644
--- a/t/app/controller/contact.t
+++ b/t/app/controller/contact.t
@@ -279,25 +279,16 @@ for my $test (
};
}
-for my $test (
- {
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- },
- },
- {
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- id => $problem_main->id,
- },
- },
+my %common = (
+ em => 'test@example.com',
+ name => 'A name',
+ subject => 'A subject',
+ message => 'A message',
+);
+for my $test (
+ { fields => \%common },
+ { fields => { %common, id => $problem_main->id } },
)
{
subtest 'check email sent correctly' => sub {
@@ -336,13 +327,7 @@ for my $test (
for my $test (
{
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- dest => undef,
- },
+ fields => { %common, dest => undef },
page_errors =>
[ 'There were problems with your report. Please see below.',
'Please enter who your message is for',
@@ -350,26 +335,14 @@ for my $test (
]
},
{
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- dest => 'council',
- },
+ fields => { %common, dest => 'council' },
page_errors =>
[ 'There were problems with your report. Please see below.',
'You can only contact the team behind FixMyStreet using our contact form',
]
},
{
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- dest => 'update',
- },
+ fields => { %common, dest => 'update' },
page_errors =>
[ 'There were problems with your report. Please see below.',
'You can only contact the team behind FixMyStreet using our contact form',
@@ -404,33 +377,9 @@ for my $test (
}
for my $test (
- {
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- dest => 'help',
- },
- },
- {
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- dest => 'feedback',
- },
- },
- {
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- dest => 'from_council',
- },
- },
+ { fields => { %common, dest => 'help' } },
+ { fields => { %common, dest => 'feedback' } },
+ { fields => { %common, dest => 'from_council' } },
)
{
subtest 'check email sent correctly with dest field set to us' => sub {
@@ -448,11 +397,53 @@ for my $test (
for my $test (
{
+ fields => { %common, dest => undef },
+ page_errors =>
+ [ 'There were problems with your report. Please see below.',
+ 'Please enter a topic of your message',
+ 'You can only use this form to report inappropriate content', # The JS-hidden one
+ ]
+ },
+ {
+ fields => { %common, dest => 'council' },
+ page_errors =>
+ [ 'There were problems with your report. Please see below.',
+ 'You can only use this form to report inappropriate content',
+ ]
+ },
+ {
+ fields => { %common, dest => 'update' },
+ page_errors =>
+ [ 'There were problems with your report. Please see below.',
+ 'You can only use this form to report inappropriate content',
+ ]
+ },
+ )
+{
+ subtest 'check Bucks submit page incorrect destination handling' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'buckinghamshire' ],
+ }, sub {
+ $mech->get_ok( '/contact?id=' . $problem_main->id, 'can visit for abuse report' );
+ $mech->submit_form_ok( { with_fields => $test->{fields} } );
+ is_deeply $mech->page_errors, $test->{page_errors}, 'page errors';
+
+ $test->{fields}->{'extra.phone'} = '';
+ is_deeply $mech->visible_form_values, $test->{fields}, 'form values';
+
+ if ( $test->{fields}->{dest} and $test->{fields}->{dest} eq 'update' ) {
+ $mech->content_contains('please leave an update');
+ } elsif ( $test->{fields}->{dest} and $test->{fields}->{dest} eq 'council' ) {
+ $mech->content_contains('should find other contact details');
+ }
+ }
+ };
+}
+
+for my $test (
+ {
fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
+ %common,
dest => 'from_council',
success_url => '/faq',
},
@@ -460,10 +451,7 @@ for my $test (
},
{
fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
+ %common,
dest => 'from_council',
success_url => 'http://www.example.com',
},
diff --git a/templates/web/buckinghamshire/contact/who.html b/templates/web/buckinghamshire/contact/who.html
new file mode 100644
index 000000000..e3b045521
--- /dev/null
+++ b/templates/web/buckinghamshire/contact/who.html
@@ -0,0 +1,48 @@
+[% IF problem %]
+<h4>Topic:</h4>
+
+[% IF field_errors.dest %]
+<div class="form-error">[% field_errors.dest %]</div>
+[% END %]
+
+<div class="checkbox-group">
+ <input name="dest" id="dest_rules" type="radio" value="rules" class="required"[% IF dest AND dest == 'rules' %] checked[% END %]>
+ <label class="inline" for="dest_rules">This [% update ? 'update' : 'report' %] is abusive, contains personal information, or similar</label>
+</div>
+
+<div class="checkbox-group">
+ <input name="dest" id="dest_update" type="radio" value="update" class="required"[% IF dest AND dest == 'update' %] checked[% END %]>
+ <label class="inline" for="dest_update">I wish to report it has not been fixed yet</label>
+</div>
+
+<div class="checkbox-group">
+ <input name="dest" id="dest_council" type="radio" value="council" class="required"[% IF dest AND dest == 'council' %] checked[% END %]>
+ <label class="inline" for="dest_council">I wish to make a new report</label>
+</div>
+
+<div id="dest-error"[% IF NOT field_errors.not_for_us %] class="hidden"[% END %]>
+ <div class="form-error">You can only use this form to report inappropriate content</div>
+
+ <div class="form-error__box form-error--council[% IF dest != 'council' %] hidden[% END %]">
+ <p>
+ <strong>If you want to report a street problem</strong>, return to the
+ <a href="/">homepage</a> and enter your postcode. You can then make a report.
+ We'll send it to your council, and publish it on the site.
+ </p>
+ <p>
+ <strong>If your problem is not a street issue</strong>, or is <strong>not
+ suitable for publication on the site</strong>, then this isn't the
+ right place for it. You should find other contact details on the
+ <a href="https://www.buckscc.gov.uk/">council's website</a>.
+ </p>
+ </div>
+
+ <div class="form-error__box form-error--update[% IF dest != 'update' %] hidden[% END %]">
+ <p>
+ <strong>If you'd like to update a report</strong>, please leave an update
+ on the <a href="/report/[% problem.id %]">report’s page</a>, underneath the report details.
+ </p>
+ </div>
+</div>
+
+[% END %]