diff options
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 26 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Alert.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Council.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Location.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Open311.pm | 14 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Questionnaire.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 32 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 27 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Rss.pm | 18 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/View/Web.pm | 4 |
14 files changed, 98 insertions, 93 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 998cb83a8..298c75352 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -50,7 +50,7 @@ sub index : Path : Args(0) { $c->forward('check_page_allowed'); - my ( $sql_restriction, $id, $site_restriction ) = $c->cobrand->site_restriction(); + my $site_restriction = $c->cobrand->site_restriction(); my $problems = $c->cobrand->problems->summary_count; @@ -122,7 +122,7 @@ sub timeline : Path( 'timeline' ) : Args(0) { $c->forward('check_page_allowed'); - my ( $sql_restriction, $id, $site_restriction ) = $c->cobrand->site_restriction(); + my $site_restriction = $c->cobrand->site_restriction(); my %time; $c->model('DB')->schema->storage->sql_maker->quote_char( '"' ); @@ -221,10 +221,10 @@ sub council_list : Path('council_list') : Args(0) { $c->stash->{edit_activity} = $edit_activity; # Not London, as treated separately - my @area_types = $c->cobrand->moniker eq 'emptyhomes' + 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); + : [ 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; @councils_ids = $c->cobrand->filter_all_council_ids_list( @councils_ids ); @@ -472,7 +472,7 @@ sub search_reports : Path('search_reports') { if (my $search = $c->req->param('search')) { $c->stash->{searched} = 1; - my ( $site_res_sql, $site_key, $site_restriction ) = $c->cobrand->site_restriction; + my $site_restriction = $c->cobrand->site_restriction; my $search_n = 0; $search_n = int($search) if $search =~ /^\d+$/; @@ -532,13 +532,11 @@ sub search_reports : Path('search_reports') { if (is_valid_email($search)) { $query = [ 'user.email' => { ilike => $like_search }, - %{ $site_restriction }, ]; } elsif ($search =~ /^id:(\d+)$/) { $query = [ 'me.id' => int($1), - 'problem.id' => int($1), - %{ $site_restriction }, + 'me.problem_id' => int($1), ]; } elsif ($search =~ /^area:(\d+)$/) { $query = []; @@ -550,13 +548,13 @@ sub search_reports : Path('search_reports') { 'me.name' => { ilike => $like_search }, text => { ilike => $like_search }, 'me.cobrand_data' => { ilike => $like_search }, - %{ $site_restriction }, ]; } if (@$query) { my $updates = $c->model('DB::Comment')->search( { + %{ $site_restriction }, -or => $query, }, { @@ -576,7 +574,7 @@ sub search_reports : Path('search_reports') { sub report_edit : Path('report_edit') : Args(1) { my ( $self, $c, $id ) = @_; - my ( $site_res_sql, $site_key, $site_restriction ) = $c->cobrand->site_restriction; + my $site_restriction = $c->cobrand->site_restriction; my $problem = $c->cobrand->problems->search( { @@ -737,8 +735,7 @@ sub search_users: Path('search_users') : Args(0) { sub update_edit : Path('update_edit') : Args(1) { my ( $self, $c, $id ) = @_; - my ( $site_res_sql, $site_key, $site_restriction ) = - $c->cobrand->site_restriction; + my $site_restriction = $c->cobrand->site_restriction; my $update = $c->model('DB::Comment')->search( { id => $id, @@ -1258,8 +1255,7 @@ sub check_page_allowed : Private { sub set_up_council_details : Private { my ($self, $c ) = @_; - my @area_types = $c->cobrand->area_types; - my $areas = mySociety::MaPit::call('areas', \@area_types); + my $areas = mySociety::MaPit::call('areas', $c->cobrand->area_types); my @councils_ids = sort { strcoll($areas->{$a}->{name}, $areas->{$b}->{name}) } keys %$areas; @councils_ids = $c->cobrand->filter_all_council_ids_list( @councils_ids ); diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm index 6e9ae819c..4e5319a59 100644 --- a/perllib/FixMyStreet/App/Controller/Alert.pm +++ b/perllib/FixMyStreet/App/Controller/Alert.pm @@ -184,7 +184,7 @@ sub create_alert : Private { unless ($alert) { $options->{cobrand} = $c->cobrand->moniker(); - $options->{cobrand_data} = $c->cobrand->extra_update_data(); + $options->{cobrand_data} = ''; $options->{lang} = $c->stash->{lang_code}; $alert = $c->model('DB::Alert')->new($options); diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index c300aee9a..926a3f2a5 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -139,7 +139,7 @@ sub prepare_params_for_email : Private { $c->stash->{message} =~ s/\r\n/\n/g; $c->stash->{subject} =~ s/\r|\n/ /g; - my $base_url = $c->cobrand->base_url_for_emails( $c->cobrand->extra_data ); + my $base_url = $c->cobrand->base_url(); my $admin_url = $c->cobrand->admin_base_url; if ( $c->stash->{update} ) { diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm index 7a0f9b73f..a6ce533e4 100644 --- a/perllib/FixMyStreet/App/Controller/Council.pm +++ b/perllib/FixMyStreet/App/Controller/Council.pm @@ -23,8 +23,8 @@ there are no councils then return false. sub load_and_check_councils_and_wards : Private { my ( $self, $c ) = @_; - my @area_types = ( $c->cobrand->area_types(), @$mySociety::VotingArea::council_child_types ); - $c->stash->{area_types} = \@area_types; + my $area_types = [ @{$c->cobrand->area_types}, @{$c->cobrand->area_types_children} ]; + $c->stash->{area_types} = $area_types; $c->forward('load_and_check_councils'); } @@ -42,11 +42,11 @@ sub load_and_check_councils : Private { my $longitude = $c->stash->{longitude}; # Look up councils and do checks for the point we've got - my @area_types; + my $area_types; if ( $c->stash->{area_types} and scalar @{ $c->stash->{area_types} } ) { - @area_types = @{ $c->stash->{area_types} }; + $area_types = $c->stash->{area_types}; } else { - @area_types = $c->cobrand->area_types(); + $area_types = $c->cobrand->area_types; } my $short_latitude = Utils::truncate_coordinate($latitude); @@ -55,7 +55,7 @@ sub load_and_check_councils : Private { # TODO: I think we want in_gb_locale around the MaPit line, needs testing my $all_councils; if ( $c->stash->{fetch_all_areas} ) { - my %area_types = map { $_ => 1 } @area_types; + my %area_types = map { $_ => 1 } @$area_types; my $all_areas = mySociety::MaPit::call( 'point', "4326/$short_longitude,$short_latitude" ); $c->stash->{all_areas} = $all_areas; @@ -67,7 +67,11 @@ sub load_and_check_councils : Private { } else { $all_councils = mySociety::MaPit::call( 'point', "4326/$short_longitude,$short_latitude", - type => \@area_types ); + type => $area_types ); + } + if ($all_councils->{error}) { + $c->stash->{location_error} = $all_councils->{error}; + return; } # Let cobrand do a check @@ -83,9 +87,8 @@ sub load_and_check_councils : Private { $c->cobrand->remove_redundant_councils($all_councils) if $c->stash->{remove_redundant_councils}; # If we don't have any councils we can't accept the report - if ( !scalar keys %$all_councils || $all_councils->{error}) { - $c->stash->{location_offshore} = 1; - $c->stash->{location_error} = 'That point is outside the boundaries.'; + if ( !scalar keys %$all_councils ) { + $c->stash->{location_error} = _('That location does not appear to be covered by a council; perhaps it is offshore or outside the country. Please try again.'); return; } diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm index df8a090c2..c3d754485 100644 --- a/perllib/FixMyStreet/App/Controller/Location.pm +++ b/perllib/FixMyStreet/App/Controller/Location.pm @@ -104,7 +104,7 @@ sub check_location : Private { eval { Utils::convert_latlon_to_en( $c->stash->{latitude}, $c->stash->{longitude} ); }; if (my $error = $@) { mySociety::Locale::pop(); # We threw exception, so it won't have happened. - $error = _('That location does not appear to be in Britain; please try again.') + $error = _('That location does not appear to be in the UK; please try again.') if $error =~ /of the area covered/; $c->stash->{location_error} = $error; return; diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm index 34e2b7cd3..040b0d3e6 100644 --- a/perllib/FixMyStreet/App/Controller/Open311.pm +++ b/perllib/FixMyStreet/App/Controller/Open311.pm @@ -163,10 +163,10 @@ sub get_services : Private { my $categories = $c->model('DB::Contact')->not_deleted; if ($lat || $lon) { - my @area_types = $c->cobrand->area_types; + my $area_types = $c->cobrand->area_types; my $all_councils = mySociety::MaPit::call('point', "4326/$lon,$lat", - type => \@area_types); + type => $area_types); $categories = $categories->search( { area_id => [ keys %$all_councils ], } ); @@ -319,8 +319,6 @@ sub get_requests : Private { service_request_id => [ '=', 'id' ], service_code => [ '=', 'category' ], status => [ 'IN', 'state' ], - start_date => [ '>=', 'confirmed' ], - end_date => [ '<', 'confirmed' ], agency_responsible => [ '~', 'council' ], interface_used => [ '=', 'service' ], has_photo => [ '=', 'photo' ], @@ -365,6 +363,14 @@ sub get_requests : Private { $criteria->{$key} = { $op, $value }; } + if ( $c->req->param('start_date') and $c->req->param('end_date') ) { + $criteria->{confirmed} = [ '-and' => { '>=', $c->req->param('start_date') }, { '<', $c->req->param('end_date') } ]; + } elsif ( $c->req->param('start_date') ) { + $criteria->{confirmed} = { '>=', $c->req->param('start_date') }; + } elsif ( $c->req->param('end_date') ) { + $criteria->{confirmed} = { '<', $c->req->param('end_date') }; + } + if ('rss' eq $c->stash->{format}) { $c->stash->{type} = 'new_problems'; $c->forward( '/rss/lookup_type' ); diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index 6aa4f7604..f0cc72e07 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -31,27 +31,27 @@ sub check_questionnaire : Private { my $questionnaire = $c->stash->{questionnaire}; - my $problem_id = $questionnaire->problem_id; + my $problem = $questionnaire->problem; if ( $questionnaire->whenanswered ) { - my $problem_url = $c->uri_for( "/report/$problem_id" ); + my $problem_url = $c->cobrand->base_url_for_report( $problem ) . $problem->url; my $contact_url = $c->uri_for( "/contact" ); $c->stash->{message} = sprintf(_("You have already answered this questionnaire. If you have a question, please <a href='%s'>get in touch</a>, or <a href='%s'>view your problem</a>.\n"), $contact_url, $problem_url); $c->stash->{template} = 'errors/generic.html'; $c->detach; } - unless ( $questionnaire->problem->is_visible ) { + unless ( $problem->is_visible ) { $c->detach('missing_problem'); } - $c->stash->{problem} = $questionnaire->problem; - $c->stash->{answered_ever_reported} = $questionnaire->problem->user->answered_ever_reported; + $c->stash->{problem} = $problem; + $c->stash->{answered_ever_reported} = $problem->user->answered_ever_reported; # EHA needs to know how many to alter display, and whether to send another or not if ($c->cobrand->moniker eq 'emptyhomes') { $c->stash->{num_questionnaire} = $c->model('DB::Questionnaire')->count( - { problem_id => $c->stash->{problem}->id } + { problem_id => $problem->id } ); } @@ -96,15 +96,16 @@ sub submit_creator_fixed : Private { my @errors; - map { $c->stash->{$_} = $c->req->params->{$_} || '' } qw(reported problem); + $c->stash->{reported} = $c->req->params->{reported}; + $c->stash->{problem_id} = $c->req->params->{problem}; # should only be able to get to here if we are logged and we have a # problem - unless ( $c->user && $c->stash->{problem} ) { + unless ( $c->user && $c->stash->{problem_id} ) { $c->detach('missing_problem'); } - my $problem = $c->cobrand->problems->find( { id => $c->stash->{problem} } ); + my $problem = $c->cobrand->problems->find( { id => $c->stash->{problem_id} } ); # you should not be able to answer questionnaires about problems # that you've not submitted @@ -114,13 +115,12 @@ sub submit_creator_fixed : Private { push @errors, _('Please say whether you\'ve ever reported a problem to your council before') unless $c->stash->{reported}; - $c->stash->{problem_id} = $c->stash->{problem}; $c->stash->{errors} = \@errors; $c->detach( 'creator_fixed' ) if scalar @errors; my $questionnaire = $c->model( 'DB::Questionnaire' )->find_or_new( { - problem_id => $c->stash->{problem}, + problem_id => $c->stash->{problem_id}, # we want to look for any previous questionnaire here rather than one for # this specific open state -> fixed transistion old_state => [ FixMyStreet::DB::Result::Problem->open_states() ], @@ -199,7 +199,7 @@ sub submit_standard : Private { mark_open => $new_state eq 'confirmed' ? 1 : 0, lang => $c->stash->{lang_code}, cobrand => $c->cobrand->moniker, - cobrand_data => $c->cobrand->extra_update_data, + cobrand_data => '', confirmed => \'ms_current_timestamp()', anonymous => $problem->anonymous, } @@ -281,10 +281,10 @@ sub display : Private { map { Utils::truncate_coordinate($_) } ( $problem->latitude, $problem->longitude ); - $c->stash->{updates} = $c->model('DB::Comment')->search( + $c->stash->{updates} = [ $c->model('DB::Comment')->search( { problem_id => $problem->id, state => 'confirmed' }, { order_by => 'confirmed' } - ); + )->all ]; $c->stash->{page} = 'questionnaire'; FixMyStreet::Map::display_map( diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 6f249b2fe..d36ba32fe 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -115,8 +115,6 @@ sub format_problem_for_display : Private { my $problem = $c->stash->{problem}; - $c->stash->{banner} = $c->cobrand->generate_problem_banner($problem); - ( $c->stash->{short_latitude}, $c->stash->{short_longitude} ) = map { Utils::truncate_coordinate($_) } ( $problem->latitude, $problem->longitude ); @@ -125,7 +123,7 @@ sub format_problem_for_display : Private { $c->stash->{add_alert} = 1; } - $c->stash->{extra_name_info} = $problem->council eq '2482' ? 1 : 0; + $c->stash->{extra_name_info} = $problem->council && $problem->council eq '2482' ? 1 : 0; $c->forward('generate_map_tags'); diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index b0b338c69..b18e6e39f 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -78,6 +78,7 @@ partial =cut use constant COUNCIL_ID_BARNET => 2489; +use constant COUNCIL_ID_BROMLEY => 2482; sub report_new : Path : Args(0) { my ( $self, $c ) = @_; @@ -93,6 +94,7 @@ sub report_new : Path : Args(0) { $c->stash->{template} = "report/new/fill_in_details.html"; $c->forward('setup_categories_and_councils'); $c->forward('generate_map'); + $c->forward('check_for_category'); # deal with the user and report and check both are happy return unless $c->forward('check_form_submitted'); @@ -614,12 +616,12 @@ sub setup_categories_and_councils : Private { ); $category_label = _('Property type:'); - } elsif ($first_council->{id} != 2482 && $first_council->{type} eq 'LBO') { + } elsif ($first_council->{id} != COUNCIL_ID_BROMLEY && $first_council->{type} eq 'LBO') { $area_ids_to_list{ $first_council->{id} } = 1; my @local_categories; if ($first_council->{id} == COUNCIL_ID_BARNET) { - @local_categories = sort(keys %{ Utils::barnet_categories() }); # removed 'Other' option + @local_categories = sort keys %{ Utils::barnet_categories() } } else { @local_categories = sort keys %{ Utils::london_categories() } } @@ -639,8 +641,6 @@ sub setup_categories_and_councils : Private { $area_ids_to_list{ $contact->area_id } = 1; - next if $contact->category eq _('Other'); - unless ( $seen{$contact->category} ) { push @category_options, $contact->category; @@ -651,9 +651,9 @@ sub setup_categories_and_councils : Private { } if (@category_options) { - @category_options = ( _('-- Pick a category --'), @category_options ); - push @category_options, _('Other') - unless $first_council->{id} == 2482; + # If there's an Other category present, put it at the bottom + @category_options = ( _('-- Pick a category --'), grep { $_ ne _('Other') } @category_options ); + push @category_options, _('Other') if $seen{_('Other')}; $category_label = _('Category'); } } @@ -664,7 +664,7 @@ sub setup_categories_and_councils : Private { $c->stash->{category_options} = \@category_options; $c->stash->{category_extras} = \%category_extras; $c->stash->{category_extras_json} = encode_json \%category_extras; - $c->stash->{extra_name_info} = $first_council->{id} == 2482 ? 1 : 0; + $c->stash->{extra_name_info} = $first_council->{id} == COUNCIL_ID_BROMLEY ? 1 : 0; my @missing_details_councils = grep { !$area_ids_to_list{$_} } # @@ -815,12 +815,12 @@ sub process_report : Private { } elsif ( $first_council->{id} == COUNCIL_ID_BARNET ) { - unless ( exists Utils::barnet_categories()->{ $report->category } or $report->category eq 'Other') { + unless ( exists Utils::barnet_categories()->{ $report->category } ) { $c->stash->{field_errors}->{category} = _('Please choose a category'); } $report->council( $first_council->{id} ); - } elsif ( $first_council->{id} != 2482 && $first_council->{type} eq 'LBO') { + } elsif ( $first_council->{id} != COUNCIL_ID_BROMLEY && $first_council->{type} eq 'LBO') { unless ( Utils::london_categories()->{ $report->category } ) { $c->stash->{field_errors}->{category} = _('Please choose a category'); @@ -896,7 +896,7 @@ sub process_report : Private { # save the cobrand and language related information $report->cobrand( $c->cobrand->moniker ); - $report->cobrand_data( $c->cobrand->extra_problem_data ); + $report->cobrand_data( '' ); $report->lang( $c->stash->{lang_code} ); return 1; @@ -1055,6 +1055,14 @@ sub generate_map : Private { return 1; } +sub check_for_category : Private { + my ( $self, $c ) = @_; + + $c->stash->{category} = $c->req->param('category'); + + return 1; +} + =head2 redirect_or_confirm_creation Now that the report has been created either redirect the user to its page if it @@ -1075,7 +1083,7 @@ sub redirect_or_confirm_creation : Private { if ( $c->cobrand->moniker eq 'fixmybarangay' && $c->user->from_council && $c->stash->{external_source_id}) { $report_uri = $c->uri_for( '/report', $report->id, undef, { external_source_id => $c->stash->{external_source_id} } ); } else { - $report_uri = $c->uri_for( '/report', $report->id ); + $report_uri = $c->cobrand->base_url_for_report( $report ) . $report->url; } $c->log->info($report->user->id . ' was logged in, redirecting to /report/' . $report->id); $c->res->redirect($report_uri); diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 3a2b40c2c..c49123a90 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -189,7 +189,7 @@ sub process_update : Private { mark_fixed => $params{fixed} ? 1 : 0, mark_open => $params{reopen} ? 1 : 0, cobrand => $c->cobrand->moniker, - cobrand_data => $c->cobrand->extra_update_data, + cobrand_data => '', lang => $c->stash->{lang_code}, anonymous => $anonymous, } @@ -348,7 +348,7 @@ sub redirect_or_confirm_creation : Private { if ( $update->confirmed ) { $c->forward( 'update_problem' ); $c->forward( 'signup_for_alerts' ); - my $report_uri = $c->uri_for( '/report', $update->problem_id ); + my $report_uri = $c->cobrand->base_url_for_report( $update->problem ) . $update->problem->url; $c->res->redirect($report_uri); $c->detach; } diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index c5f709054..37766db44 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -34,8 +34,8 @@ sub index : Path : Args(0) { # Fetch all areas of the types we're interested in my $areas_info; eval { - my @area_types = $c->cobrand->area_types; - $areas_info = mySociety::MaPit::call('areas', \@area_types, + my $area_types = $c->cobrand->area_types; + $areas_info = mySociety::MaPit::call('areas', $area_types, min_generation => $c->cobrand->area_min_generation ); }; @@ -57,6 +57,7 @@ sub index : Path : Args(0) { $c->stash->{areas_info} = $areas_info; my @keys = sort { strcoll($areas_info->{$a}{name}, $areas_info->{$b}{name}) } keys %$areas_info; + @keys = $c->cobrand->filter_all_council_ids_list( @keys ); $c->stash->{areas_info_sorted} = [ map { $areas_info->{$_} } @keys ]; eval { @@ -68,8 +69,11 @@ sub index : Path : Args(0) { $c->stash->{open} = $j->{open}; }; if ($@) { - $c->stash->{message} = _("There was a problem showing the All Reports page. Please try again later.") . ' ' . - sprintf(_('The error was: %s'), $@); + $c->stash->{message} = _("There was a problem showing the All Reports page. Please try again later."); + if ($c->config->{STAGING_SITE}) { + $c->stash->{message} .= '</p><p>Perhaps the bin/update-all-reports script needs running.</p><p>' + . sprintf(_('The error was: %s'), $@); + } $c->stash->{template} = 'errors/generic.html'; return; } @@ -126,6 +130,8 @@ sub ward : Path : Args(2) { any_zoom => 1, ); + $c->cobrand->tweak_all_reports_map( $c ); + # List of wards unless ($c->stash->{ward}) { my $children = mySociety::MaPit::call('area/children', [ $c->stash->{council}->{id} ], @@ -211,13 +217,6 @@ sub council_check : Private { $q_council =~ s/\+/ /g; $q_council =~ s/\.html//; - # Manual misspelling redirect - if ($q_council =~ /^rhondda cynon taff$/i) { - my $url = $c->uri_for( '/reports/rhondda+cynon+taf' ); - $c->res->redirect( $url ); - $c->detach(); - } - # Check cobrand specific incantations - e.g. ONS codes for UK, # Oslo/ kommunes sharing a name in Norway return if $c->cobrand->reports_council_check( $c, $q_council ); @@ -232,9 +231,9 @@ sub council_check : Private { } # We must now have a string to check - my @area_types = $c->cobrand->area_types; + my $area_types = $c->cobrand->area_types; my $areas = mySociety::MaPit::call( 'areas', $q_council, - type => \@area_types, + type => $area_types, min_generation => $c->cobrand->area_min_generation ); if (keys %$areas == 1) { @@ -351,7 +350,7 @@ sub load_and_group_problems : Private { { photo => 'photo is not null' }, ], order_by => { -desc => 'lastupdate' }, - rows => 100, + rows => $c->cobrand->reports_per_page, } )->page( $page ); $c->stash->{pager} = $problems->pager; diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm index 4d0b6cb93..fe4b652ed 100755 --- a/perllib/FixMyStreet/App/Controller/Rss.pm +++ b/perllib/FixMyStreet/App/Controller/Rss.pm @@ -172,7 +172,6 @@ sub generate : Private { $c->stash->{rss} = new XML::RSS( version => '2.0', encoding => 'UTF-8', - stylesheet => $c->cobrand->feed_xsl, encode_output => undef ); $c->stash->{rss}->add_module( @@ -205,14 +204,10 @@ sub query_main : Private { my ( $self, $c ) = @_; my $alert_type = $c->stash->{alert_type}; - my ( $site_restriction, $site_id ) = $c->cobrand->site_restriction( $c->cobrand->extra_data ); - # Only apply a site restriction if the alert uses the problem table - $site_restriction = '' unless $alert_type->item_table eq 'problem'; - # FIXME Do this in a nicer way at some point in the future... my $query = 'select * from ' . $alert_type->item_table . ' where ' . ($alert_type->head_table ? $alert_type->head_table . '_id=? and ' : '') - . $alert_type->item_where . $site_restriction . ' order by ' + . $alert_type->item_where . ' order by ' . $alert_type->item_order; my $rss_limit = mySociety::Config::get('RSS_LIMIT'); $query .= " limit $rss_limit" unless $c->stash->{type} =~ /^all/; @@ -250,12 +245,13 @@ sub add_row : Private { (my $title = _($alert_type->item_title)) =~ s/{{(.*?)}}/$row->{$1}/g; (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 $hashref_restriction = $c->cobrand->site_restriction; + my $base_url = $c->cobrand->base_url; + if ( $hashref_restriction && $hashref_restriction->{council} && $row->{council} && $row->{council} ne $hashref_restriction->{council} ) { + $base_url = $c->config->{BASE_URL}; } + my $url = $base_url . $link; my %item = ( title => ent($title), @@ -268,7 +264,7 @@ sub add_row : Private { if ($c->cobrand->allow_photo_display && $row->{photo}) { my $key = $alert_type->item_table eq 'comment' ? 'c/' : ''; - $item{description} .= ent("\n<br><img src=\"". $c->cobrand->base_url . "/photo/$key$row->{id}.jpeg\">"); + $item{description} .= ent("\n<br><img src=\"". $base_url . "/photo/$key$row->{id}.jpeg\">"); } if ( $row->{used_map} ) { diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 1434838f2..03dc69b00 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -34,7 +34,8 @@ sub confirm_problem : Path('/P') { # Load the problem my $data = $auth_token->data; my $problem_id = ref $data ? $data->{id} : $data; - my $problem = $c->cobrand->problems->find( { id => $problem_id } ) + # Look at all problems, not just cobrand, in case am approving something we don't actually show + my $problem = $c->model('DB::Problem')->find( { id => $problem_id } ) || $c->detach('token_error'); $c->stash->{problem} = $problem; @@ -78,7 +79,7 @@ sub confirm_problem : Path('/P') { $c->set_session_cookie_expire(0); if ( FixMyStreet::DB::Result::Problem->visible_states()->{$old_state} ) { - my $report_uri = $c->uri_for( '/report', $problem->id ); + my $report_uri = $c->cobrand->base_url_for_report( $problem ) . $problem->url; $c->res->redirect($report_uri); } diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index 092e362f9..eac194dff 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -83,14 +83,12 @@ sub tprintf { [% display_crosssell_advert( email, name ) %] -Displays a crosssell advert if permitted by the cobrand. +Displays a crosssell advert (will be fixmystreet cobrand only). =cut sub display_crosssell_advert { my ( $self, $c, $email, $name, %data ) = @_; - - return unless $c->cobrand->allow_crosssell_adverts(); return CrossSell::display_advert( $c, $email, $name, %data ); } |