diff options
author | Jon Kristensen <info@jonkri.com> | 2014-05-15 17:41:07 +0200 |
---|---|---|
committer | Jon Kristensen <info@jonkri.com> | 2014-05-15 17:41:07 +0200 |
commit | d6ab834a8e1fb67800785eb781e4f9ecc2e39a5c (patch) | |
tree | 57330eaed413dd8a200e2d49b1deb91b69dad79f /perllib | |
parent | 87b7c87e1cf83ba043a0254008248595363906c1 (diff) | |
parent | 966a1a754d7f4f055944212c5523798a7795402f (diff) |
Merge branch 'master' of git://github.com/mysociety/fixmystreet into jonkri-master
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/CrossSell.pm | 26 | ||||
-rw-r--r-- | perllib/FixMyStreet/App.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 11 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 25 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 18 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Problem.pm | 2 | ||||
-rw-r--r-- | perllib/Utils.pm | 4 |
13 files changed, 86 insertions, 28 deletions
diff --git a/perllib/CrossSell.pm b/perllib/CrossSell.pm index ca4eebdb3..f9bb73d6a 100644 --- a/perllib/CrossSell.pm +++ b/perllib/CrossSell.pm @@ -161,6 +161,30 @@ for campaigns too. EOF } +sub display_app_links { + return <<EOF; +<h1 style="padding-top:0.5em">New! FixMyStreet Apps for Apple and Android</h1> +<p> +We've built all-new FixMyStreet phone apps, for your use. Key +improvements include offline reporting (for where there is bad signal) +and a better interface for adding problem reports more quickly and +easily. Please give the apps a go and tell us what you think. +</p> + +<p> +<a href="https://play.google.com/store/apps/details?id=org.mysociety.FixMyStreet"> + <img alt="FixMyStreet Android app on Google Play" + src="/cobrands/fixmystreet/images/google_play_logo.png" /> +</a> + +<a href="https://itunes.apple.com/gb/app/fixmystreet/id297456545"> + <img alt="FixMyStreet app on the App Store" + src="/cobrands/fixmystreet/images/itunes_store_logo.png" /> +</a><br> +</p> +EOF +} + # Not currently used, needs more explanation and testing; perhaps in future. sub display_gny_groups { my ($lon, $lat) = @_; @@ -222,7 +246,7 @@ sub display_advert ($$;$%) { #unless (defined $data{done_tms} && $data{done_tms}==1) { $c->stash->{scratch} = 'advert=wtt'; return '<div style="margin: 0 5em; border-top: dotted 1px #666666;">' - . display_wtt_link() + . display_app_links() . '</div>'; $c->stash->{scratch} = 'advert=news'; diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 1664f0f30..13617a3c0 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -95,6 +95,7 @@ __PACKAGE__->setup(); 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'; }; # set up DB handle for old code diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 9c0018f38..cfe165f43 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -774,7 +774,8 @@ sub report_edit : Path('report_edit') : Args(1) { if ( $c->req->param('remove_photo') ) { $problem->photo(undef); } - if ( $new_state eq 'hidden' ) { + + if ( $c->req->param('remove_photo') || $new_state eq 'hidden' ) { unlink glob FixMyStreet->path_to( 'web', 'photo', $problem->id . '.*' ); } @@ -916,6 +917,10 @@ sub update_edit : Path('update_edit') : Args(1) { $update->photo(undef); } + if ( $c->req->param('remove_photo') || $new_state eq 'hidden' ) { + unlink glob FixMyStreet->path_to( 'web', 'photo', 'c', $update->id . '.*' ); + } + $update->name( $c->req->param('name') || '' ); $update->text( $c->req->param('text') ); $update->anonymous( $c->req->param('anonymous') ); @@ -939,10 +944,6 @@ sub update_edit : Path('update_edit') : Args(1) { } } - if ( $new_state eq 'hidden' ) { - unlink glob FixMyStreet->path_to( 'web', 'photo', 'c', $update->id . '.*' ); - } - $update->update; $c->stash->{status_message} = '<p><em>' . _('Updated!') . '</em></p>'; diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index 7ba18ed2d..6bc6e90ef 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -108,6 +108,11 @@ sub validate : Private { if !mySociety::EmailUtil::is_valid_email( $c->req->param('em') ); } + %field_errors = ( + %field_errors, + $c->cobrand->extra_contact_validation($c) + ); + push @errors, _('Illegal ID') if $c->req->param('id') && $c->req->param('id') !~ /^[1-9]\d*$/ or $c->req->param('update_id') diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index b5f65d8c8..25c6e1923 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -195,7 +195,7 @@ sub export_as_csv { (defined $value and length $value) ? ($_, $value) : () } sort keys %where }; - my $csv = Text::CSV->new(); + my $csv = Text::CSV->new({ binary => 1, eol => "\n" }); $csv->combine( 'Report ID', 'Title', @@ -264,7 +264,7 @@ sub export_as_csv { } $c->res->content_type('text/csv; charset=utf-8'); $c->res->header('content-disposition' => "attachment; filename=${filename}.csv"); - $c->res->body( join "\n", @body ); + $c->res->body( join "", @body ); } sub updates_search : Private { diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 081256fe2..13a347a90 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -167,6 +167,9 @@ sub format_problem_for_display : Private { } $c->stash->{extra_name_info} = $problem->bodies_str && $problem->bodies_str eq '2482' ? 1 : 0; + if ( $c->sessionid && $c->flash->{created_report} ) { + $c->stash->{created_report} = $c->flash->{created_report}; + } $c->forward('generate_map_tags'); diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 761215344..1e9f83aec 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -624,15 +624,13 @@ sub setup_categories_and_bodies : Private { _('Empty public building - school, hospital, etc.') ); - } elsif ($first_area->{id} != COUNCIL_ID_BROMLEY && $first_area->{type} eq 'LBO') { + } elsif ($first_area->{id} != COUNCIL_ID_BROMLEY + && $first_area->{id} != COUNCIL_ID_BARNET + && $first_area->{type} eq 'LBO') { $bodies_to_list{ $first_body->id } = 1; my @local_categories; - if ($first_area->{id} == COUNCIL_ID_BARNET) { - @local_categories = sort keys %{ Utils::barnet_categories() } - } else { - @local_categories = sort keys %{ Utils::london_categories() } - } + @local_categories = sort keys %{ Utils::london_categories() }; @category_options = ( _('-- Pick a category --'), @local_categories @@ -853,15 +851,10 @@ sub process_report : Private { $report->extra( \%extra ); } - } elsif ( $first_area->{id} == COUNCIL_ID_BARNET ) { + } elsif ($first_area->{id} != COUNCIL_ID_BROMLEY + && $first_area->{id} != COUNCIL_ID_BARNET + && $first_area->{type} eq 'LBO') { - unless ( exists Utils::barnet_categories()->{ $report->category } ) { - $c->stash->{field_errors}->{category} = _('Please choose a category'); - } - $report->bodies_str( $first_body->id ); - - } elsif ( $first_area->{id} != COUNCIL_ID_BROMLEY && $first_area->{type} eq 'LBO') { - unless ( Utils::london_categories()->{ $report->category } ) { $c->stash->{field_errors}->{category} = _('Please choose a category'); } @@ -1155,7 +1148,9 @@ sub redirect_or_confirm_creation : Private { $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->flash->{created_report} = 'loggedin'; + if ( $c->sessionid ) { + $c->flash->{created_report} = 'loggedin'; + } $c->res->redirect($report_uri); $c->detach; } diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 19130e25f..44cb2429d 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -102,7 +102,7 @@ sub confirm_problem : Path('/P') { $c->res->redirect($report_uri); } - $c->flash->{created_report} = 'fromemail'; + $c->stash->{created_report} = 'fromemail'; return 1; } diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index d2af4949e..c8bae90e6 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -854,6 +854,14 @@ sub prettify_dt { return Utils::prettify_dt( $dt, 1 ); } +=head2 extra_contact_validation + +Perform any extra validation on the contact form. + +=cut + +sub extra_contact_validation { (); } + sub problem_as_hashref { my $self = shift; my $problem = shift; diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index c3a1f9d9d..ce62e206e 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -21,5 +21,23 @@ sub title_list { return undef; } +sub extra_contact_validation { + my $self = shift; + my $c = shift; + + my %errors; + + $c->stash->{dest} = $c->req->param('dest'); + + $errors{dest} = "Please enter who your message is for" + unless $c->req->param('dest'); + + if ( $c->req->param('dest') eq 'council' || $c->req->param('dest') eq 'update' ) { + $errors{not_for_us} = 1; + } + + return %errors; +} + 1; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 7b5460c51..3463ebab6 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -623,11 +623,10 @@ sub body { # Note: this only makes sense when called on a problem that has been sent! sub can_display_external_id { my $self = shift; - if ($self->external_id && $self->send_method_used && - ($self->send_method_used eq 'barnet' || $self->bodies_str =~ /2237/)) { + if ($self->external_id && $self->bodies_str =~ /2237/) { return 1; } - return 0; + return 0; } # TODO Some/much of this could be moved to the template diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 5499af474..c108f7e29 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -376,6 +376,8 @@ sub send_reports { if ( $row->subcategory ) { $h{subcategory_line} = sprintf(_("Subcategory: %s"), $row->subcategory) . "\n\n"; + } else { + $h{subcategory_line} = "\n\n"; } $h{bodies_name} = join(_(' and '), @dear); diff --git a/perllib/Utils.pm b/perllib/Utils.pm index 27d604a59..7a22c888d 100644 --- a/perllib/Utils.pm +++ b/perllib/Utils.pm @@ -123,7 +123,9 @@ sub london_categories { } sub barnet_categories { - # The values here are KBIDs from Barnet's system: see bin/send-reports for formatting + # The values here are KBIDs from Barnet's system: see bin/send-reports for formatting. + # They are no longer used since Barnet switched to email for delivery of problem reports. + # and can be removed when SendReport/Barnet.pm is removed. if (mySociety::Config::get('STAGING_SITE')) { # note staging site must use different KBIDs return { 'Street scene misc' => 14 # for test |