aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-05-29 14:37:07 +0100
committerM Somerville <matthew-github@dracos.co.uk>2020-09-02 14:52:54 +0100
commit36401150f6ea0775f3c70a30ef871ffd6defa94b (patch)
treee6e341a19cc3bb12121789abc89d020acee6d81e
parent4f96bd558e0b915adef325f27ac5ccd65e9b310f (diff)
[Hounslow] Factor non-map report creation calls.
-rw-r--r--perllib/FixMyStreet/App/Controller/Contact/Enquiry.pm12
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm18
-rw-r--r--perllib/FixMyStreet/Cobrand/Hounslow.pm53
3 files changed, 40 insertions, 43 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact/Enquiry.pm b/perllib/FixMyStreet/App/Controller/Contact/Enquiry.pm
index 5b1c4980f..da5b9906e 100644
--- a/perllib/FixMyStreet/App/Controller/Contact/Enquiry.pm
+++ b/perllib/FixMyStreet/App/Controller/Contact/Enquiry.pm
@@ -49,15 +49,9 @@ sub submit : Path('submit') : Args(0) {
$c->set_param('pc', '');
$c->set_param('skipped', 1);
- $c->forward('/report/new/initialize_report');
- $c->forward('/report/new/check_for_category');
- $c->forward('/auth/check_csrf_token');
- $c->forward('/report/new/process_report');
- $c->forward('/report/new/process_user');
- $c->forward('handle_uploads');
- $c->forward('/photo/process_photo');
- $c->go('index', [ 1 ]) unless $c->forward('/report/new/check_for_errors');
- $c->forward('/report/new/save_user_and_report');
+ $c->forward('/report/new/non_map_creation', [ [ '/contact/enquiry/handle_uploads' ] ])
+ or $c->go('index', [ 1 ]);
+
$c->forward('confirm_report');
$c->stash->{success} = 1;
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index f5933d754..a00251171 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1785,6 +1785,24 @@ sub generate_category_extra_json : Private {
return \@fields;
}
+sub non_map_creation : Private {
+ my ($self, $c, $extras) = @_;
+
+ $c->forward('initialize_report');
+ $c->forward('check_for_category');
+ $c->forward('/auth/check_csrf_token');
+ $c->forward('process_report');
+ $c->forward('process_user');
+ if ($extras) {
+ $c->forward($_) for @$extras;
+ }
+ $c->forward('/photo/process_photo');
+ return 0 unless $c->forward('check_for_errors');
+ $c->forward('save_user_and_report');
+ return 1;
+
+}
+
__PACKAGE__->meta->make_immutable;
1;
diff --git a/perllib/FixMyStreet/Cobrand/Hounslow.pm b/perllib/FixMyStreet/Cobrand/Hounslow.pm
index 5ce22762f..90d3b17dc 100644
--- a/perllib/FixMyStreet/Cobrand/Hounslow.pm
+++ b/perllib/FixMyStreet/Cobrand/Hounslow.pm
@@ -126,40 +126,25 @@ sub open311_skip_report_fetch {
sub filter_report_description { "" }
sub setup_general_enquiries_stash {
- my $self = shift;
-
- my @bodies = $self->{c}->model('DB::Body')->active->for_areas(( $self->council_area_id ))->all;
- my %bodies = map { $_->id => $_ } @bodies;
- my @contacts #
- = $self->{c} #
- ->model('DB::Contact') #
- ->active
- ->search(
- {
- 'me.body_id' => [ keys %bodies ]
- },
- {
- prefetch => 'body',
- order_by => 'me.category',
- }
- )->all;
- @contacts = grep {
- my $groups = $_->groups;
- grep { $_ eq 'Other' || $_ eq 'General Enquiries' } @$groups;
- } @contacts;
- $self->{c}->stash->{bodies} = \%bodies;
- $self->{c}->stash->{bodies_to_list} = \%bodies;
- $self->{c}->stash->{contacts} = \@contacts;
- $self->{c}->stash->{missing_details_bodies} = [];
- $self->{c}->stash->{missing_details_body_names} = [];
-
- $self->{c}->set_param('title', "General Enquiry");
- # Can't use (0, 0) for lat lon so default to the rough location
- # of Hounslow Highways HQ.
- $self->{c}->stash->{latitude} = 51.469;
- $self->{c}->stash->{longitude} = -0.35;
-
- return 1;
+ my $self = shift;
+ my $c = $self->{c};
+
+ $c->set_param('title', "General Enquiry");
+ # Can't use (0, 0) for lat lon so default to the rough location
+ # of Hounslow Highways HQ.
+ $c->stash->{latitude} = 51.469;
+ $c->stash->{longitude} = -0.35;
+
+ $c->stash->{all_areas} = { $self->council_area_id => { id => $self->council_area_id } };
+ $c->forward('/report/new/setup_categories_and_bodies');
+
+ my $contacts = $c->stash->{contacts};
+ @$contacts = grep {
+ my $groups = $_->groups;
+ grep { $_ eq 'Other' || $_ eq 'General Enquiries' } @$groups;
+ } @$contacts;
+
+ return 1;
}
sub abuse_reports_only { 1 }