diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Body.pm | 4 |
4 files changed, 34 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 0d3b024a8..7922dfea1 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -94,8 +94,11 @@ __PACKAGE__->setup(); # tell the code we're secure if we are. after 'prepare_headers' => sub { my $self = shift; - $self->req->secure( 1 ) if $self->config->{BASE_URL} eq 'https://www.zueriwieneu.ch'; - $self->req->secure( 1 ) if $self->config->{BASE_URL} eq 'http://www.fixmystreet.com' && $self->req->headers->header('Host') eq 'fix.bromley.gov.uk'; + my $base_url = $self->config->{BASE_URL}; + my $host = $self->req->headers->header('Host'); + $self->req->secure( 1 ) if $base_url eq 'https://www.zueriwieneu.ch'; + $self->req->secure( 1 ) if $base_url eq 'https://www.fixmystreet.com' + && ( $host eq 'fix.bromley.gov.uk' || $host eq 'www.fixmystreet.com' ); }; # set up DB handle for old code diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 7e0cccc7b..5b3283a2c 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -368,11 +368,32 @@ sub load_and_group_problems : Private { my ( $self, $c ) = @_; my $page = $c->req->params->{p} || 1; + my $type = $c->req->params->{t} || 'all'; my $where = { non_public => 0, state => [ FixMyStreet::DB::Result::Problem->visible_states() ] }; + + my $not_open = [ FixMyStreet::DB::Result::Problem::fixed_states(), FixMyStreet::DB::Result::Problem::closed_states() ]; + if ( $type eq 'new' ) { + $where->{confirmed} = { '>', \"ms_current_timestamp() - INTERVAL '4 week'" }; + $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; + } elsif ( $type eq 'older' ) { + $where->{confirmed} = { '<', \"ms_current_timestamp() - INTERVAL '4 week'" }; + $where->{lastupdate} = { '>', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; + } elsif ( $type eq 'unknown' ) { + $where->{lastupdate} = { '<', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; + } elsif ( $type eq 'fixed' ) { + $where->{lastupdate} = { '>', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{state} = $not_open; + } elsif ( $type eq 'older_fixed' ) { + $where->{lastupdate} = { '<', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{state} = $not_open; + } + if ($c->stash->{ward}) { $where->{areas} = { 'like', '%,' . $c->stash->{ward}->{id} . ',%' }; $where->{bodies_str} = [ @@ -449,7 +470,7 @@ sub redirect_body : Private { $url .= '/' . $c->cobrand->short_name( $c->stash->{body} ); $url .= '/' . $c->cobrand->short_name( $c->stash->{ward} ) if $c->stash->{ward}; - $c->res->redirect( $c->uri_for($url) ); + $c->res->redirect( $c->uri_for($url, $c->req->params ) ); } sub add_row { diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index ec3423f35..c4e33a3c1 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -40,8 +40,9 @@ sub base_url { my $base_url = mySociety::Config::get('BASE_URL'); my $u = $self->council_url; if ( $base_url !~ /$u/ ) { - $base_url =~ s{http://(?!www\.)}{http://$u.}g; - $base_url =~ s{http://www\.}{http://$u.}g; + # council cobrands are not https so transform to http as well + $base_url =~ s{(https?)://(?!www\.)}{http://$u.}g; + $base_url =~ s{(https?)://www\.}{http://$u.}g; } return $base_url; } @@ -59,7 +60,7 @@ sub area_check { if ($council_match) { return 1; } - my $url = 'http://www.fixmystreet.com/'; + my $url = 'https://www.fixmystreet.com/'; if ($context eq 'alert') { $url .= 'alert'; } else { @@ -86,7 +87,7 @@ sub reports_body_check { # We want to make sure we're only on our page. unless ( $self->council_name =~ /^\Q$code\E/ ) { - $c->res->redirect( 'http://www.fixmystreet.com' . $c->req->uri->path_query, 301 ); + $c->res->redirect( 'https://www.fixmystreet.com' . $c->req->uri->path_query, 301 ); $c->detach(); } diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm index be4adeca9..6b529735d 100644 --- a/perllib/FixMyStreet/DB/Result/Body.pm +++ b/perllib/FixMyStreet/DB/Result/Body.pm @@ -98,9 +98,9 @@ __PACKAGE__->has_many( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hTOxxiiHmC8nmQK/p8dXhQ sub url { - my ( $self, $c ) = @_; + my ( $self, $c, $args ) = @_; # XXX $areas_info was used here for Norway parent - needs body parents, I guess - return $c->uri_for( '/reports/' . $c->cobrand->short_name( $self ) ); + return $c->uri_for( '/reports/' . $c->cobrand->short_name( $self ), $args || {} ); } sub areas { |