aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm10
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm58
2 files changed, 48 insertions, 20 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 5ebeffc11..677aa66d7 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -683,7 +683,15 @@ sub report_edit : Path('report_edit') : Args(1) {
if (my $rotate_photo_param = $self->_get_rotate_photo_param($c)) {
$self->rotate_photo($c, @$rotate_photo_param);
- return 1;
+ if ( $c->cobrand->moniker eq 'zurich' ) {
+ # Clicking the photo rotation buttons should do nothing
+ # except for rotating the photo, so return the user
+ # to the report screen now.
+ $c->res->redirect( $c->uri_for( 'report_edit', $problem->id ) );
+ return;
+ } else {
+ return 1;
+ }
}
if ( $c->cobrand->moniker eq 'zurich' ) {
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 1a9963a60..0e75d71b9 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -123,6 +123,26 @@ sub problem_is_closed {
return exists $self->zurich_closed_states->{ $problem->state } ? 1 : 0;
}
+sub zurich_public_response_states {
+ my $states = {
+ 'fixed - council' => 1,
+ 'closed' => 1, # extern
+ 'unable to fix' => 1, # jurisdiction unknown
+
+ # e.g. as above, but WITHOUT the following (as they are hidden)
+ # 'hidden' => 1,
+ # 'investigating' => 1, # wish
+ # 'partial' => 1, # not contactable
+ };
+
+ return wantarray ? keys %{ $states } : $states;
+}
+
+sub problem_has_public_response {
+ my ($self, $problem) = @_;
+ return exists $self->zurich_public_response_states->{ $problem->state } ? 1 : 0;
+}
+
sub problem_as_hashref {
my $self = shift;
my $problem = shift;
@@ -570,13 +590,8 @@ sub admin_report_edit {
my $state = $c->get_param('state') || '';
my $oldstate = $problem->state;
- my %closure_states = (
- 'closed' => 1,
- 'investigating' => 1,
- 'hidden' => 1,
- 'partial' => 1,
- 'unable to fix' => 1,
- );
+ my $closure_states = $self->zurich_closed_states;
+ delete $closure_states->{'fixed - council'}; # may not be needed?
my $old_closure_state = $problem->get_extra_metadata('closure_status');
@@ -595,7 +610,7 @@ sub admin_report_edit {
$internal_note_text = "Weitergeleitet von $old_cat an $new_cat";
$self->update_admin_log($c, $problem, "Changed category from $old_cat to $new_cat");
$redirect = 1 if $cat->body_id ne $body->id;
- } elsif ( $closure_states{$state} and
+ } elsif ( $closure_states->{$state} and
( $oldstate ne 'planned' )
|| (($old_closure_state ||'') ne $state))
{
@@ -610,7 +625,7 @@ sub admin_report_edit {
$problem->set_extra_metadata( closure_status => $state );
$self->set_problem_state($c, $problem, 'planned');
$state = 'planned';
- $redirect = 1;
+ $problem->set_extra_metadata_if_undefined( moderated_overdue => $self->overdue( $problem ) );
} elsif ( my $subdiv = $c->get_param('body_subdivision') ) {
$problem->set_extra_metadata_if_undefined( moderated_overdue => $self->overdue( $problem ) );
@@ -628,12 +643,8 @@ sub admin_report_edit {
}
$self->set_problem_state($c, $problem, $state)
- unless $closure_states{$state}; # in closure-states case, we'll defer to clause below
-
- if ($self->problem_is_closed($problem)) {
- $problem->set_extra_metadata_if_undefined( closed_overdue => $self->overdue( $problem ) );
- $c->stash->{problem_is_closed} = 1;
- }
+ unless $closure_states->{$state};
+ # we'll defer to 'planned' clause below to change the state
}
}
@@ -641,15 +652,17 @@ sub admin_report_edit {
# Rueckmeldung ausstehend
# override $state from the metadata set above
$state = $problem->get_extra_metadata('closure_status') || '';
- my $closed = 0;
+ my ($moderated, $closed) = (0, 0);
if ($state eq 'hidden' && $c->req->params->{publish_response} ) {
_admin_send_email( $c, 'problem-rejected.txt', $problem );
- $problem->set_extra_metadata_if_undefined( moderated_overdue => $self->overdue( $problem ) );
+
$self->set_problem_state($c, $problem, $state);
+ $moderated++;
$closed++;
}
elsif ($state =~/^(closed|investigating)$/) { # Extern | Wish
+ $moderated++;
# Nested if instead of `and` because in these cases, we *don't*
# want to close unless we have body_external (so we don't want
# the final elsif clause below to kick in on publish_response)
@@ -659,7 +672,6 @@ sub admin_report_edit {
$problem->external_body( $external );
}
if ($problem->external_body && $c->req->params->{publish_response}) {
- $problem->set_extra_metadata_if_undefined( moderated_overdue => $self->overdue( $problem ) );
$problem->whensent( undef );
$self->set_problem_state($c, $problem, $state);
my $template = ($state eq 'investigating') ? 'problem-wish.txt' : 'problem-external.txt';
@@ -671,14 +683,20 @@ sub admin_report_edit {
}
elsif ($c->req->params->{publish_response}) {
# otherwise we only set the state if publish_response is set
+ #
# if $state wasn't set, then we are simply closing the message as fixed
$state ||= 'fixed - council';
_admin_send_email( $c, 'problem-closed.txt', $problem );
$redirect = 1;
+ $moderated++;
$closed++;
}
+ if ($moderated) {
+ $problem->set_extra_metadata_if_undefined( moderated_overdue => $self->overdue( $problem ) );
+ }
+
if ($closed) {
# set to either the closure_status from metadata or 'fixed - council' as above
$self->set_problem_state($c, $problem, $state);
@@ -757,7 +775,9 @@ sub admin_report_edit {
# (this will only happen if no other update_admin_log has already been called)
$self->update_admin_log($c, $problem);
- if ( $redirect ) {
+ if ( $redirect and $type eq 'dm' ) {
+ # only redirect for DM
+ $c->stash->{status_message} ||= '<p><em>' . _('Updated!') . '</em></p>';
$c->go('index');
}