diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 2aaa488d6..a34737844 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -217,7 +217,10 @@ sub council_list : Path('council_list') : Args(0) { $c->stash->{edit_activity} = $edit_activity; - my @area_types = $c->cobrand->area_types; + # 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); my @councils_ids = sort { strcoll($areas->{$a}->{name}, $areas->{$b}->{name}) } keys %$areas; @@ -331,6 +334,32 @@ sub update_contacts : Private { ); $c->stash->{updated} = _('Values updated'); + } elsif ( $posted eq 'open311' ) { + $c->forward('check_token'); + + my %params = map { $_ => $c->req->param($_) } qw/open311_id endpoint jurisdiction api_key area_id/; + + if ( $params{open311_id} ) { + my $conf = $c->model('DB::Open311Conf')->find( { id => $params{open311_id} } ); + + $conf->endpoint( $params{endpoint} ); + $conf->jurisdiction( $params{jurisdiction} ); + $conf->api_key( $params{api_key} ); + + $conf->update(); + + $c->stash->{updated} = _('Configuration updated'); + } else { + my $conf = $c->model('DB::Open311Conf')->find_or_new( { area_id => $params{area_id} } ); + + $conf->endpoint( $params{endpoint} ); + $conf->jurisdiction( $params{jurisdiction} ); + $conf->api_key( $params{api_key} ); + + $conf->insert(); + + $c->stash->{updated} = _('Configuration updated - contacts will be generated automatically later'); + } } } @@ -348,6 +377,12 @@ sub display_contacts : Private { $c->stash->{contacts} = $contacts; + my $open311 = $c->model('DB::Open311Conf')->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'); |