diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 197 | ||||
-rw-r--r-- | t/app/controller/admin.t | 83 | ||||
-rw-r--r-- | templates/web/default/admin/bodies.html | 44 | ||||
-rw-r--r-- | templates/web/default/admin/body.html (renamed from templates/web/default/admin/council_contacts.html) | 42 | ||||
-rw-r--r-- | templates/web/default/admin/body_edit.html (renamed from templates/web/default/admin/council_edit.html) | 36 | ||||
-rw-r--r-- | templates/web/default/admin/council_list.html | 47 | ||||
-rw-r--r-- | templates/web/default/admin/flagged.html (renamed from templates/web/default/admin/list_flagged.html) | 2 | ||||
-rw-r--r-- | templates/web/default/admin/problem_row.html | 4 | ||||
-rw-r--r-- | templates/web/default/admin/reports.html (renamed from templates/web/default/admin/search_reports.html) | 2 | ||||
-rw-r--r-- | templates/web/default/admin/stats.html | 6 | ||||
-rw-r--r-- | templates/web/default/admin/user_edit.html | 6 | ||||
-rw-r--r-- | templates/web/default/admin/users.html (renamed from templates/web/default/admin/search_users.html) | 4 |
12 files changed, 207 insertions, 266 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index d5bce9283..d64ca4862 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -204,7 +204,7 @@ sub questionnaire : Path('questionnaire') : Args(0) { return 1; } -sub council_list : Path('council_list') : Args(0) { +sub bodies : Path('bodies') : Args(0) { my ( $self, $c ) = @_; $c->forward('check_page_allowed'); @@ -221,14 +221,10 @@ sub council_list : Path('council_list') : Args(0) { $c->stash->{edit_activity} = $edit_activity; - # Not London, as treated separately - my $area_types = $c->cobrand->moniker eq 'emptyhomes' - ? $c->cobrand->area_types - : [ grep { $_ ne 'LBO' } @{ $c->cobrand->area_types } ]; - my $areas = mySociety::MaPit::call('areas', $area_types); + $c->forward( 'fetch_all_bodies' ); - my @councils_ids = sort { strcoll($areas->{$a}->{name}, $areas->{$b}->{name}) } keys %$areas; - @councils_ids = $c->cobrand->filter_all_council_ids_list( @councils_ids ); + # XXX For fixmystreet.com, need to exclude bodies that are covering London. + # But soon, this means just don't have bodies covering London. my $contacts = $c->model('DB::Contact')->search( undef, @@ -243,32 +239,21 @@ sub council_list : Path('council_list') : Args(0) { my %council_info = map { $_->{body_id} => $_ } $contacts->all; - my @no_info = grep { !$council_info{$_} } @councils_ids; - my @one_plus_deleted = grep { $council_info{$_} && $council_info{$_}->{deleted} } @councils_ids; - my @unconfirmeds = grep { $council_info{$_} && !$council_info{$_}->{deleted} && $council_info{$_}->{confirmed} != $council_info{$_}->{c} } @councils_ids; - my @all_confirmed = grep { $council_info{$_} && !$council_info{$_}->{deleted} && $council_info{$_}->{confirmed} == $council_info{$_}->{c} } @councils_ids; - - $c->stash->{areas} = $areas; $c->stash->{counts} = \%council_info; - $c->stash->{no_info} = \@no_info; - $c->stash->{one_plus_deleted} = \@one_plus_deleted; - $c->stash->{unconfirmeds} = \@unconfirmeds; - $c->stash->{all_confirmed} = \@all_confirmed; return 1; } -sub council_contacts : Path('council_contacts') : Args(1) { - my ( $self, $c, $area_id ) = @_; - - $c->forward('check_page_allowed'); +sub body : Path('body') : Args(1) { + my ( $self, $c, $body_id ) = @_; - my $posted = $c->req->param('posted') || ''; - $c->stash->{area_id} = $area_id; + $c->stash->{body_id} = $body_id; + $c->forward( 'check_page_allowed' ); $c->forward( 'get_token' ); + $c->forward( 'lookup_body' ); - if ( $posted ) { + if ( $c->req->param('posted') ) { $c->log->debug( 'posted' ); $c->forward('update_contacts'); } @@ -294,7 +279,7 @@ sub update_contacts : Private { my $contact = $c->model('DB::Contact')->find_or_new( { - body_id => $c->stash->{area_id}, + body_id => $c->stash->{body_id}, category => $category, } ); @@ -328,7 +313,7 @@ sub update_contacts : Private { my $contacts = $c->model('DB::Contact')->search( { - body_id => $c->stash->{area_id}, + body_id => $c->stash->{body_id}, category => { -in => \@categories }, } ); @@ -346,65 +331,34 @@ sub update_contacts : Private { } elsif ( $posted eq 'open311' ) { $c->forward('check_token'); - my %params = map { $_ => $c->req->param($_) || '' } qw/open311_id endpoint jurisdiction api_key area_id send_method send_comments suppress_alerts comment_user_id devolved/; - - if ( $params{open311_id} ) { - my $conf = $c->model('DB::Body')->find( { id => $params{open311_id} } ); + my %params = map { $_ => $c->req->param($_) || '' } qw/endpoint jurisdiction api_key send_method send_comments suppress_alerts comment_user_id devolved/; - $conf->endpoint( $params{endpoint} ); - $conf->jurisdiction( $params{jurisdiction} ); - $conf->api_key( $params{api_key} ); - $conf->send_method( $params{send_method} ); - $conf->send_comments( $params{send_comments} || 0); - $conf->suppress_alerts( $params{suppress_alerts} || 0); - $conf->comment_user_id( $params{comment_user_id} || undef ); - $conf->can_be_devolved( $params{devolved} || 0 ); + my $body = $c->stash->{body}; - $conf->update(); + $body->endpoint( $params{endpoint} ); + $body->jurisdiction( $params{jurisdiction} ); + $body->api_key( $params{api_key} ); + $body->send_method( $params{send_method} ); + $body->send_comments( $params{send_comments} || 0); + $body->suppress_alerts( $params{suppress_alerts} || 0); + $body->comment_user_id( $params{comment_user_id} || undef ); + $body->can_be_devolved( $params{devolved} || 0 ); - $c->stash->{updated} = _('Configuration updated'); - } else { - my $conf = $c->model('DB::Body')->find_or_new( { area_id => $params{area_id} } ); - - $conf->endpoint( $params{endpoint} ); - $conf->jurisdiction( $params{jurisdiction} ); - $conf->api_key( $params{api_key} ); - $conf->send_method( $params{send_method} ); - $conf->send_comments( $params{send_comments} || 0); - $conf->suppress_alerts( $params{suppress_alerts} || 0); - $conf->comment_user_id( $params{comment_user_id} || undef ); - $conf->can_be_devolved( $params{devolved} || 0 ); + $body->update(); - $conf->insert(); - - $c->stash->{updated} = _('Configuration updated - contacts will be generated automatically later'); - } + $c->stash->{updated} = _('Configuration updated - contacts will be generated automatically later'); } } sub display_contacts : Private { my ( $self, $c ) = @_; - $c->forward('setup_council_details'); - - my $area_id = $c->stash->{area_id}; - - my $contacts = $c->model('DB::Contact')->search( - { body_id => $area_id }, - { order_by => ['category'] } - ); - + my $contacts = $c->stash->{body}->contacts->search(undef, { order_by => [ 'category' ] } ); $c->stash->{contacts} = $contacts; my @methods = map { $_ =~ s/FixMyStreet::SendReport:://; $_ } keys %{ FixMyStreet::SendReport->get_senders }; $c->stash->{send_methods} = \@methods; - my $open311 = $c->model('DB::Body')->search( - { area_id => $area_id } - ); - - $c->stash->{open311} = $open311; - if ( $c->req->param('text') && $c->req->param('text') == 1 ) { $c->stash->{template} = 'admin/council_contacts.txt'; $c->res->content_type('text/plain; charset=utf-8'); @@ -414,17 +368,16 @@ sub display_contacts : Private { return 1; } -sub setup_council_details : Private { +sub lookup_body : Private { my ( $self, $c ) = @_; - my $area_id = $c->stash->{area_id}; - - my $mapit_data = mySociety::MaPit::call('area', $area_id); - - $c->stash->{council_name} = $mapit_data->{name}; - - my $example_postcode = mySociety::MaPit::call('area/example_postcode', $area_id); - + my $body_id = $c->stash->{body_id}; + my $body = $c->model('DB::Body')->find($body_id); + $c->detach( '/page_error_404_not_found' ) + unless $body; + $c->stash->{body} = $body; + + my $example_postcode = mySociety::MaPit::call('area/example_postcode', $body->area_id); if ($example_postcode && ! ref $example_postcode) { $c->stash->{example_pc} = $example_postcode; } @@ -432,41 +385,34 @@ sub setup_council_details : Private { return 1; } -sub council_edit_all : Path('council_edit') { - my ( $self, $c, $area_id, @category ) = @_; +# This is for if the category name contains a '/' +sub body_edit_all : Path('body_edit') { + my ( $self, $c, $body_id, @category ) = @_; my $category = join( '/', @category ); - $c->go( 'council_edit', [ $area_id, $category ] ); + $c->go( 'body_edit', [ $body_id, $category ] ); } -sub council_edit : Path('council_edit') : Args(2) { - my ( $self, $c, $area_id, $category ) = @_; - - $c->forward('check_page_allowed'); +sub body_edit : Path('body_edit') : Args(2) { + my ( $self, $c, $body_id, $category ) = @_; - $c->stash->{area_id} = $area_id; + $c->stash->{body_id} = $body_id; + $c->forward( 'check_page_allowed' ); $c->forward( 'get_token' ); - $c->forward('setup_council_details'); - - my $contact = $c->model('DB::Contact')->search( - { - body_id => $area_id, - category => $category - } - )->first; + $c->forward( 'lookup_body' ); + my $contact = $c->stash->{body}->contacts->search( { category => $category } )->first; $c->stash->{contact} = $contact; my $history = $c->model('DB::ContactsHistory')->search( { - body_id => $area_id, + body_id => $body_id, category => $category }, { order_by => ['contacts_history_id'] }, ); - $c->stash->{history} = $history; my @methods = map { $_ =~ s/FixMyStreet::SendReport:://; $_ } keys %{ FixMyStreet::SendReport->get_senders }; @@ -475,7 +421,7 @@ sub council_edit : Path('council_edit') : Args(2) { return 1; } -sub search_reports : Path('search_reports') { +sub reports : Path('reports') { my ( $self, $c ) = @_; $c->forward('check_page_allowed'); @@ -518,7 +464,7 @@ sub search_reports : Path('search_reports') { 'me.name' => { ilike => $like_search }, 'me.title' => { ilike => $like_search }, detail => { ilike => $like_search }, - council => { like => $like_search }, + bodies_str => { like => $like_search }, cobrand_data => { like => $like_search }, ]; } @@ -537,8 +483,8 @@ sub search_reports : Path('search_reports') { # will have been turned off $c->stash->{problems} = [ $problems->all ]; - $c->stash->{edit_council_contacts} = 1 - if ( grep {$_ eq 'councilcontacts'} keys %{$c->stash->{allowed_pages}}); + $c->stash->{edit_body_contacts} = 1 + if ( grep {$_ eq 'body'} keys %{$c->stash->{allowed_pages}}); if (is_valid_email($search)) { $query = [ @@ -716,7 +662,7 @@ sub report_edit : Path('report_edit') : Args(1) { return 1; } -sub search_users: Path('search_users') : Args(0) { +sub users: Path('users') : Args(0) { my ( $self, $c ) = @_; $c->forward('check_page_allowed'); @@ -872,7 +818,7 @@ sub user_edit : Path('user_edit') : Args(1) { my $user = $c->model('DB::User')->find( { id => $id } ); $c->stash->{user} = $user; - $c->forward('set_up_council_details'); + $c->forward('fetch_all_bodies'); if ( $c->req->param('submit') ) { $c->forward('check_token'); @@ -881,13 +827,13 @@ sub user_edit : Path('user_edit') : Args(1) { if ( $user->email ne $c->req->param('email') || $user->name ne $c->req->param('name' ) || - $user->from_body != $c->req->param('council') ) { + $user->from_body != $c->req->param('body') ) { $edited = 1; } $user->name( $c->req->param('name') ); $user->email( $c->req->param('email') ); - $user->from_body( $c->req->param('council') || undef ); + $user->from_body( $c->req->param('body') || undef ); $user->flagged( $c->req->param('flagged') || 0 ); $user->update; @@ -902,7 +848,7 @@ sub user_edit : Path('user_edit') : Args(1) { return 1; } -sub list_flagged : Path('list_flagged') : Args(0) { +sub flagged : Path('flagged') : Args(0) { my ( $self, $c ) = @_; $c->forward('check_page_allowed'); @@ -924,8 +870,7 @@ sub stats : Path('stats') : Args(0) { my ( $self, $c ) = @_; $c->forward('check_page_allowed'); - - $c->forward('set_up_council_details'); + $c->forward('fetch_all_bodies'); if ( $c->req->param('getcounts') ) { @@ -961,11 +906,11 @@ sub stats : Path('stats') : Args(0) { my $bymonth = $c->req->param('bymonth'); $c->stash->{bymonth} = $bymonth; - my ( %council, %dates ); - $council{council} = { like => $c->req->param('council') } - if $c->req->param('council'); + my ( %body, %dates ); + $body{bodies_str} = { like => $c->req->param('body') } + if $c->req->param('body'); - $c->stash->{selected_council} = $c->req->param('council'); + $c->stash->{selected_body} = $c->req->param('body'); my $field = 'confirmed'; @@ -1000,7 +945,7 @@ sub stats : Path('stats') : Args(0) { $field => { '>=', $start_date}, $field => { '<=', $end_date + $one_day }, ], - %council, + %body, %dates, }, \%select, @@ -1029,16 +974,16 @@ sub set_allowed_pages : Private { if( !$pages ) { $pages = { 'summary' => [_('Summary'), 0], - 'council_list' => [_('Bodies'), 1], - 'search_reports' => [_('Reports'), 2], + 'bodies' => [_('Bodies'), 1], + 'reports' => [_('Reports'), 2], 'timeline' => [_('Timeline'), 3], 'questionnaire' => [_('Survey'), 4], - 'search_users' => [_('Users'), 5], - 'list_flagged' => [_('Flagged'), 6], + 'users' => [_('Users'), 5], + 'flagged' => [_('Flagged'), 6], 'stats' => [_('Stats'), 6], 'user_edit' => [undef, undef], - 'council_contacts' => [undef, undef], - 'council_edit' => [undef, undef], + 'body' => [undef, undef], + 'body_edit' => [undef, undef], 'report_edit' => [undef, undef], 'update_edit' => [undef, undef], 'abuse_edit' => [undef, undef], @@ -1261,16 +1206,12 @@ sub check_page_allowed : Private { return 1; } -sub set_up_council_details : Private { +sub fetch_all_bodies : Private { my ($self, $c ) = @_; - my $areas = mySociety::MaPit::call('areas', $c->cobrand->area_types); - - my @councils_ids = sort { strcoll($areas->{$a}->{name}, $areas->{$b}->{name}) } keys %$areas; - @councils_ids = $c->cobrand->filter_all_council_ids_list( @councils_ids ); - - $c->stash->{council_ids} = \@councils_ids; - $c->stash->{council_details} = $areas; + my @bodies = $c->model('DB::Body')->all; + @bodies = sort { strcoll($a->name, $b->name) } @bodies; + $c->stash->{bodies} = \@bodies; return 1; } diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 9cea85861..a43a875c3 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -144,7 +144,9 @@ subtest 'check summary counts' => sub { }; my $host = FixMyStreet->config('BASE_URL'); -$mech->get_ok('/admin/council_contacts/2650'); + +my $body = $mech->create_body_ok(2650, 'Aberdeen City Council'); +$mech->get_ok('/admin/body/2650'); $mech->content_contains('Aberdeen City Council'); $mech->content_like(qr{AB\d\d}); $mech->content_contains("$host/around"); @@ -160,7 +162,7 @@ subtest 'check contact creation' => sub { ); $history->delete_all; - $mech->get_ok('/admin/council_contacts/2650'); + $mech->get_ok('/admin/body/2650'); $mech->submit_form_ok( { with_fields => { category => 'test category', @@ -190,12 +192,12 @@ subtest 'check contact creation' => sub { note => 'test/note', non_public => 'on', } } ); - $mech->get_ok('/admin/council_edit/2650/test/category'); + $mech->get_ok('/admin/body_edit/2650/test/category'); }; subtest 'check contact editing' => sub { - $mech->get_ok('/admin/council_edit/2650/test%20category'); + $mech->get_ok('/admin/body_edit/2650/test%20category'); $mech->submit_form_ok( { with_fields => { email => 'test2@example.com', @@ -216,31 +218,29 @@ subtest 'check contact editing' => sub { $mech->content_contains( '<td>Non Public' ); - $mech->get_ok('/admin/council_edit/2650/test%20category'); + $mech->get_ok('/admin/body_edit/2650/test%20category'); $mech->content_contains( '<td><strong>test2@example.com' ); }; subtest 'check contact updating' => sub { - $mech->get_ok('/admin/council_edit/2650/test%20category'); + $mech->get_ok('/admin/body_edit/2650/test%20category'); $mech->content_like(qr{test2\@example.com</strong>[^<]*</td>[^<]*<td>No}s); - $mech->get_ok('/admin/council_contacts/2650'); + $mech->get_ok('/admin/body/2650'); $mech->form_number( 1 ); $mech->tick( 'confirmed', 'test category' ); $mech->submit_form_ok({form_number => 1}); $mech->content_like(qr'test2@example.com</td>[^<]*<td>Yes's); - $mech->get_ok('/admin/council_edit/2650/test%20category'); + $mech->get_ok('/admin/body_edit/2650/test%20category'); $mech->content_like(qr{test2\@example.com[^<]*</td>[^<]*<td><strong>Yes}s); }; -my $open311 = - FixMyStreet::App->model('DB::Body')->search( { area_id => 2650 } ); -$open311->delete if $open311; +$body->update({ send_method => undef }); subtest 'check open311 configuring' => sub { - $mech->get_ok('/admin/council_contacts/2650/'); + $mech->get_ok('/admin/body/2650'); $mech->content_lacks('Council contacts configured via Open311'); $mech->form_number(3); @@ -258,7 +258,7 @@ subtest 'check open311 configuring' => sub { $mech->content_contains('Council contacts configured via Open311'); $mech->content_contains('Configuration updated - contacts will be generated automatically later'); - $open311 = + my $open311 = FixMyStreet::App->model('DB::Body')->search( { area_id => 2650 } ); is $open311->count, 1, 'only one configuration'; @@ -293,7 +293,7 @@ subtest 'check open311 configuring' => sub { }; subtest 'check text output' => sub { - $mech->get_ok('/admin/council_contacts/2650?text=1'); + $mech->get_ok('/admin/body/2650?text=1'); is $mech->content_type, 'text/plain'; $mech->content_contains('test category'); }; @@ -853,17 +853,17 @@ for my $test ( update_fixed => 0, update_reopen => 0, update_state => undef, - user_council => undef, + user_body => undef, content => 'user is problem owner', }, { - desc => 'user is council user', + desc => 'user is body user', problem_user => $user, update_user => $user2, update_fixed => 0, update_reopen => 0, update_state => undef, - user_council => 2504, + user_body => 2504, content => 'user is from same council as problem - 2504', }, { @@ -873,7 +873,7 @@ for my $test ( update_fixed => 0, update_reopen => 0, update_state => 'planned', - user_council => 2504, + user_body => 2504, content => 'Update changed problem state to planned', }, { @@ -883,7 +883,7 @@ for my $test ( update_fixed => 1, update_reopen => 0, update_state => undef, - user_council => undef, + user_body => undef, content => 'Update marked problem as fixed', }, { @@ -893,7 +893,7 @@ for my $test ( update_fixed => 0, update_reopen => 1, update_state => undef, - user_council => undef, + user_body => undef, content => 'Update reopened problem', }, ) { @@ -907,7 +907,7 @@ for my $test ( $update->mark_open( $test->{update_reopen} ); $update->update; - $test->{update_user}->from_body( $test->{user_council} ); + $test->{update_user}->from_body( $test->{user_body} ); $test->{update_user}->update; $mech->get_ok('/admin/update_edit/' . $update->id ); @@ -1033,14 +1033,14 @@ subtest 'report search' => sub { $update->user($report->user); $update->update; - $mech->get_ok('/admin/search_reports'); - $mech->get_ok('/admin/search_reports?search=' . $report->id ); + $mech->get_ok('/admin/reports'); + $mech->get_ok('/admin/reports?search=' . $report->id ); $mech->content_contains( $report->title ); my $r_id = $report->id; $mech->content_like( qr{href="http://[^/]*[^.]/report/$r_id/">$r_id</a>} ); - $mech->get_ok('/admin/search_reports?search=' . $report->user->email); + $mech->get_ok('/admin/reports?search=' . $report->user->email); my $u_id = $update->id; $mech->content_like( qr{href="http://[^/]*[^.]/report/$r_id/">$r_id</a>} ); @@ -1049,24 +1049,24 @@ subtest 'report search' => sub { $update->state('hidden'); $update->update; - $mech->get_ok('/admin/search_reports?search=' . $report->user->email); + $mech->get_ok('/admin/reports?search=' . $report->user->email); $mech->content_like( qr{<tr [^>]*hidden[^>]*> \s* <td> \s* $u_id \s* </td>}xs ); $report->state('hidden'); $report->update; - $mech->get_ok('/admin/search_reports?search=' . $report->user->email); + $mech->get_ok('/admin/reports?search=' . $report->user->email); $mech->content_like( qr{<tr [^>]*hidden[^>]*> \s* <td> \s* $r_id \s* </td>}xs ); $report->state('fixed - user'); $report->update; - $mech->get_ok('/admin/search_reports?search=' . $report->user->email); + $mech->get_ok('/admin/reports?search=' . $report->user->email); $mech->content_like( qr{href="http://[^/]*[^.]/report/$r_id/">$r_id</a>} ); }; subtest 'search abuse' => sub { - $mech->get_ok( '/admin/search_users?search=example' ); + $mech->get_ok( '/admin/users?search=example' ); $mech->content_like(qr/test4\@example.com.*\n.*\n.*Email in abuse table/); }; @@ -1077,26 +1077,26 @@ subtest 'show flagged entries' => sub { $user->flagged( 1 ); $user->update; - $mech->get_ok('/admin/list_flagged'); + $mech->get_ok('/admin/flagged'); $mech->content_contains( $report->title ); $mech->content_contains( $user->email ); }; subtest 'user search' => sub { - $mech->get_ok('/admin/search_users'); - $mech->get_ok('/admin/search_users?search=' . $user->name); + $mech->get_ok('/admin/users'); + $mech->get_ok('/admin/users?search=' . $user->name); $mech->content_contains( $user->name); my $u_id = $user->id; $mech->content_like( qr{user_edit/$u_id">Edit</a>} ); - $mech->get_ok('/admin/search_users?search=' . $user->email); + $mech->get_ok('/admin/users?search=' . $user->email); $mech->content_like( qr{user_edit/$u_id">Edit</a>} ); $user->from_body(2509); $user->update; - $mech->get_ok('/admin/search_users?search=2509' ); + $mech->get_ok('/admin/users?search=2509' ); $mech->content_contains(2509); }; @@ -1115,13 +1115,16 @@ is $log_entries->count, 0, 'no admin log entries'; $user->flagged( 0 ); $user->update; +$mech->create_body_ok(2509, 'Haringey Borough Council'); +$mech->create_body_ok(2607, 'Southend-on-Sea Borough Council'); + for my $test ( { desc => 'edit user name', fields => { name => 'Test User', email => 'test@example.com', - council => 2509, + body => 2509, flagged => undef, }, changes => { @@ -1135,7 +1138,7 @@ for my $test ( fields => { name => 'Changed User', email => 'test@example.com', - council => 2509, + body => 2509, flagged => undef, }, changes => { @@ -1145,15 +1148,15 @@ for my $test ( log_entries => [qw/edit edit/], }, { - desc => 'edit user council', + desc => 'edit user body', fields => { name => 'Changed User', email => 'changed@example.com', - council => 2509, + body => 2509, flagged => undef, }, changes => { - council => 2607, + body => 2607, }, log_count => 3, log_entries => [qw/edit edit edit/], @@ -1163,7 +1166,7 @@ for my $test ( fields => { name => 'Changed User', email => 'changed@example.com', - council => 2607, + body => 2607, flagged => undef, }, changes => { @@ -1177,7 +1180,7 @@ for my $test ( fields => { name => 'Changed User', email => 'changed@example.com', - council => 2607, + body => 2607, flagged => 'on', }, changes => { diff --git a/templates/web/default/admin/bodies.html b/templates/web/default/admin/bodies.html new file mode 100644 index 000000000..522bbf956 --- /dev/null +++ b/templates/web/default/admin/bodies.html @@ -0,0 +1,44 @@ +[% INCLUDE 'admin/header.html' title=loc('Council contacts') -%] + +<h2>[% loc('Diligency prize league table') %]</h2> +[% IF edit_activity.count %] +<ul> + [% WHILE ( editor = edit_activity.next ) %] + <li>[% tprintf( loc('%d edits by %s'), editor.get_column('c'), editor.editor ) %]</li> + [% END %] +</ul> +[% ELSE %] +<p> +[% loc('No edits have yet been made.') %] +</p> +[% END %] + +<h2>[% loc('Councils') %]</h2> + +[%- FOREACH body IN bodies %] + [%- SET id = body.id %] + [%- IF body.parent_area %] + [%- + p_area = areas.$body.parent_area + parent = ', ' _ areas.$parent.name + %] + [%- ELSE %] + [%- parent = '' %] + [%- END %] + [%- '<ul>' IF loop.first %] + <li><a href="[% c.uri_for( 'body', id ) %]">[% body.name %] [% parent %]</a> + – + [% IF counts.$id %] + [% tprintf( loc('%d addresses'), counts.$id.c) IF c.cobrand.moniker != 'emptyhomes' %] + [% IF counts.$id.deleted %] + (1+ deleted) + [% ELSIF counts.$id.confirmed != counts.$id.c %] + (some unconfirmed) + [% END %] + [% ELSE %] + no categories + [% END %] + [%- '</ul>' IF loop.last %] +[%- END %] + +[% INCLUDE 'admin/footer.html' %] diff --git a/templates/web/default/admin/council_contacts.html b/templates/web/default/admin/body.html index be855cb95..80cd32fef 100644 --- a/templates/web/default/admin/council_contacts.html +++ b/templates/web/default/admin/body.html @@ -1,6 +1,4 @@ -[% INCLUDE 'admin/header.html' title=tprintf(loc('Council contacts for %s'), council_name) -%] - -[% conf = open311.next %] +[% INCLUDE 'admin/header.html' title=tprintf(loc('Council contacts for %s'), body.name) -%] [% IF updated %] <p> @@ -13,14 +11,14 @@ <a href="[% c.uri_for_email( '/around', { pc => example_pc } ) %]">[% tprintf( loc('Example postcode %s'), example_pc ) | html %]</a> | [% END %] [% IF c.cobrand.moniker == 'emptyhomes' %] -<a href="[% c.uri_for( 'search_reports', search => 'area:' _ area_id ) %]">[% loc('List all reported problems' ) %]</a> +<a href="[% c.uri_for( 'reports', search => 'body:' _ body_id ) %]">[% loc('List all reported problems' ) %]</a> [% ELSE %] -<a href="[% c.uri_for_email( '/reports/' _ area_id ) %]">[% loc('List all reported problems' ) %]</a> +<a href="[% c.uri_for_email( '/reports/' _ body_id ) %]">[% loc('List all reported problems' ) %]</a> [% END %] -<a href="[% c.uri_for( 'council_contacts', area_id, { text => 1 } ) %]">[% loc('Text only version') %]</a> +<a href="[% c.uri_for( 'body', body_id, { text => 1 } ) %]">[% loc('Text only version') %]</a> </p> -[% IF open311.count > 0 %] +[% IF body.send_method == 'Open311' %] <h2> Council contacts configured via Open311 </h2> @@ -30,7 +28,7 @@ <p class="error">Do not give these out except to people at the council.</p> [% END %] -<form method="post" action="[% c.uri_for('council_contacts', area_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> +<form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> <table cellspacing="0" cellpadding="2" border="1"> <tr> @@ -47,11 +45,11 @@ </tr> [% WHILE ( contact = contacts.next ) %] <tr> - <td><a href="[% c.uri_for( 'council_edit', area_id, contact.category ) %]">[% contact.category %]</a></td> + <td><a href="[% c.uri_for( 'body_edit', body_id, contact.category ) %]">[% contact.category %]</a></td> <td>[% contact.email | html %]</td> <td>[% IF contact.confirmed %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]</td> <td>[% IF contact.deleted %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]</td> - <td>[% IF conf.can_be_devolved && contact.send_method %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]</td> + <td>[% IF body.can_be_devolved && contact.send_method %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]</td> <td>[% contact.editor %]</td> <td>[% contact.note | html %]</td> <td>[% contact.non_public ? loc('Non Public') : loc('Public') %]</td> @@ -62,7 +60,6 @@ </table> <p> - <input type="hidden" name="area_id" value="[% area_id %]"> <input type="hidden" name="posted" value="update"> <input type="hidden" name="token" value="[% token %]"> <input type="submit" name="Update statuses" value="[% loc('Update statuses') %]"> @@ -71,7 +68,7 @@ <h2>[% loc('Add new category') %]</h2> - <form method="post" action="[% c.uri_for('council_contacts', area_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> + <form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> [% IF c.cobrand.moniker != 'emptyhomes' %] <p> @@ -101,7 +98,6 @@ </p> <p> - <input type="hidden" name="area_id" value="[% area_id %]" > <input type="hidden" name="posted" value="new" > <input type="hidden" name="token" value="[% token %]" > <input type="submit" name="Create category" value="[% loc('Create category') %]" > @@ -114,20 +110,20 @@ </form> <h2>[% loc('Configure Open311 integration') %]</h2> - <form method="post" action="[% c.uri_for('council_contacts', area_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> + <form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> <p> <label for="endpoint">Endpoint</label> - <input type="text" name="endpoint" id="endpoint" value="[% conf.endpoint %]" size="50"> + <input type="text" name="endpoint" id="endpoint" value="[% body.endpoint %]" size="50"> </p> <p> <label for="jurisdiction">Jurisdiction</label> - <input type="text" name="jurisdiction" id="jurisdiction" value="[% conf.jurisdiction %]" size="50"> + <input type="text" name="jurisdiction" id="jurisdiction" value="[% body.jurisdiction %]" size="50"> </p> <p> <label for="api_key">Api Key</label> - <input type="text" name="api_key" id="api_key" value="[% conf.api_key %]" size="25"> + <input type="text" name="api_key" id="api_key" value="[% body.api_key %]" size="25"> </p> <p> @@ -135,34 +131,32 @@ <select name="send_method"> <option value=""> -- Select a method -- </option> [% FOR method IN send_methods %] - <option value="[% method %]"[% ' selected' IF conf.send_method == method %]>[% method %]</option> + <option value="[% method %]"[% ' selected' IF body.send_method == method %]>[% method %]</option> [% END %] </select> </p> <p> - <input type="checkbox" name="send_comments"[% ' checked' IF conf.send_comments %]> + <input type="checkbox" name="send_comments"[% ' checked' IF body.send_comments %]> <label for="send_comments" class="inline">Use Open311 comment sending extension</label> </p> <p> <label for"comment_user_id">User to attribute fetched comments to</label> - <input type="text" name="comment_user_id" value="[% conf.comment_user_id %]"> + <input type="text" name="comment_user_id" value="[% body.comment_user_id %]"> </p> <p> - <input type="checkbox" name="suppress_alerts"[% ' checked' IF conf.suppress_alerts %]> + <input type="checkbox" name="suppress_alerts"[% ' checked' IF body.suppress_alerts %]> <label for="suppress_alerts" class="inline">Do not send email alerts on fetched comments to problem creator</label> </p> <p> - <input type="checkbox" name="devolved"[% ' checked' IF conf.can_be_devolved %]> + <input type="checkbox" name="devolved"[% ' checked' IF body.can_be_devolved %]> <label for="devolved" class="inline">Endpoint lookup can be devolved to contacts</label> </p> <p> - <input type="hidden" name="open311_id" value="[% conf.id %]"> - <input type="hidden" name="area_id" value="[% area_id %]"> <input type="hidden" name="posted" value="open311"> <input type="hidden" name="token" value="[% token %]"> <input type="submit" name="Configure Open311" value="[% loc('Configure Open311') %]"> diff --git a/templates/web/default/admin/council_edit.html b/templates/web/default/admin/body_edit.html index 408466b51..7c9ad5fab 100644 --- a/templates/web/default/admin/council_edit.html +++ b/templates/web/default/admin/body_edit.html @@ -1,4 +1,4 @@ -[% INCLUDE 'admin/header.html' title=tprintf(loc('Council contacts for %s'), council_name) -%] +[% INCLUDE 'admin/header.html' title=tprintf(loc('Council contacts for %s'), body.name) -%] [% BLOCK highlightchanged_yesno %] [%- output = loc('No') %] @@ -19,37 +19,43 @@ [% END %] </p> -<form method="post" action="[% c.uri_for('council_contacts', area_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> - <strong>[% loc('Category:') %] </strong>[% contact.category | html %] +<form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> + <p><strong>[% loc('Category:') %] </strong>[% contact.category | html %] <input type="hidden" name="category" value="[% contact.category | html %]" > <input type="hidden" name="token" value="[% token %]" > - <strong>[% loc('Email:') %] </strong> + <p><strong>[% loc('Email:') %] </strong> <input type="text" name="email" value="[% contact.email | html %]" size="30"> - <input type="checkbox" name="confirmed" value="1" id="confirmed"[% ' checked' IF contact.confirmed %]> <label for="confirmed">[% loc('Confirmed' ) %]</label> - <input type="checkbox" name="deleted" value="1" id="deleted"[% ' checked' IF contact.deleted %]> <label for="deleted">[% loc('Deleted') %]</label> - <input type="checkbox" name="non_public" value="1" id="non_public"[% ' checked' IF contact.non_public %]> <label for="non_public">[% loc('Private') %]</label><br> - <strong>[% loc('Note:') %] </strong><textarea name="note" rows="3" cols="40">[% contact.note | html %]</textarea> <br> + <p> + <input type="checkbox" name="confirmed" value="1" id="confirmed"[% ' checked' IF contact.confirmed %]> + <label class="inline" for="confirmed">[% loc('Confirmed' ) %]</label> + <input type="checkbox" name="deleted" value="1" id="deleted"[% ' checked' IF contact.deleted %]> + <label class="inline" for="deleted">[% loc('Deleted') %]</label> + <input type="checkbox" name="non_public" value="1" id="non_public"[% ' checked' IF contact.non_public %]> + <label class="inline" for="non_public">[% loc('Private') %]</label><br> + + <p><strong>[% loc('Note:') %] </strong><textarea name="note" rows="3" cols="40">[% contact.note | html %]</textarea> + [% IF body.can_be_devolved %] <h2>[% loc('Configure Endpoint') %]</h2> - <form method="post" action="[% c.uri_for('council_contacts', area_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> + <form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> <p> - <label for="endpoint">Endpoint</label>: + <label for="endpoint">Endpoint</label> <input type="text" name="endpoint" id="endpoint" value="[% contact.endpoint %]" size="50"> </p> <p> - <label for="jurisdiction">Jurisdiction</label>: + <label for="jurisdiction">Jurisdiction</label> <input type="text" name="jurisdiction" id="jurisdiction" value="[% contact.jurisdiction %]" size="50"> </p> <p> - <label for="api_key">Api Key</label>: + <label for="api_key">Api Key</label> <input type="text" name="api_key" id="api_key" value="[% contact.api_key %]" size="25"> </p> <p> - <label for="send_method">Send Method</label>: + <label for="send_method">Send Method</label> <select name="send_method"> <option value=""> -- Select a method -- </option> [% FOR method IN send_methods %] @@ -57,10 +63,10 @@ [% END %] </select> </p> + [% END %] - <input type="hidden" name="area_id" value="[% area_id %]"> <input type="hidden" name="posted" value="new"> - <input type="submit" name="Save changes" value="[% loc('Save changes') %]"> + <p><input type="submit" name="Save changes" value="[% loc('Save changes') %]"> </form> <h2>[% loc('History') %]</h2> diff --git a/templates/web/default/admin/council_list.html b/templates/web/default/admin/council_list.html deleted file mode 100644 index ac99368fe..000000000 --- a/templates/web/default/admin/council_list.html +++ /dev/null @@ -1,47 +0,0 @@ -[% INCLUDE 'admin/header.html' title=loc('Council contacts') -%] - -[%- BLOCK details %] -[%- IF councils.size == 0 %] - [%- loc('None') %] -[%- ELSE %] -[%- FOREACH council IN councils %] - [%- IF council.parent_area %] - [%- - p_area = areas.$council.parent_area - parent = ', ' _ areas.$parent.name - %] - [%- ELSE %] - [%- parent = '' %] - [%- END %] - [%- '<ul>' IF loop.first %] - <li><a href="[% c.uri_for( 'council_contacts', council ) %]">[% areas.$council.name %] [% parent %][% tprintf( loc('%d addresses'), counts.$council.c) IF counts.$council && c.cobrand.moniker != 'emptyhomes' %]</a> - [%- '</ul>' IF loop.last %] -[%- END %] -[%- END %] -[%- END %] - -<h2>[% loc('Diligency prize league table') %]</h2> -[% IF edit_activity.count %] -<ul> - [% WHILE ( editor = edit_activity.next ) %] - <li>[% tprintf( loc('%d edits by %s'), editor.get_column('c'), editor.editor ) %]</li> - [% END %] -</ul> -[% ELSE %] -<p> -[% loc('No edits have yet been made.') %] -</p> -[% END %] - -<h2>[% loc('Councils') %]</h2> - -<h3>[% loc('No info at all') %]</h3> -[% PROCESS details councils=no_info %] -<h3>[% loc('Currently has 1+ deleted') %]</h3> -[% PROCESS details councils=one_plus_deleted %] -<h3>[% loc('Some unconfirmeds') %]</h3> -[% PROCESS details councils=unconfirmeds %] -<h3>[% loc('All confirmed') %]</h3> -[% PROCESS details councils=all_confirmed %] - -[% INCLUDE 'admin/footer.html' %] diff --git a/templates/web/default/admin/list_flagged.html b/templates/web/default/admin/flagged.html index 0b22bccb2..5af92a23c 100644 --- a/templates/web/default/admin/list_flagged.html +++ b/templates/web/default/admin/flagged.html @@ -38,7 +38,7 @@ <tr> <td>[% user.name | html %]</td> <td>[% user.email | html %]</td> - <td><a href="[% c.uri_for( 'search_reports', search => user.email ) %]">list content</a></td> + <td><a href="[% c.uri_for( 'reports', search => user.email ) %]">list content</a></td> </tr> [%- END %] </table> diff --git a/templates/web/default/admin/problem_row.html b/templates/web/default/admin/problem_row.html index ce95f8078..f985fdf7f 100644 --- a/templates/web/default/admin/problem_row.html +++ b/templates/web/default/admin/problem_row.html @@ -10,8 +10,8 @@ <td>[% PROCESS value_or_nbsp value=problem.title %]</td> <td>[% PROCESS value_or_nbsp value=problem.name %]</td> <td>[% PROCESS value_or_nbsp value=problem.user.email %]</td> - <td>[%- IF edit_council_contacts -%] - <a href="[% c.uri_for('council_contacts', problem.bodies_str ) %]">[% PROCESS value_or_nbsp value=problem.bodies_str %]</a> + <td>[%- IF edit_body_contacts -%] + <a href="[% c.uri_for('body', problem.bodies_str ) %]">[% PROCESS value_or_nbsp value=problem.bodies_str %]</a> [%- ELSE -%] [%- PROCESS value_or_nbsp value=problem.bodies_str -%] [%- END -%]</td> diff --git a/templates/web/default/admin/search_reports.html b/templates/web/default/admin/reports.html index 9702c16a7..b5e1361cd 100644 --- a/templates/web/default/admin/search_reports.html +++ b/templates/web/default/admin/reports.html @@ -1,7 +1,7 @@ [% INCLUDE 'admin/header.html' title=loc('Search Reports') %] [% PROCESS 'admin/report_blocks.html' %] -<form method="get" action="[% c.uri_for('search_reports') %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> +<form method="get" action="[% c.uri_for('reports') %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> <label for="search">[% loc('Search:') %]</label> <input type="text" name="search" size="30" id="search"> </form> diff --git a/templates/web/default/admin/stats.html b/templates/web/default/admin/stats.html index 234600837..bb42d5b7d 100644 --- a/templates/web/default/admin/stats.html +++ b/templates/web/default/admin/stats.html @@ -81,10 +81,10 @@ </p> <p> - [% loc('Council:') %] <select id='council' name='council'> + [% loc('Council:') %] <select id='body' name='body'> <option value=''>[% loc('No council') %]</option> - [% FOR council IN council_ids %] - <option value="[% council %]"[% ' selected' IF council == selected_council %]>[% council_details.$council.name %]</option> + [% FOR body IN bodies %] + <option value="[% body.id %]"[% ' selected' IF body.id == selected_body %]>[% body.name %]</option> [% END %] </select> </p> diff --git a/templates/web/default/admin/user_edit.html b/templates/web/default/admin/user_edit.html index f6d3be3e3..205e6561e 100644 --- a/templates/web/default/admin/user_edit.html +++ b/templates/web/default/admin/user_edit.html @@ -9,10 +9,10 @@ <ul> <li>[% loc('Name:') %] <input type='text' name='name' id='name' value='[% user.name | html %]'></li> <li>[% loc('Email:') %] <input type='text' id='email' name='email' value='[% user.email | html %]'></li> -<li>[% loc('Council:') %] <select id='council' name='council'> +<li>[% loc('Council:') %] <select id='body' name='body'> <option value=''>[% loc('No council') %]</option> -[% FOR council IN council_ids %] - <option value="[% council %]"[% ' selected' IF council == user.from_body %]>[% council_details.$council.name %]</option> +[% FOR body IN bodies %] + <option value="[% body.id %]"[% ' selected' IF body.id == user.from_body %]>[% body.name %]</option> [% END %] </select> <li>[% loc('Flagged:') %] <input type="checkbox" id="flagged" name="flagged"[% user.flagged ? ' checked' : '' %]></li> diff --git a/templates/web/default/admin/search_users.html b/templates/web/default/admin/users.html index 258fd9adf..12f681741 100644 --- a/templates/web/default/admin/search_users.html +++ b/templates/web/default/admin/users.html @@ -1,7 +1,7 @@ [% INCLUDE 'admin/header.html' title=loc('Search Users') %] [% PROCESS 'admin/report_blocks.html' %] -<form method="get" action="[% c.uri_for('search_users') %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> +<form method="get" action="[% c.uri_for('users') %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> <label for="search">[% loc('Search:') %]</label> <input type="text" name="search" size="30" id="search"> </form> @@ -18,7 +18,7 @@ [%- FOREACH user IN users %] <tr> <td>[% PROCESS value_or_nbsp value=user.name %]</td> - <td><a href="[% c.uri_for( 'search_reports', search => user.email ) %]">[% PROCESS value_or_nbsp value=user.email %]</a></td> + <td><a href="[% c.uri_for( 'reports', search => user.email ) %]">[% PROCESS value_or_nbsp value=user.email %]</a></td> <td>[% PROCESS value_or_nbsp value=user.from_body %]</td> <td>[% user.flagged == 2 ? loc('(Email in abuse table)') : user.flagged ? loc('Yes') : ' ' %]</td> <td>[% IF user.id %]<a href="[% c.uri_for( 'user_edit', user.id ) %]">[% loc('Edit') %]</a>[% END %]</td> |