aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm77
1 files changed, 47 insertions, 30 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 54d744ccd..e14c7dc66 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -7,6 +7,7 @@ BEGIN { extends 'Catalyst::Controller'; }
use POSIX qw(strftime strcoll);
use Digest::MD5 qw(md5_hex);
use mySociety::EmailUtil qw(is_valid_email);
+use if !$ENV{TRAVIS}, 'Image::Magick';
use FixMyStreet::SendReport;
@@ -32,6 +33,11 @@ sub begin : Private {
my ( $self, $c ) = @_;
$c->uri_disposition('relative');
+
+ if ( $c->cobrand->moniker eq 'seesomething' ) {
+ $c->detach( '/auth/redirect' ) unless $c->user_exists;
+ $c->detach( '/auth/redirect' ) unless $c->user->from_council;
+ }
}
sub summary : Path( 'summary' ) : Args(0) {
@@ -299,9 +305,14 @@ sub update_contacts : Private {
$contact->email( $email );
$contact->confirmed( $c->req->param('confirmed') ? 1 : 0 );
$contact->deleted( $c->req->param('deleted') ? 1 : 0 );
+ $contact->non_public( $c->req->param('non_public') ? 1 : 0 );
$contact->note( $c->req->param('note') );
$contact->whenedited( \'ms_current_timestamp()' );
$contact->editor( $editor );
+ $contact->endpoint( $c->req->param('endpoint') );
+ $contact->jurisdiction( $c->req->param('jurisdiction') );
+ $contact->api_key( $c->req->param('api_key') );
+ $contact->send_method( $c->req->param('send_method') );
if ( $contact->in_storage ) {
$c->stash->{updated} = _('Values updated');
@@ -338,7 +349,7 @@ 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 extended_statuses comment_user_id/;
+ my %params = map { $_ => $c->req->param($_) || '' } qw/open311_id endpoint jurisdiction api_key area_id send_method send_comments suppress_alerts extended_statuses comment_user_id devolved/;
if ( $params{open311_id} ) {
my $conf = $c->model('DB::Open311Conf')->find( { id => $params{open311_id} } );
@@ -350,6 +361,7 @@ sub update_contacts : Private {
$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 );
$conf->send_extended_statuses( $params{extended_statuses} || 0 );
$conf->update();
@@ -365,6 +377,7 @@ sub update_contacts : Private {
$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 );
$conf->send_extended_statuses( $params{extended_statuses} || 0 );
$conf->insert();
@@ -461,6 +474,9 @@ sub council_edit : Path('council_edit') : Args(2) {
$c->stash->{history} = $history;
+ my @methods = map { $_ =~ s/FixMyStreet::SendReport:://; $_ } keys %{ FixMyStreet::SendReport->get_senders };
+ $c->stash->{send_methods} = \@methods;
+
return 1;
}
@@ -640,6 +656,7 @@ 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;
# do this here so before we update the values in problem
if ( $c->req->param('anonymous') ne $problem->anonymous
@@ -647,7 +664,8 @@ sub report_edit : Path('report_edit') : Args(1) {
|| $c->req->param('email') ne $problem->user->email
|| $c->req->param('title') ne $problem->title
|| $c->req->param('detail') ne $problem->detail
- || $flagged != $problem->flagged )
+ || $flagged != $problem->flagged
+ || $non_public != $problem->non_public )
{
$edited = 1;
}
@@ -658,6 +676,7 @@ sub report_edit : Path('report_edit') : Args(1) {
$problem->state( $c->req->param('state') );
$problem->name( $c->req->param('name') );
$problem->flagged( $flagged );
+ $problem->non_public( $non_public );
if ( $c->req->param('email') ne $problem->user->email ) {
my $user = $c->model('DB::User')->find_or_create(
@@ -725,8 +744,24 @@ sub search_users: Path('search_users') : Args(0) {
]
}
);
+ my @users = $users->all;
+ my %email2user = map { $_->email => $_ } @users;
+ $c->stash->{users} = [ @users ];
+
+ my $emails = $c->model('DB::Abuse')->search(
+ {
+ email => { ilike => $isearch }
+ }
+ );
+ foreach my $email ($emails->all) {
+ # Slight abuse of the boolean flagged value
+ if ($email2user{$email->email}) {
+ $email2user{$email->email}->flagged( 2 );
+ } else {
+ push @{$c->stash->{users}}, { email => $email->email, flagged => 2 };
+ }
+ }
- $c->stash->{users} = [ $users->all ];
}
return 1;
@@ -833,26 +868,6 @@ sub update_edit : Path('update_edit') : Args(1) {
return 1;
}
-sub search_abuse : Path('search_abuse') : Args(0) {
- my ( $self, $c ) = @_;
-
- $c->forward('check_page_allowed');
-
- my $search = $c->req->param('search');
-
- if ($search) {
- my $emails = $c->model('DB::Abuse')->search(
- {
- email => { ilike => "\%$search\%" }
- }
- );
-
- $c->stash->{emails} = [ $emails->all ];
- }
-
- return 1;
-}
-
sub user_edit : Path('user_edit') : Args(1) {
my ( $self, $c, $id ) = @_;
@@ -917,6 +932,10 @@ sub stats : Path('stats') : Args(0) {
$c->forward('set_up_council_details');
+ if ( $c->cobrand->moniker eq 'seesomething' ) {
+ return $c->cobrand->admin_stats();
+ }
+
if ( $c->req->param('getcounts') ) {
my ( $start_date, $end_date, @errors );
@@ -1019,13 +1038,12 @@ sub set_allowed_pages : Private {
if( !$pages ) {
$pages = {
'summary' => [_('Summary'), 0],
- 'council_list' => [_('Council contacts'), 1],
- 'search_reports' => [_('Search Reports'), 2],
+ 'council_list' => [_('Bodies'), 1],
+ 'search_reports' => [_('Reports'), 2],
'timeline' => [_('Timeline'), 3],
- 'questionnaire' => [_('Survey Results'), 4],
- 'search_users' => [_('Search Users'), 5],
- 'search_abuse' => [_('Search Abuse'), 5],
- 'list_flagged' => [_('List Flagged'), 6],
+ 'questionnaire' => [_('Survey'), 4],
+ 'search_users' => [_('Users'), 5],
+ 'list_flagged' => [_('Flagged'), 6],
'stats' => [_('Stats'), 6],
'user_edit' => [undef, undef],
'council_contacts' => [undef, undef],
@@ -1276,7 +1294,6 @@ sub trim {
sub _rotate_image {
my ($photo, $direction) = @_;
- use Image::Magick;
my $image = Image::Magick->new;
$image->BlobToImage($photo);
my $err = $image->Rotate($direction);