aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
authorChris Mytton <self@hecticjeff.net>2013-09-13 12:12:14 +0100
committerChris Mytton <self@hecticjeff.net>2013-09-13 12:12:14 +0100
commitb44f9edab53f59fb442e5ee4db28cb25408c652c (patch)
treee7cd62bd148a5332e1ec625dda6c3bc6b09ceb62 /perllib/FixMyStreet/App/Controller
parent2099ac31a4410f2cf8e1c7d31dc35cdd9ac1e070 (diff)
parent94ac7786132a538a5742ba325eb7fe9eff89cfc9 (diff)
Merge branch 'master' into oxfordshire-usability-recommendations
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm30
-rw-r--r--perllib/FixMyStreet/App/Controller/JSON.pm7
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm14
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm3
4 files changed, 44 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index e2547019b..4973b7c4e 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -130,6 +130,8 @@ sub index : Path : Args(0) {
$c->stash->{categories} = $c->cobrand->problems->categories_summary();
+ $c->stash->{total_bodies} = $c->model('DB::Body')->count();
+
return 1;
}
@@ -234,6 +236,7 @@ sub bodies : Path('bodies') : Args(0) {
my $posted = $c->req->param('posted') || '';
if ( $posted eq 'body' ) {
+ $c->forward('check_for_super_user');
$c->forward('check_token');
my $params = $c->forward('body_params');
@@ -296,6 +299,7 @@ sub body : Path('body') : Args(1) {
$c->stash->{body_id} = $body_id;
+ $c->forward( 'check_for_super_user' );
$c->forward( 'get_token' );
$c->forward( 'lookup_body' );
$c->forward( 'fetch_all_bodies' );
@@ -311,6 +315,13 @@ sub body : Path('body') : Args(1) {
return 1;
}
+sub check_for_super_user : Private {
+ my ( $self, $c ) = @_;
+ if ( $c->cobrand->moniker eq 'zurich' && $c->stash->{admin_type} ne 'super' ) {
+ $c->detach('/page_error_404_not_found', []);
+ }
+}
+
sub update_contacts : Private {
my ( $self, $c ) = @_;
@@ -377,6 +388,7 @@ sub update_contacts : Private {
$c->stash->{updated} = _('Values updated');
} elsif ( $posted eq 'body' ) {
+ $c->forward('check_for_super_user');
$c->forward('check_token');
my $params = $c->forward( 'body_params' );
@@ -401,7 +413,7 @@ sub update_contacts : Private {
sub body_params : Private {
my ( $self, $c ) = @_;
- my @fields = qw/name endpoint jurisdiction api_key send_method send_comments suppress_alerts send_extended_statuses comment_user_id can_be_devolved parent/;
+ my @fields = qw/name endpoint jurisdiction api_key send_method send_comments suppress_alerts send_extended_statuses comment_user_id can_be_devolved parent deleted/;
my %defaults = map { $_ => '' } @fields;
%defaults = ( %defaults,
send_comments => 0,
@@ -410,6 +422,7 @@ sub body_params : Private {
send_extended_statuses => 0,
can_be_devolved => 0,
parent => undef,
+ deleted => 0,
);
my %params = map { $_ => $c->req->param($_) || $defaults{$_} } @fields;
return \%params;
@@ -420,6 +433,7 @@ sub display_contacts : Private {
my $contacts = $c->stash->{body}->contacts->search(undef, { order_by => [ 'category' ] } );
$c->stash->{contacts} = $contacts;
+ $c->stash->{live_contacts} = $contacts->search({ deleted => 0 });
if ( $c->req->param('text') && $c->req->param('text') == 1 ) {
$c->stash->{template} = 'admin/council_contacts.txt';
@@ -1014,8 +1028,20 @@ sub flagged : Path('flagged') : Args(0) {
$c->stash->{problems} = [ $problems->all ];
my $users = $c->model('DB::User')->search( { flagged => 1 } );
+ my @users = $users->all;
+ my %email2user = map { $_->email => $_ } @users;
+ $c->stash->{users} = [ @users ];
- $c->stash->{users} = $users;
+ my @abuser_emails = $c->model('DB::Abuse')->all();
+
+ foreach my $email (@abuser_emails) {
+ # 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 };
+ }
+ }
return 1;
}
diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm
index 1a7c1915b..17507a84b 100644
--- a/perllib/FixMyStreet/App/Controller/JSON.pm
+++ b/perllib/FixMyStreet/App/Controller/JSON.pm
@@ -8,6 +8,7 @@ use JSON;
use DateTime;
use DateTime::Format::ISO8601;
use List::MoreUtils 'uniq';
+use FixMyStreet::App;
=head1 NAME
@@ -80,11 +81,13 @@ sub problems : Local {
$date_col = 'lastupdate';
}
+ my $dt_parser = FixMyStreet::App->model('DB')->schema->storage->datetime_parser;
+
my $one_day = DateTime::Duration->new( days => 1 );
my $query = {
$date_col => {
- '>=' => $start_dt,
- '<=' => $end_dt + $one_day,
+ '>=' => $dt_parser->format_datetime($start_dt),
+ '<=' => $dt_parser->format_datetime($end_dt + $one_day),
},
state => [ @state ],
};
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index 8b00d1533..09afabecf 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -30,17 +30,19 @@ Display a photo
=cut
-sub during :LocalRegex('^([0-9a-f]{40})\.temp\.jpeg$') {
+sub during :LocalRegex('^([0-9a-f]{40})\.(temp|fulltemp)\.jpeg$') {
my ( $self, $c ) = @_;
- my ( $hash ) = @{ $c->req->captures };
+ my ( $hash, $size ) = @{ $c->req->captures };
my $file = file( $c->config->{UPLOAD_DIR}, "$hash.jpeg" );
my $photo = $file->slurp;
- if ( $c->cobrand->default_photo_resize ) {
- $photo = _shrink( $photo, $c->cobrand->default_photo_resize );
- } else {
- $photo = _shrink( $photo, '250x250' );
+ if ( $size eq 'temp' ) {
+ if ( $c->cobrand->default_photo_resize ) {
+ $photo = _shrink( $photo, $c->cobrand->default_photo_resize );
+ } else {
+ $photo = _shrink( $photo, '250x250' );
+ }
}
$c->forward( 'output', [ $photo ] );
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 3d3ddce1e..6018dfa80 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -956,6 +956,9 @@ sub check_for_errors : Private {
delete $field_errors{name};
my $report = $c->stash->{report};
$report->title( Utils::cleanup_text( substr($report->detail, 0, 25) ) );
+ if ( ! $c->req->param('phone') ) {
+ $field_errors{phone} = _("This information is required");
+ }
}
# FIXME: need to check for required bromley fields here