diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 46 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 5 | ||||
-rw-r--r-- | templates/web/zurich/admin/report_edit-sdm.html | 6 | ||||
-rw-r--r-- | templates/web/zurich/admin/reports/edit.html | 4 |
4 files changed, 48 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 695d10439..f3cfe8801 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -552,6 +552,18 @@ sub category_options { $c->stash->{category_options} = \@categories; } +sub report_remove_internal_flag { + my $self = shift; + my $c = $self->{c}; + my $problem = $c->stash->{problem}; + $c->forward('/auth/check_csrf_token'); + $problem->non_public(0); + $problem->update; + $c->forward('/admin/log_edit', [ $problem->id, 'problem', 'Intern Flag entfernt' ]); + # Make sure the problem's time_spent is updated + $self->update_admin_log($c, $problem); +} + sub admin_report_edit { my $self = shift; my $c = $self->{c}; @@ -631,6 +643,10 @@ sub admin_report_edit { } } + if ( ($type eq 'super' || $type eq 'dm') && $c->get_param('stop_internal') ) { + $self->report_remove_internal_flag; + return $self->admin_report_edit_done; + } # Problem updates upon submission if ( ($type eq 'super' || $type eq 'dm') && $c->get_param('submit') ) { @@ -871,12 +887,7 @@ sub admin_report_edit { $c->go('index'); } - $c->stash->{updates} = [ $c->model('DB::Comment') - ->search( { problem_id => $problem->id }, { order_by => 'created' } ) - ->all ]; - - $self->stash_states($problem); - return 1; + return $self->admin_report_edit_done; } if ($type eq 'sdm') { @@ -913,6 +924,8 @@ sub admin_report_edit { # Make sure the problem's time_spent is updated $self->update_admin_log($c, $problem); $c->res->redirect( '/admin/summary' ); + } elsif ($editable && $c->get_param('stop_internal')) { + $self->report_remove_internal_flag; } elsif ($editable && $c->get_param('submit')) { $c->forward('/auth/check_csrf_token'); @@ -953,13 +966,7 @@ sub admin_report_edit { } } - $c->stash->{updates} = [ $c->model('DB::Comment') - ->search( { problem_id => $problem->id }, { order_by => 'created' } ) - ->all ]; - - $self->stash_states($problem); - return 1; - + return $self->admin_report_edit_done; } $self->stash_states($problem); @@ -967,6 +974,19 @@ sub admin_report_edit { } +sub admin_report_edit_done { + my $self = shift; + my $c = $self->{c}; + my $problem = $c->stash->{problem}; + $c->stash->{updates} = [ $c->model('DB::Comment') + ->search( { problem_id => $problem->id }, { order_by => 'created' } ) + ->all ]; + + $self->stash_states($problem); + return 1; +} + + sub admin_district_lookup { my ($self, $row) = @_; FixMyStreet::Geocode::Zurich::admin_district($row->local_coords); diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index fb2c08550..cab7a3fef 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -800,7 +800,12 @@ subtest 'test no email sent if closed' => sub { $internal->discard_changes; is $internal->state, 'fixed - council'; $mech->email_count_is(0); +}; +subtest 'remove internal flag' => sub { + $mech->submit_form_ok( { form_number => 2, button => 'stop_internal' } ); + $internal->discard_changes; + is $internal->non_public, 0; $internal->delete; $mech->log_out_ok; }; diff --git a/templates/web/zurich/admin/report_edit-sdm.html b/templates/web/zurich/admin/report_edit-sdm.html index b468bc7a0..9d4afef20 100644 --- a/templates/web/zurich/admin/report_edit-sdm.html +++ b/templates/web/zurich/admin/report_edit-sdm.html @@ -85,6 +85,12 @@ <div class="admin-report-edit admin-report-edit--interact"> +[% IF problem.non_public %] +<p align="right" class="screen-only"> + <input [% sdm_disabled %] type="submit" class="btn" name="stop_internal" value="Keine interne Meldung"> +</p> +[% END %] + <p align="right" class="screen-only"><input [% sdm_disabled %] type="submit" class="btn" name="send_back" value="[% loc('Not for my subdivision') %]"></p> [% status_message | safe %] diff --git a/templates/web/zurich/admin/reports/edit.html b/templates/web/zurich/admin/reports/edit.html index 147022981..c88c63307 100644 --- a/templates/web/zurich/admin/reports/edit.html +++ b/templates/web/zurich/admin/reports/edit.html @@ -119,6 +119,10 @@ [% status_message | safe %] +[% IF problem.non_public %] +<p align="right" class="screen-only"><input type="submit" class="btn" name="stop_internal" value="Keine interne Meldung"></p> +[% END %] + <dl [% IF status_message %]class="with-message"[% END %]> <dt class="screen-only"> |