aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm41
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm7
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm11
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Rss.pm10
4 files changed, 59 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index a34737844..c988b23c1 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -572,6 +572,9 @@ sub report_edit : Path('report_edit') : Args(1) {
elsif ( $c->req->param('banuser') ) {
$c->forward('ban_user');
}
+ elsif ( $c->req->param('rotate_photo') ) {
+ $c->forward('rotate_photo');
+ }
elsif ( $c->req->param('submit') ) {
$c->forward('check_token');
@@ -1161,6 +1164,31 @@ sub check_email_for_abuse : Private {
return 1;
}
+=head2 rotate_photo
+
+Rotate a photo 90 degrees left or right
+
+=cut
+
+sub rotate_photo : Private {
+ my ( $self, $c ) =@_;
+
+ my $direction = $c->req->param('rotate_photo');
+
+ return unless $direction =~ /Left/ or $direction =~ /Right/;
+
+ my $photo = _rotate_image( $c->stash->{problem}->photo, $direction =~ /Left/ ? -90 : 90 );
+
+ if ( $photo ) {
+ $c->stash->{rotated} = 1;
+ $c->stash->{problem}->photo( $photo );
+ $c->stash->{problem}->update();
+ }
+
+ return 1;
+}
+
+
=head2 check_page_allowed
Checks if the current catalyst action is in the list of allowed pages and
@@ -1207,6 +1235,19 @@ sub trim {
return $e;
}
+sub _rotate_image {
+ my ($photo, $direction) = @_;
+ use Image::Magick;
+ my $image = Image::Magick->new;
+ $image->BlobToImage($photo);
+ my $err = $image->Rotate($direction);
+ return 0 if $err;
+ my @blobs = $image->ImageToBlob();
+ undef $image;
+ return $blobs[0];
+}
+
+
=head1 AUTHOR
Struan Donald
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index c6ede88f7..e982d6a4c 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -911,6 +911,13 @@ sub check_for_errors : Private {
%{ $c->stash->{report}->check_for_errors },
);
+ # if they're got the login details wrong when signing in then
+ # we don't care about the name field even though it's validated
+ # by the user object
+ if ( $c->req->param('submit_sign_in') and $field_errors{password} ) {
+ delete $field_errors{name};
+ }
+
# add the photo error if there is one.
if ( my $photo_error = delete $c->stash->{photo_error} ) {
$field_errors{photo} = $photo_error;
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 0a4ae4609..0587a627a 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -110,6 +110,8 @@ sub ward : Path : Args(2) {
$c->stash->{council_url} = '/reports/' . $council_short;
+ $c->stash->{stats} = $c->cobrand->get_report_stats();
+
my $pins = $c->stash->{pins};
$c->stash->{page} = 'reports'; # So the map knows to make clickable pins
@@ -349,17 +351,12 @@ sub load_and_group_problems : Private {
$c->stash->{pager} = $problems->pager;
$problems = $problems->cursor; # Raw DB cursor for speed
- my ( %fixed, %open, @pins, $total, $cobrand_total );
+ my ( %fixed, %open, @pins );
my $re_councils = join('|', keys %{$c->stash->{areas_info}});
my @cols = ( 'id', 'council', 'state', 'areas', 'latitude', 'longitude', 'title', 'cobrand', 'duration', 'age' );
while ( my @problem = $problems->next ) {
my %problem = zip @cols, @problem;
$c->log->debug( $problem{'cobrand'} . ', cobrand is ' . $c->cobrand->moniker );
- if ( $problem{'cobrand'} && $problem{'cobrand'} eq $c->cobrand->moniker ) {
- $cobrand_total++;
- } else {
- $total++;
- }
if ( !$problem{council} ) {
# Problem was not sent to any council, add to possible councils
$problem{councils} = 0;
@@ -382,8 +379,6 @@ sub load_and_group_problems : Private {
fixed => \%fixed,
open => \%open,
pins => \@pins,
- cobrand_count => $cobrand_total || 0,
- total_count => $total || 0,
);
return 1;
diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm
index 7fddbed97..822780b81 100755
--- a/perllib/FixMyStreet/App/Controller/Rss.pm
+++ b/perllib/FixMyStreet/App/Controller/Rss.pm
@@ -251,6 +251,12 @@ sub add_row : Private {
(my $link = $alert_type->item_link) =~ s/{{(.*?)}}/$row->{$1}/g;
(my $desc = _($alert_type->item_description)) =~ s/{{(.*?)}}/$row->{$1}/g;
my $url = $c->uri_for( $link );
+
+ if ( $row->{postcode} ) {
+ my $pc = $c->cobrand->format_postcode( $row->{postcode} );
+ $title .= ", $pc";
+ }
+
my %item = (
title => ent($title),
link => $url,
@@ -266,8 +272,8 @@ sub add_row : Private {
}
if ( $row->{used_map} ) {
- #my $address = $c->cobrand->find_closest_address_for_rss( $row->{latitude}, $row->{longitude} );
- #$item{description} .= ent("\n<br>$address");
+ my $address = $c->cobrand->find_closest_address_for_rss( $row->{latitude}, $row->{longitude}, $row );
+ $item{description} .= ent("\n<br>$address") if $address;
}
my $recipient_name = $c->cobrand->contact_name;