aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-08-01 11:30:53 +0100
committerStruan Donald <struan@exo.org.uk>2013-08-01 11:30:53 +0100
commit094e926d6c62bc8e9e45e69ec256744cda169d7d (patch)
tree175c02563e3386a89461d63c77f76a541f628920
parente7c62cbd10d8d751b816517939ccf466f5e804dd (diff)
Send back a list of titles in new report ajax details
This is so that the mobile app can use the list to build the appropriate UI as fixing the HTML that is sent for the site is too awful.
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm3
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm3
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm8
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm11
-rw-r--r--t/app/controller/report_new.t7
5 files changed, 31 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 788e57be0..3d3ddce1e 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -189,11 +189,14 @@ sub report_form_ajax : Path('ajax') : Args(0) {
? $c->render_fragment('report/new/extra_name.html')
: '';
+ my $extra_titles_list = $c->cobrand->title_list($c->stash->{all_areas});
+
my $body = JSON->new->utf8(1)->encode(
{
councils_text => $councils_text,
category => $category,
extra_name_info => $extra_name_info,
+ titles_list => $extra_titles_list,
categories => $c->stash->{category_options},
}
);
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index 3c7580eb1..f648225ae 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -97,6 +97,9 @@ sub tweak_all_reports_map {
}
}
+sub title_list {
+ return ["MR", "MISS", "MRS", "MS", "DR"];
+}
1;
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index a745088a6..38efb7a35 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -691,6 +691,14 @@ sub example_places {
return $e;
}
+=head2 title_list
+
+Returns an arrayref of possible titles for a person to send to the mobile app.
+
+=cut
+
+sub title_list { return undef; }
+
=head2 only_authed_can_create
If true, only users with the from_body flag set are able to create reports.
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index 04c137674..aa2be4a0f 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -1,6 +1,8 @@
package FixMyStreet::Cobrand::FixMyStreet;
use base 'FixMyStreet::Cobrand::UK';
+use constant COUNCIL_ID_BROMLEY => 2482;
+
# FixMyStreet should return all cobrands
sub restriction {
return {};
@@ -10,5 +12,14 @@ sub admin_base_url {
return 'https://secure.mysociety.org/admin/bci/';
}
+sub title_list {
+ my $self = shift;
+ my $areas = shift;
+ my $first_area = ( values %$areas )[0];
+
+ return ["MR", "MISS", "MRS", "MS", "DR"] if $first_area->{id} eq COUNCIL_ID_BROMLEY;
+ return undef;
+}
+
1;
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 818f9e625..8e129a41c 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -921,8 +921,13 @@ subtest "test report creation for a category that is non public" => sub {
$contact2->category( "Pothol\xc3\xa9s" );
$contact2->update;
-$mech->get_ok( '/report/new/ajax?latitude=' . $saved_lat . '&longitude=' . $saved_lon );
+
+my $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=' . $saved_lat . '&longitude=' . $saved_lon );
$mech->content_contains( "Pothol\xc3\xa9s" );
+ok !$extra_details->{titles_list}, 'Non Bromley does not send back list of titles';
+
+$extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=51.4021&longitude=0.01578');
+ok $extra_details->{titles_list}, 'Bromley sends back list of titles';
#### test uploading an image