From 8d81147d1f757e70393e08947c0be1b73ebfb3ae Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 11 Mar 2014 15:10:30 +0000 Subject: cobrand file with geocoder etc config also, make readonly, disable photos, questionnaires, never hide old pins Fixes #701 --- perllib/FixMyStreet/Cobrand/ZeroTB.pm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 perllib/FixMyStreet/Cobrand/ZeroTB.pm (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/ZeroTB.pm b/perllib/FixMyStreet/Cobrand/ZeroTB.pm new file mode 100644 index 000000000..bd25b6076 --- /dev/null +++ b/perllib/FixMyStreet/Cobrand/ZeroTB.pm @@ -0,0 +1,31 @@ +package FixMyStreet::Cobrand::ZeroTB; +use base 'FixMyStreet::Cobrand::Default'; + +use strict; +use warnings; + +sub site_title { return 'ZeroTB'; } + +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; } + +1; + -- cgit v1.2.3 From 21bf819455562ab75874b230af82affd0138400c Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 14 Mar 2014 14:53:07 +0000 Subject: change text of location search instructions --- perllib/FixMyStreet/Cobrand/ZeroTB.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/ZeroTB.pm b/perllib/FixMyStreet/Cobrand/ZeroTB.pm index bd25b6076..589a9e922 100644 --- a/perllib/FixMyStreet/Cobrand/ZeroTB.pm +++ b/perllib/FixMyStreet/Cobrand/ZeroTB.pm @@ -6,6 +6,8 @@ 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'; } -- cgit v1.2.3 From f0c1e25cd4774996d6e523bdad73ae3d8f6cabae Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 19 Mar 2014 12:26:18 +0000 Subject: Allow comments to be confirmed with no confirmation Add never_confirm_updates setting to cobrand that, when set to 0 means that comments are confirmed with no confirmation step. Essentially behaves as it would if the user was logged in. Also add a flag to the flash that indicates the comment was accepted to you can display a message on the report page if required --- perllib/FixMyStreet/App/Controller/Report/Update.pm | 10 +++++++++- perllib/FixMyStreet/Cobrand/Default.pm | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') 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..60ed216d7 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -829,6 +829,14 @@ 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; } + =head2 prettify_dt my $date = $c->prettify_dt( $datetime ); -- cgit v1.2.3 From 90bf8d40800452046b4b89e80e2af64ee65872bc Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 19 Mar 2014 12:29:34 +0000 Subject: turn on never_confirm_updates for ZeroTB and display a message on the report page to indicate the update has been sent as it's never displayed --- perllib/FixMyStreet/Cobrand/ZeroTB.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/ZeroTB.pm b/perllib/FixMyStreet/Cobrand/ZeroTB.pm index 589a9e922..a63a451cc 100644 --- a/perllib/FixMyStreet/Cobrand/ZeroTB.pm +++ b/perllib/FixMyStreet/Cobrand/ZeroTB.pm @@ -28,6 +28,7 @@ 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; } 1; -- cgit v1.2.3 From b20cb6576485017970f025e6f294ac8c09f39e69 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 20 Mar 2014 17:27:00 +0000 Subject: Add a searchable dropdown of clinic names to postcode form uses select2 for the dropdown and a cobrand call to fetch the list of report titles as the clinic names. Relies on a redirect in httpd.conf to make the non JS version work. Still leaves the postcode search in place as select2 won't accept custom terms if you base it on a select box, which we want to do so it works if JavaScript is disabled Fixes #723 --- perllib/FixMyStreet/Cobrand/ZeroTB.pm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/ZeroTB.pm b/perllib/FixMyStreet/Cobrand/ZeroTB.pm index a63a451cc..c774610c4 100644 --- a/perllib/FixMyStreet/Cobrand/ZeroTB.pm +++ b/perllib/FixMyStreet/Cobrand/ZeroTB.pm @@ -30,5 +30,11 @@ sub send_questionnaires { return 0; } sub on_map_default_max_pin_age { return 0; } sub never_confirm_updates { 1; } +sub get_clinic_list { + my $self = shift; + + return $self->problems->search({ state => 'confirmed' }, { order_by => 'title' }); +} + 1; -- cgit v1.2.3 From 5c871b7093ac2fd137b980979bb210cc1cad59a7 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 21 Mar 2014 17:30:07 +0000 Subject: Add Cobrand config to include update date in email alerts This is useful for sites where the updates aren't published on the site so you need a bit more context in the email alerts. Add inlude_time_in_update_alerts to default cobrand, off as default If this is set then the date is added after the name string in the email, passing in 'alert' as the type to dt_prettify in order to allow the cobrand to format it accordingly. This does require pulling out the alert confirmed time from the database in the send_alerts code where it wasn't before. --- perllib/FixMyStreet/Cobrand/Default.pm | 2 ++ perllib/FixMyStreet/DB/ResultSet/AlertType.pm | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 60ed216d7..d2af4949e 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -837,6 +837,8 @@ If true then we never send an email to confirm an update 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/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 { -- cgit v1.2.3 From ee474f3340c02bc1b9e75accf303e16257d86882 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 21 Mar 2014 17:34:57 +0000 Subject: Changes to alert-update formatting for ZeroTB Include date in alerts Remove everything apart from the update text as we don't need it --- perllib/FixMyStreet/Cobrand/ZeroTB.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/ZeroTB.pm b/perllib/FixMyStreet/Cobrand/ZeroTB.pm index c774610c4..32d14d0f6 100644 --- a/perllib/FixMyStreet/Cobrand/ZeroTB.pm +++ b/perllib/FixMyStreet/Cobrand/ZeroTB.pm @@ -29,6 +29,7 @@ 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 get_clinic_list { my $self = shift; @@ -36,5 +37,17 @@ sub get_clinic_list { 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; -- cgit v1.2.3 From ecd7e9c67f8cce7b3c080c843066fe9aa822e457 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 26 Mar 2014 11:59:05 +0000 Subject: replace default pins with clinic logo add files and change config in cobrand --- perllib/FixMyStreet/Cobrand/ZeroTB.pm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/ZeroTB.pm b/perllib/FixMyStreet/Cobrand/ZeroTB.pm index 32d14d0f6..087bf0912 100644 --- a/perllib/FixMyStreet/Cobrand/ZeroTB.pm +++ b/perllib/FixMyStreet/Cobrand/ZeroTB.pm @@ -31,6 +31,14 @@ 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; -- cgit v1.2.3 From ac7443809e921594c2a5682c49ddf388cdb2598f Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 26 Mar 2014 18:01:55 +0000 Subject: Use flags to indicate type of location error This makes it a bit easier to override the message in templates which makes it a bit easier for cobrands. Leaves the default error message in location_error stash key which should prevent any existing logic breaking. --- perllib/FixMyStreet/App/Controller/Council.pm | 3 +++ perllib/FixMyStreet/App/Controller/Location.pm | 1 + 2 files changed, 4 insertions(+) (limited to 'perllib/FixMyStreet') 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; } -- cgit v1.2.3