aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-01-10 18:29:23 +0000
committerMatthew Somerville <matthew@mysociety.org>2013-01-10 18:29:23 +0000
commit7c1df92482fd5e69d885aaf8daf8f83c7692e26e (patch)
tree8387a5ab4a8c197be22d227c2efe620dd57d6c73 /perllib
parent7996a7c5ac4d909ef1f73d39aa20f78d09a988dc (diff)
Workflow simplifications for Zurich.
Allow DM/supers to assign new reports more obviously, by changing the one thing they need to (category for different DM, one of two body dropdowns for subdivisions or external body).
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm9
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm89
2 files changed, 67 insertions, 31 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index e453a9565..2551de071 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -721,15 +721,6 @@ sub report_edit : Path('report_edit') : Args(1) {
# do this here otherwise lastupdate and confirmed times
# do not display correctly
$problem->discard_changes;
-
- if ( $c->cobrand->moniker eq 'zurich' && $c->req->param('body') ) {
- my $problem_body = $c->req->param('body');
- my $admin_body = $c->stash->{body};
- if ($admin_body->id ne $problem_body) {
- $c->detach('index');
- }
- }
-
}
}
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 9e9d8542a..aa5a3a8c2 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -121,6 +121,33 @@ sub admin_report_edit {
unless $allowed_bodies{$problem->bodies_str};
}
+ if ($type eq 'super') {
+
+ my @bodies = $c->model('DB::Body')->all();
+ @bodies = sort { strcoll($a->name, $b->name) } @bodies;
+ $c->stash->{bodies} = \@bodies;
+
+ # Can change category to any other
+ my @categories = $c->model('DB::Contact')->not_deleted->all;
+ $c->stash->{categories} = [ map { $_->category } @categories ];
+
+ } elsif ($type eq 'dm') {
+
+ # Can assign to:
+ my @bodies = $c->model('DB::Body')->search( [
+ { 'me.parent' => $body->parent->id }, # Other DMs on the same level
+ { 'me.parent' => $body->id }, # Their subdivisions
+ { 'me.parent' => undef, 'bodies.id' => undef }, # External bodies
+ ], { join => 'bodies', distinct => 1 } );
+ @bodies = sort { strcoll($a->name, $b->name) } @bodies;
+ $c->stash->{bodies} = \@bodies;
+
+ # Can change category to any other
+ my @categories = $c->model('DB::Contact')->not_deleted->all;
+ $c->stash->{categories} = [ map { $_->category } @categories ];
+
+ }
+
# Problem updates upon submission
if ( ($type eq 'super' || $type eq 'dm') && $c->req->param('submit') ) {
$c->forward('check_token');
@@ -128,34 +155,55 @@ sub admin_report_edit {
# Predefine the hash so it's there for lookups
# XXX Note you need to shallow copy each time you set it, due to a bug? in FilterColumn.
my $extra = $problem->extra || {};
-
$extra->{internal_notes} = $c->req->param('internal_notes');
$extra->{publish_photo} = $c->req->params->{publish_photo} || 0;
$extra->{third_personal} = $c->req->params->{third_personal} || 0;
$problem->extra( { %$extra } );
+ # Workflow things
+ my $redirect = 0;
+ my $new_cat = $c->req->params->{category};
+ if ( $new_cat && $new_cat ne $problem->category ) {
+ my $cat = $c->model('DB::Contact')->search( { category => $c->req->params->{category} } )->first;
+ $problem->category( $new_cat );
+ $problem->bodies_str( $cat->body_id );
+ $problem->whensent( undef );
+ $redirect = 1 if $cat->body_id ne $body->id;
+ } elsif ( my $subdiv = $c->req->params->{body_subdivision} ) {
+ $problem->state( 'in progress' );
+ $problem->bodies_str( $subdiv );
+ $problem->whensent( undef );
+ $redirect = 1;
+ } elsif ( my $external = $c->req->params->{body_external} ) {
+ $problem->state( 'closed' );
+ $problem->bodies_str( $external );
+ $problem->whensent( undef );
+ $redirect = 1;
+ } else {
+ $problem->state( $c->req->params->{state} ) if $c->req->params->{state};
+ }
+
+ $problem->title( $c->req->param('title') );
+ $problem->detail( $c->req->param('detail') );
+
$problem->lastupdate( \'ms_current_timestamp()' );
$problem->update;
- }
- if ($type eq 'super') {
+ $c->stash->{status_message} =
+ '<p><em>' . _('Updated!') . '</em></p>';
- my @bodies = $c->model('DB::Body')->all();
- @bodies = sort { strcoll($a->name, $b->name) } @bodies;
- $c->stash->{bodies} = \@bodies;
+ # do this here otherwise lastupdate and confirmed times
+ # do not display correctly
+ $problem->discard_changes;
- } elsif ($type eq 'dm') {
+ if ( $redirect ) {
+ $c->detach('index');
+ }
- # Can assign to:
- my @bodies = $c->model('DB::Body')->search( [
- { 'me.parent' => $body->parent->id }, # Other DMs on the same level
- { 'me.parent' => $body->id }, # Their subdivisions
- { 'me.parent' => undef, 'bodies.id' => undef }, # External bodies
- ], { join => 'bodies', distinct => 1 } );
- @bodies = sort { strcoll($a->name, $b->name) } @bodies;
- $c->stash->{bodies} = \@bodies;
+ return 1;
+ }
- } elsif ($type eq 'sdm') {
+ if ($type eq 'sdm') {
# Has cut-down edit template for adding update and sending back up only
$c->stash->{template} = 'admin/report_edit-sdm.html';
@@ -167,9 +215,7 @@ sub admin_report_edit {
$problem->state( 'confirmed' );
$problem->update;
# log here
-
$c->res->redirect( '/admin/summary' );
- return 1;
} elsif ($c->req->param('no_more_updates')) {
$c->forward('check_token');
@@ -178,9 +224,7 @@ sub admin_report_edit {
$problem->state( 'planned' );
$problem->update;
# log here
-
$c->res->redirect( '/admin/summary' );
- return 1;
} elsif ($c->req->param('submit')) {
$c->forward('check_token');
@@ -207,13 +251,14 @@ sub admin_report_edit {
}
$c->stash->{status_message} = '<p><em>' . _('Updated!') . '</em></p>';
-
$c->stash->{updates} = [ $c->model('DB::Comment')
->search( { problem_id => $problem->id }, { order_by => 'created' } )
->all ];
- return 1;
}
+
+ return 1;
+
}
return 0;