aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm20
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm7
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm8
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm5
5 files changed, 38 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 253840082..c12fdf9b9 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -340,6 +340,7 @@ sub update_contacts : Private {
}
$c->forward('update_extra_fields', [ $contact ]);
+ $c->forward('contact_cobrand_extra_fields', [ $contact ]);
if ( %errors ) {
$c->stash->{updated} = _('Please correct the errors below');
@@ -444,6 +445,8 @@ sub body_params : Private {
my %defaults = map { $_ => '' } @fields;
%defaults = ( %defaults,
send_comments => 0,
+ fetch_problems => 0,
+ blank_updates_permitted => 0,
suppress_alerts => 0,
comment_user_id => undef,
send_extended_statuses => 0,
@@ -1008,11 +1011,18 @@ sub report_edit_location : Private {
my ($lat, $lon) = map { Utils::truncate_coordinate($_) } $problem->latitude, $problem->longitude;
if ( $c->stash->{latitude} != $lat || $c->stash->{longitude} != $lon ) {
+ # The two actions below change the stash, setting things up for e.g. a
+ # new report. But here we're only doing it in order to check the found
+ # bodies match; we don't want to overwrite the existing report data if
+ # this lookup is bad. So let's save the stash and restore it after the
+ # comparison.
+ my $safe_stash = { %{$c->stash} };
$c->forward('/council/load_and_check_areas', []);
$c->forward('/report/new/setup_categories_and_bodies');
my %allowed_bodies = map { $_ => 1 } @{$problem->bodies_str_ids};
my @new_bodies = @{$c->stash->{bodies_to_list}};
my $bodies_match = grep { exists( $allowed_bodies{$_} ) } @new_bodies;
+ $c->stash($safe_stash);
return unless $bodies_match;
$problem->latitude($c->stash->{latitude});
$problem->longitude($c->stash->{longitude});
@@ -1035,7 +1045,6 @@ sub categories_for_point : Private {
# Remove the "Pick a category" option
shift @{$c->stash->{category_options}} if @{$c->stash->{category_options}};
- $c->stash->{category_options_copy} = $c->stash->{category_options};
$c->stash->{categories_hash} = { map { $_->{name} => 1 } @{$c->stash->{category_options}} };
}
@@ -1610,6 +1619,15 @@ sub user_edit : Path('user_edit') : Args(1) {
return 1;
}
+sub contact_cobrand_extra_fields : Private {
+ my ( $self, $c, $contact ) = @_;
+
+ my $extra_fields = $c->cobrand->call_hook('contact_extra_fields');
+ foreach ( @$extra_fields ) {
+ $contact->set_extra_metadata( $_ => $c->get_param("extra[$_]") );
+ }
+}
+
sub user_cobrand_extra_fields : Private {
my ( $self, $c ) = @_;
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index 661579f95..7cdf150aa 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -345,6 +345,8 @@ Generates a CSV output, given a 'csv' stash hashref containing:
* columns: an arrayref of the columns (looked up in the row's as_hashref, plus
the following: user_name_display, acknowledged, fixed, closed, wards,
local_coords_x, local_coords_y, url).
+* extra_data: If present, a function that is passed the report and returns a
+hashref of extra data to include that can be used by 'columns'.
=cut
@@ -398,6 +400,11 @@ sub generate_csv : Private {
$report->local_coords;
$hashref->{url} = join '', $c->cobrand->base_url_for_report($report), $report->url;
+ if (my $fn = $c->stash->{csv}->{extra_data}) {
+ my $extra = $fn->($report);
+ $hashref = { %$hashref, %$extra };
+ }
+
$csv->combine(
@{$hashref}{
@{$c->stash->{csv}->{columns}}
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index ddc976f2d..b50728b77 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -308,6 +308,7 @@ sub get_requests : Private {
# Only provide access to the published reports
my $states = FixMyStreet::DB::Result::Problem->visible_states();
delete $states->{unconfirmed};
+ delete $states->{submitted};
my $criteria = {
state => [ keys %$states ]
};
@@ -410,6 +411,7 @@ sub get_request : Private {
my $states = FixMyStreet::DB::Result::Problem->visible_states();
delete $states->{unconfirmed};
+ delete $states->{submitted};
my $criteria = {
state => [ keys %$states ],
id => $id,
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 7062f481f..df4dc5f77 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -221,9 +221,15 @@ sub format_problem_for_display : Private {
if ( $c->stash->{ajax} ) {
$c->res->content_type('application/json; charset=utf-8');
+
+ # encode_json doesn't like DateTime objects, so strip them out
+ my $report_hashref = $c->cobrand->problem_as_hashref( $problem, $c );
+ delete $report_hashref->{created};
+ delete $report_hashref->{confirmed};
+
my $content = encode_json(
{
- report => $c->cobrand->problem_as_hashref( $problem, $c ),
+ report => $report_hashref,
updates => $c->cobrand->updates_as_hashref( $problem, $c ),
}
);
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 888110429..e4e82f091 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -967,6 +967,7 @@ sub process_report : Private {
# set defaults that make sense
$report->state('unconfirmed');
+ $report->state('submitted') if $c->cobrand->moniker eq 'zurich';
# save the cobrand and language related information
$report->cobrand( $c->cobrand->moniker );
@@ -1002,7 +1003,7 @@ sub set_report_extras : Private {
foreach my $contact (@$contacts) {
my $metas = $contact->get_metadata_for_input;
foreach my $field ( @$metas ) {
- if ( lc( $field->{required} ) eq 'true' && !$c->cobrand->category_extra_hidden($field->{code})) {
+ if ( lc( $field->{required} ) eq 'true' && !$c->cobrand->category_extra_hidden($field)) {
unless ( $c->get_param($param_prefix . $field->{code}) ) {
$c->stash->{field_errors}->{ $field->{code} } = _('This information is required');
}
@@ -1019,7 +1020,7 @@ sub set_report_extras : Private {
my $metas = $extra_fields->get_extra_fields;
$param_prefix = "extra[" . $extra_fields->id . "]";
foreach my $field ( @$metas ) {
- if ( lc( $field->{required} ) eq 'true' && !$c->cobrand->category_extra_hidden($field->{code})) {
+ if ( lc( $field->{required} ) eq 'true' && !$c->cobrand->category_extra_hidden($field)) {
unless ( $c->get_param($param_prefix . $field->{code}) ) {
$c->stash->{field_errors}->{ $field->{code} } = _('This information is required');
}