diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 31 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 151 |
2 files changed, 131 insertions, 51 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 8ed135e6d..0a2a8830c 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -312,7 +312,7 @@ sub update_contacts : Private { my ( $self, $c ) = @_; my $posted = $c->req->param('posted'); - my $editor = $c->req->remote_user || _('*unknown*'); + my $editor = $c->req->remote_user || ($c->user && $c->user->name) || _('*unknown*'); if ( $posted eq 'new' ) { $c->forward('check_token'); @@ -661,11 +661,6 @@ sub report_edit : Path('report_edit') : Args(1) { my $flagged = $c->req->param('flagged') ? 1 : 0; my $non_public = $c->req->param('non_public') ? 1 : 0; - # 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} ||= ''; - # do this here so before we update the values in problem if ( $c->req->param('anonymous') ne $problem->anonymous || $c->req->param('name') ne $problem->name @@ -673,8 +668,6 @@ sub report_edit : Path('report_edit') : Args(1) { || $c->req->param('title') ne $problem->title || $c->req->param('detail') ne $problem->detail || ($c->req->param('body') && $c->req->param('body') ne $problem->bodies_str) - || ($c->req->param('internal_notes') && $c->req->param('internal_notes') ne $extra->{internal_notes}) - || ($c->cobrand->moniker eq 'zurich' && $c->req->param('publish_photo') ne $extra->{publish_photo}) || $flagged != $problem->flagged || $non_public != $problem->non_public ) { @@ -687,19 +680,6 @@ sub report_edit : Path('report_edit') : Args(1) { $problem->state( $new_state ); $problem->name( $c->req->param('name') ); $problem->bodies_str( $c->req->param('body') ) if $c->req->param('body'); - if ($c->req->param('internal_notes')) { - $extra->{internal_notes} = $c->req->param('internal_notes'); - $problem->extra( { %$extra } ); - } - - # Zurich have photos being published or not, and third parties getting - # personal data; can't just check as with e.g. internal_notes as it's a - # checkbox and won't be set if it's not ticked - if ($c->cobrand->moniker eq 'zurich') { - $extra->{publish_photo} = $c->req->params->{publish_photo} || 0; - $extra->{third_personal} = $c->req->params->{third_personal} || 0; - $problem->extra( { %$extra } ); - } $problem->flagged( $flagged ); $problem->non_public( $non_public ); @@ -741,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 455e2bbbb..d70e785d7 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -39,6 +39,34 @@ sub show_unconfirmed_reports { } # Specific administrative displays + +sub admin_pages { + my $self = shift; + my $c = $self->{c}; + + my $type = $c->stash->{admin_type}; + my $pages = { + 'summary' => [_('Summary'), 0], + 'reports' => [_('Reports'), 2], + 'report_edit' => [undef, undef], + 'update_edit' => [undef, undef], + }; + return $pages if $type eq 'sdm'; + + $pages = { %$pages, + 'bodies' => [_('Bodies'), 1], + 'body' => [undef, undef], + 'body_edit' => [undef, undef], + }; + return $pages if $type eq 'dm'; + + $pages = { %$pages, + 'users' => [_('Users'), 3], + 'user_edit' => [undef, undef], + }; + return $pages if $type eq 'super'; +} + sub admin_type { my $self = shift; my $c = $self->{c}; @@ -75,7 +103,7 @@ sub admin { # XXX No multiples or missing bodies $c->stash->{unconfirmed} = $c->cobrand->problems->search({ - state => 'unconfirmed', + state => [ 'unconfirmed', 'confirmed' ], bodies_str => $c->stash->{body}->id, }); $c->stash->{approval} = $c->cobrand->problems->search({ @@ -83,7 +111,7 @@ sub admin { bodies_str => $c->stash->{body}->id, }); $c->stash->{other} = $c->cobrand->problems->search({ - state => { -not_in => [ 'unconfirmed', 'planned' ] }, + state => { -not_in => [ 'unconfirmed', 'confirmed', 'planned' ] }, bodies_str => \@all, }); } elsif ($type eq 'sdm') { @@ -127,6 +155,10 @@ sub admin_report_edit { @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: @@ -138,7 +170,87 @@ sub admin_report_edit { @bodies = sort { strcoll($a->name, $b->name) } @bodies; $c->stash->{bodies} = \@bodies; - } elsif ($type eq 'sdm') { + # 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'); + + # 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') ); + + # Final, public, Update from DM + if (my $update = $c->req->param('status_update')) { + FixMyStreet::App->model('DB::Comment')->create( { + text => $update, + user => $c->user->obj, + state => 'confirmed', + confirmed => \'ms_current_timestamp()', + problem => $problem, + mark_fixed => 0, + problem_state => 'fixed - council', + anonymous => 1, + } ); + $problem->state( 'fixed - council' ); + } + + $problem->lastupdate( \'ms_current_timestamp()' ); + $problem->update; + + $c->stash->{status_message} = + '<p><em>' . _('Updated!') . '</em></p>'; + + # do this here otherwise lastupdate and confirmed times + # do not display correctly + $problem->discard_changes; + + if ( $redirect ) { + $c->detach('index'); + } + + $c->stash->{updates} = [ $c->model('DB::Comment') + ->search( { problem_id => $problem->id }, { order_by => 'created' } ) + ->all ]; + + return 1; + } + + 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'; @@ -150,20 +262,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'); - - $problem->bodies_str( $body->parent->id ); - $problem->state( 'planned' ); - $problem->update; - # log here - - $c->res->redirect( '/admin/summary' ); - return 1; } elsif ($c->req->param('submit')) { $c->forward('check_token'); @@ -191,12 +290,22 @@ 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; + # If they clicked the no more updates button, we're done. + if ($c->req->param('no_more_updates')) { + $problem->bodies_str( $body->parent->id ); + $problem->state( 'planned' ); + $problem->update; + # log here + $c->res->redirect( '/admin/summary' ); + } } + + $c->stash->{updates} = [ $c->model('DB::Comment') + ->search( { problem_id => $problem->id }, { order_by => 'created' } ) + ->all ]; + + return 1; + } return 0; |