aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2015-04-21 14:18:17 +0000
committerDave Arter <davea@mysociety.org>2015-10-06 09:09:25 +0100
commit91da8077bad2de594297c13c507cc5001c036531 (patch)
treefa50791ea9019bd4624876a56f2ade26fd9439e4 /perllib/FixMyStreet/Cobrand
parent3ef919ee67fc34c8b06dd85b035ba9d0ef85804c (diff)
[Zurich] Tweaks to redirect
See mysociety/FixMyStreet-Commercial#690 I understand redirection to summary page was introduced at ZWN's request, to make it easy to process reports and then quickly move onto the next one. However, during testing now, Tobias has mentioned this is a) slowing things down and b) confusing because it's not obvious that the report has been saved. I've tried to address (b) by adding the "Aktualisiert!" message when you are redirected. Also, for (a) I've removed the redirection from a few cases, and disabled it for superuser. If need be, I can remove redirection from more (or all) cases. Fix Official answer/Reply to user - hide label for status update on state change - correct wording on button for closure (single wording) - correct wording on label for user reply (either "Official answer" or "Reply to user" as appropriate) - Make sure the official response texts are shown for edit/static as appropriate, and test. - javascript improvements - honour public status update for Extern/Wunsch too - don't show public message for Wunsch - Ignore all other fields when rotating photos. (See mysociety/FixMyStreet-Commercial#718)
Diffstat (limited to 'perllib/FixMyStreet/Cobrand')
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm58
1 files changed, 39 insertions, 19 deletions
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');
}