diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Council.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Location.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/ZeroTB.pm | 61 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/AlertType.pm | 22 |
6 files changed, 106 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm index 5d95c2538..ceec04027 100644 --- a/perllib/FixMyStreet/App/Controller/Council.pm +++ b/perllib/FixMyStreet/App/Controller/Council.pm @@ -69,6 +69,7 @@ sub load_and_check_areas : Private { type => $area_types ); } if ($all_areas->{error}) { + $c->stash->{location_error_mapit_error} = 1; $c->stash->{location_error} = $all_areas->{error}; return; } @@ -78,6 +79,7 @@ sub load_and_check_areas : Private { $c->cobrand->area_check( { all_areas => $all_areas }, $c->stash->{area_check_action} ); if ( !$success ) { + $c->stash->{location_error_cobrand_check} = 1; $c->stash->{location_error} = $error_msg; return; } @@ -87,6 +89,7 @@ sub load_and_check_areas : Private { # If we don't have any areas we can't accept the report if ( !scalar keys %$all_areas ) { + $c->stash->{location_error_no_areas} = 1; $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 f103ff7f9..4312b6911 100644 --- a/perllib/FixMyStreet/App/Controller/Location.pm +++ b/perllib/FixMyStreet/App/Controller/Location.pm @@ -103,6 +103,7 @@ sub determine_location_from_pc : Private { } # pass errors back to the template + $c->stash->{location_error_pc_lookup} = 1; $c->stash->{location_error} = $error; return; } diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index dbfd57e78..bc79cafd3 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -312,7 +312,14 @@ sub save_update : Private { my $update = $c->stash->{update}; - if ( !$update->user->in_storage ) { + if ( $c->cobrand->never_confirm_updates ) { + if ( $update->user->in_storage() ) { + $update->user->update(); + } else { + $update->user->insert(); + } + $update->confirm(); + } elsif ( !$update->user->in_storage ) { # User does not exist. # Store changes in token for when token is validated. $c->stash->{token_data} = { @@ -370,6 +377,7 @@ sub redirect_or_confirm_creation : Private { $c->forward( 'signup_for_alerts' ); my $report_uri = $c->cobrand->base_url_for_report( $update->problem ) . $update->problem->url; + $c->flash->{comment_created} = 1; $c->res->redirect($report_uri); $c->detach; } diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 2de3eae5f..d2af4949e 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -829,6 +829,16 @@ sub show_unconfirmed_reports { 0; } +=head2 never_confirm_updates + +If true then we never send an email to confirm an update + +=cut + +sub never_confirm_updates { 0; } + +sub include_time_in_update_alerts { 0; } + =head2 prettify_dt my $date = $c->prettify_dt( $datetime ); diff --git a/perllib/FixMyStreet/Cobrand/ZeroTB.pm b/perllib/FixMyStreet/Cobrand/ZeroTB.pm new file mode 100644 index 000000000..087bf0912 --- /dev/null +++ b/perllib/FixMyStreet/Cobrand/ZeroTB.pm @@ -0,0 +1,61 @@ +package FixMyStreet::Cobrand::ZeroTB; +use base 'FixMyStreet::Cobrand::Default'; + +use strict; +use warnings; + +sub site_title { return 'ZeroTB'; } + +sub enter_postcode_text { return _ ('Enter a nearby street name and area, postal code or district in Delhi'); } + +sub country { + return 'IN'; +} + +sub languages { [ 'en-gb,English,en_GB' ] } +sub language_override { 'en-gb' } + +sub disambiguate_location { + return { + country => 'in', + town => 'Delhi', + bounds => [ 28.404625000000024, 76.838845800000072, 28.884380600000028, 77.347877500000067 ], + }; +} + +sub only_authed_can_create { return 1; } +sub allow_photo_display { return 0; } +sub allow_photo_upload{ return 0; } +sub send_questionnaires { return 0; } +sub on_map_default_max_pin_age { return 0; } +sub never_confirm_updates { 1; } +sub include_time_in_update_alerts { 1; } + +sub pin_colour { + return 'clinic'; +} + +sub path_to_pin_icons { + return '/cobrands/zerotb/images/'; +} + +sub get_clinic_list { + my $self = shift; + + return $self->problems->search({ state => 'confirmed' }, { order_by => 'title' }); +} + +sub prettify_dt { + my ( $self, $dt, $type ) = @_; + $type ||= ''; + + if ( $type eq 'alert' ) { + return $dt->strftime('%H:%M %Y-%m-%d'); + } else { + return Utils::prettify_dt( $dt, $type ); + } + +} + +1; + diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm index 8e18832a9..545b54c60 100644 --- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm +++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm @@ -29,6 +29,7 @@ sub email_alerts ($) { $query .= " $item_table.id as item_id, $item_table.text as item_text, $item_table.name as item_name, $item_table.anonymous as item_anonymous, + $item_table.confirmed as item_confirmed, $head_table.* from alert inner join $item_table on alert.parameter::integer = $item_table.${head_table}_id @@ -114,6 +115,27 @@ sub email_alerts ($) { $data{problem_url} = $url . "/report/" . $row->{id}; } $data{data} .= $row->{item_name} . ' : ' if $row->{item_name} && !$row->{item_anonymous}; + if ( $cobrand->include_time_in_update_alerts ) { + # this is basically recreating the code from the inflate wrapper + # in the database model. + my $tz; + if ( FixMyStreet->config('TIME_ZONE') ) { + $tz = FixMyStreet->config('TIME_ZONE'); + } + + my $parser = DateTime::Format::Pg->new(); + my $dt = $parser->parse_timestamp( $row->{item_confirmed} ); + my $l_tz = DateTime::TimeZone->new( name => "local" ); + # We need to always set this otherwise we end up with the DateTime + # object being in the floating timezone in which case applying a + # subsequent timezone set will have no effect. + $dt->set_time_zone( $l_tz ); + if ( $tz ) { + my $tz_obj = DateTime::TimeZone->new( name => $tz ); + $dt->set_time_zone( $tz_obj ); + } + $data{data} .= $cobrand->prettify_dt( $dt, 'alert' ) . "\n\n"; + } $data{data} .= $row->{item_text} . "\n\n------\n\n"; # this is ward and council problems } else { |