From 485ac883cd1e119aeca2cbe77e5f02828496c28d Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 30 Aug 2013 19:31:24 +0100 Subject: Changed hardcoded URL in Problem.pm to be using variable from general.yml instead. --- perllib/FixMyStreet/DB/ResultSet/Problem.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 07848d782..97d457297 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -464,7 +464,8 @@ sub send_reports { send_fail_count => { '>', 0 } } ); while (my $row = $unsent->next) { - $sending_errors .= "* http://www.fixmystreet.com/report/" . $row->id . ", failed " + my $base_url = mySociety::Config::get('BASE_URL'); + $sending_errors .= "* " . $base_url . "/report/" . $row->id . ", failed " . $row->send_fail_count . " times, last at " . $row->send_fail_timestamp . ", reason " . $row->send_fail_reason . "\n"; } -- cgit v1.2.3 From 6053521d9c977f1414d1254e56415514795eb7a7 Mon Sep 17 00:00:00 2001 From: Jonas Oberg Date: Tue, 9 Apr 2013 07:04:38 +0000 Subject: Updated MapQuest links per instructions --- perllib/FixMyStreet/Map/OSM/MapQuest.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Map/OSM/MapQuest.pm b/perllib/FixMyStreet/Map/OSM/MapQuest.pm index 4751679f5..ff314a4da 100644 --- a/perllib/FixMyStreet/Map/OSM/MapQuest.pm +++ b/perllib/FixMyStreet/Map/OSM/MapQuest.pm @@ -28,7 +28,7 @@ sub map_tiles { } sub base_tile_url { - return 'mqcdn.com/tiles/1.0.0/osm/'; + return 'mqcdn.com/tiles/1.0.0/map/'; } 1; -- cgit v1.2.3 From 924ec5ee474b731caaceb384034f478277c6a21c Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Tue, 3 Sep 2013 15:44:00 +0100 Subject: [Zurich] Only super user can edit bodies --- perllib/FixMyStreet/App/Controller/Admin.pm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index e2547019b..e0ba80af6 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -296,6 +296,7 @@ sub body : Path('body') : Args(1) { $c->stash->{body_id} = $body_id; + $c->forward( 'check_for_super_user' ); $c->forward( 'get_token' ); $c->forward( 'lookup_body' ); $c->forward( 'fetch_all_bodies' ); @@ -311,6 +312,13 @@ sub body : Path('body') : Args(1) { return 1; } +sub check_for_super_user : Private { + my ( $self, $c ) = @_; + if ( $c->cobrand->moniker eq 'zurich' && $c->stash->{admin_type} ne 'super' ) { + $c->detach('/page_error_404_not_found', []); + } +} + sub update_contacts : Private { my ( $self, $c ) = @_; -- cgit v1.2.3 From 18d916c30374bff64c0ce56c613210b93d301acc Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Wed, 4 Sep 2013 16:32:52 +0100 Subject: [Zurich] Ensure only superusers can add/edit bodies --- perllib/FixMyStreet/App/Controller/Admin.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index e0ba80af6..133c83024 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -234,6 +234,7 @@ sub bodies : Path('bodies') : Args(0) { my $posted = $c->req->param('posted') || ''; if ( $posted eq 'body' ) { + $c->forward('check_for_super_user'); $c->forward('check_token'); my $params = $c->forward('body_params'); @@ -385,6 +386,7 @@ sub update_contacts : Private { $c->stash->{updated} = _('Values updated'); } elsif ( $posted eq 'body' ) { + $c->forward('check_for_super_user'); $c->forward('check_token'); my $params = $c->forward( 'body_params' ); -- cgit v1.2.3 From 12bf37ede6631a132f7b10e8e13017043786f422 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Wed, 4 Sep 2013 17:29:37 +0100 Subject: [Zurich] Make the phone number field required --- perllib/FixMyStreet/App/Controller/Report/New.pm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 3d3ddce1e..2c1c7e15a 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -956,6 +956,9 @@ sub check_for_errors : Private { delete $field_errors{name}; my $report = $c->stash->{report}; $report->title( Utils::cleanup_text( substr($report->detail, 0, 25) ) ); + if ( ! $c->req->param('phone') ) { + $field_errors{phone} = "This field is required."; + } } # FIXME: need to check for required bromley fields here -- cgit v1.2.3 From d97283bf7b22fb00faa4c8b36a6b477192308fdb Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Thu, 5 Sep 2013 10:00:17 +0100 Subject: Use format_datetime for DBIx::Class searches to get rid of warnings when running test suite --- perllib/FixMyStreet/App/Controller/JSON.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm index 1a7c1915b..17507a84b 100644 --- a/perllib/FixMyStreet/App/Controller/JSON.pm +++ b/perllib/FixMyStreet/App/Controller/JSON.pm @@ -8,6 +8,7 @@ use JSON; use DateTime; use DateTime::Format::ISO8601; use List::MoreUtils 'uniq'; +use FixMyStreet::App; =head1 NAME @@ -80,11 +81,13 @@ sub problems : Local { $date_col = 'lastupdate'; } + my $dt_parser = FixMyStreet::App->model('DB')->schema->storage->datetime_parser; + my $one_day = DateTime::Duration->new( days => 1 ); my $query = { $date_col => { - '>=' => $start_dt, - '<=' => $end_dt + $one_day, + '>=' => $dt_parser->format_datetime($start_dt), + '<=' => $dt_parser->format_datetime($end_dt + $one_day), }, state => [ @state ], }; -- cgit v1.2.3 From 7ae561917867bc4b3cc711108c053537f306d4a5 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Thu, 5 Sep 2013 13:38:43 +0100 Subject: [Zurich] Localise phone error message --- perllib/FixMyStreet/App/Controller/Report/New.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 2c1c7e15a..6018dfa80 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -957,7 +957,7 @@ sub check_for_errors : Private { my $report = $c->stash->{report}; $report->title( Utils::cleanup_text( substr($report->detail, 0, 25) ) ); if ( ! $c->req->param('phone') ) { - $field_errors{phone} = "This field is required."; + $field_errors{phone} = _("This information is required"); } } -- cgit v1.2.3 From dbd5376d42beb4744e9e9e2a020f878a2821b00b Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 5 Sep 2013 15:43:06 +0100 Subject: Spell out all "marked as %s" strings. As doing interpolation from a database state field is not great for translation. Fixes #391. --- perllib/FixMyStreet/DB/Result/Comment.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index eb9e52a65..c747f7fc1 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -179,8 +179,8 @@ sub get_photo_params { =head2 meta_problem_state -Returns a string suitable for display in the update meta section. -Mostly removes the '- council/user' bit from fixed states +Returns a string suitable for display lookup in the update meta section. +Removes the '- council/user' bit from fixed states. =cut @@ -190,10 +190,6 @@ sub meta_problem_state { my $state = $self->problem_state; $state =~ s/ -.*$//; - $state = _("not the council's responsibility") - if $state eq 'not responsible'; - $state = _('duplicate report') if $state eq 'duplicate'; - return $state; } -- cgit v1.2.3 From eed261eaa1ac36e86b9f621d999e72f083f9c3da Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 4 Sep 2013 11:08:15 +0100 Subject: switch Fixmindelo to pt_CV locale --- perllib/FixMyStreet/Cobrand/FixMindelo.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/FixMindelo.pm b/perllib/FixMyStreet/Cobrand/FixMindelo.pm index 6f81bad84..7ba93ac3b 100644 --- a/perllib/FixMyStreet/Cobrand/FixMindelo.pm +++ b/perllib/FixMyStreet/Cobrand/FixMindelo.pm @@ -4,11 +4,12 @@ use base 'FixMyStreet::Cobrand::Default'; use strict; use warnings; - sub country { return 'CV'; } +sub languages { [ 'pt-cv,Portuguese,pt_CV', 'en-gb,English,en_GB' ] } +sub language_override { 'pt-cv' } sub language_domain { 'FixMindelo' } sub disambiguate_location { -- cgit v1.2.3 From c8bf5e635e62fc45aa074f87278cef9e1d89696f Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 4 Sep 2013 14:27:49 +0100 Subject: remove Mindelo's language domain because we don't need it -- just using translation (pt_CV) file --- perllib/FixMyStreet/Cobrand/FixMindelo.pm | 1 - 1 file changed, 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/FixMindelo.pm b/perllib/FixMyStreet/Cobrand/FixMindelo.pm index 7ba93ac3b..59debf157 100644 --- a/perllib/FixMyStreet/Cobrand/FixMindelo.pm +++ b/perllib/FixMyStreet/Cobrand/FixMindelo.pm @@ -10,7 +10,6 @@ sub country { sub languages { [ 'pt-cv,Portuguese,pt_CV', 'en-gb,English,en_GB' ] } sub language_override { 'pt-cv' } -sub language_domain { 'FixMindelo' } sub disambiguate_location { return { -- cgit v1.2.3 From ea1ecdb43b879ce3355aa11167ae11f5f444bd65 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Sun, 4 Aug 2013 18:20:46 +0100 Subject: show "no bodies" hint on empty body db --- perllib/FixMyStreet/App/Controller/Admin.pm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 133c83024..69238f90f 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -130,6 +130,9 @@ sub index : Path : Args(0) { $c->stash->{categories} = $c->cobrand->problems->categories_summary(); + if ($c->config->{SHOW_ADMIN_HINTS}) { + $c->stash->{total_bodies} = $c->model('DB::Body')->count(); + } return 1; } -- cgit v1.2.3 From db265d6814d3a3ab05ad3eea7ae2442433db05b7 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 14 Aug 2013 16:10:02 +0100 Subject: remove SHOW_ADMIN_HINTS config admin hints are displayed *like it or not* (actually, could hide for a given cobrand with CSS setting display:none) --- perllib/FixMyStreet/App/Controller/Admin.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 69238f90f..5393e98bb 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -130,9 +130,8 @@ sub index : Path : Args(0) { $c->stash->{categories} = $c->cobrand->problems->categories_summary(); - if ($c->config->{SHOW_ADMIN_HINTS}) { - $c->stash->{total_bodies} = $c->model('DB::Body')->count(); - } + $c->stash->{total_bodies} = $c->model('DB::Body')->count(); + return 1; } -- cgit v1.2.3 From 404b8328ec8022513df39723112a2084be341e61 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Thu, 15 Aug 2013 08:17:57 +0100 Subject: show warning on body with no live contacts --- perllib/FixMyStreet/App/Controller/Admin.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 5393e98bb..5e98c5d04 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -432,6 +432,7 @@ sub display_contacts : Private { my $contacts = $c->stash->{body}->contacts->search(undef, { order_by => [ 'category' ] } ); $c->stash->{contacts} = $contacts; + $c->stash->{live_contacts} = $contacts->search({ deleted => 0 }); if ( $c->req->param('text') && $c->req->param('text') == 1 ) { $c->stash->{template} = 'admin/council_contacts.txt'; -- cgit v1.2.3 From 367fdaba0686150e841e879445ad2378f2f4d897 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Fri, 23 Aug 2013 08:32:49 +0100 Subject: clarify presentation on lagged users page now shows which flagged users are in abuse table, which seems important (separate issue #523 to make managing and indeed viewing abuse table) --- perllib/FixMyStreet/App/Controller/Admin.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 5e98c5d04..ba8f22a05 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -1027,8 +1027,20 @@ sub flagged : Path('flagged') : Args(0) { $c->stash->{problems} = [ $problems->all ]; my $users = $c->model('DB::User')->search( { flagged => 1 } ); + my @users = $users->all; + my %email2user = map { $_->email => $_ } @users; + $c->stash->{users} = [ @users ]; - $c->stash->{users} = $users; + my @abuser_emails = $c->model('DB::Abuse')->all(); + + foreach my $email (@abuser_emails) { + # Slight abuse of the boolean flagged value + if ($email2user{$email->email}) { + $email2user{$email->email}->flagged( 2 ); + } else { + push @{$c->stash->{users}}, { email => $email->email, flagged => 2 }; + } + } return 1; } -- cgit v1.2.3 From 3704a07ef4a94a7e20d01f9b5a9cdb8fcc449e89 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Fri, 6 Sep 2013 16:30:50 +0100 Subject: [Zurich] Add report state to admin stats csv --- perllib/FixMyStreet/Cobrand/Zurich.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index ffdc1feab..c74e41e10 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -592,10 +592,10 @@ sub admin_stats { ); if ( $c->req->params->{export} ) { - my $problems = $c->model('DB::Problem')->search( { %params }, { columns => [ 'id', 'created', 'latitude', 'longitude', 'cobrand', 'category' ] } ); - my $body = "ID,Created,E,N,Category\n"; + my $problems = $c->model('DB::Problem')->search( { %params }, { columns => [ 'id', 'created', 'latitude', 'longitude', 'cobrand', 'category', 'state' ] } ); + my $body = "ID,Created,E,N,Category,Status\n"; while (my $report = $problems->next) { - $body .= join( ',', $report->id, $report->created, $report->local_coords, $report->category ) . "\n"; + $body .= join( ',', $report->id, $report->created, $report->local_coords, $report->category, $report->state ) . "\n"; } $c->res->content_type('text/csv; charset=utf-8'); $c->res->body($body); -- cgit v1.2.3 From fd57174663e65d10fcb968d9ebd570ad119a80ad Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Fri, 6 Sep 2013 16:33:03 +0100 Subject: [Zurich] Add report user id to admin stats csv --- perllib/FixMyStreet/Cobrand/Zurich.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index c74e41e10..cd42bdf02 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -592,10 +592,10 @@ sub admin_stats { ); if ( $c->req->params->{export} ) { - my $problems = $c->model('DB::Problem')->search( { %params }, { columns => [ 'id', 'created', 'latitude', 'longitude', 'cobrand', 'category', 'state' ] } ); - my $body = "ID,Created,E,N,Category,Status\n"; + my $problems = $c->model('DB::Problem')->search( { %params }, { columns => [ 'id', 'created', 'latitude', 'longitude', 'cobrand', 'category', 'state', 'user_id' ] } ); + my $body = "ID,Created,E,N,Category,Status,UserID\n"; while (my $report = $problems->next) { - $body .= join( ',', $report->id, $report->created, $report->local_coords, $report->category, $report->state ) . "\n"; + $body .= join( ',', $report->id, $report->created, $report->local_coords, $report->category, $report->state, $report->user_id ) . "\n"; } $c->res->content_type('text/csv; charset=utf-8'); $c->res->body($body); -- cgit v1.2.3 From 7cef43f24a00b174a4f777df4fcff939950e7878 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Fri, 6 Sep 2013 16:54:27 +0100 Subject: [Zurich] Reformat long lines in csv export code --- perllib/FixMyStreet/Cobrand/Zurich.pm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index cd42bdf02..602b4281b 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -592,10 +592,22 @@ sub admin_stats { ); if ( $c->req->params->{export} ) { - my $problems = $c->model('DB::Problem')->search( { %params }, { columns => [ 'id', 'created', 'latitude', 'longitude', 'cobrand', 'category', 'state', 'user_id' ] } ); + my $problems = $c->model('DB::Problem')->search( + {%params}, + { + columns => [ + 'id', 'created', 'latitude', 'longitude', + 'cobrand', 'category', 'state', 'user_id' + ] + } + ); my $body = "ID,Created,E,N,Category,Status,UserID\n"; - while (my $report = $problems->next) { - $body .= join( ',', $report->id, $report->created, $report->local_coords, $report->category, $report->state, $report->user_id ) . "\n"; + while ( my $report = $problems->next ) { + $body .= join( ',', + $report->id, $report->created, + $report->local_coords, $report->category, + $report->state, $report->user_id ) + . "\n"; } $c->res->content_type('text/csv; charset=utf-8'); $c->res->body($body); -- cgit v1.2.3 From bdc37865f7826e76523a478219ea5abab918593a Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Mon, 9 Sep 2013 11:28:47 +0100 Subject: [Zurich] Add external body name to admin csv export --- perllib/FixMyStreet/Cobrand/Zurich.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 602b4281b..502748c90 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -596,17 +596,25 @@ sub admin_stats { {%params}, { columns => [ - 'id', 'created', 'latitude', 'longitude', - 'cobrand', 'category', 'state', 'user_id' + 'id', 'created', + 'latitude', 'longitude', + 'cobrand', 'category', + 'state', 'user_id', + 'external_body' ] } ); - my $body = "ID,Created,E,N,Category,Status,UserID\n"; + my $body = "ID,Created,E,N,Category,Status,UserID,External Body\n"; while ( my $report = $problems->next ) { + my $external_body; + my $body_name = ""; + if ( $external_body = $report->body($c) ) { + $body_name = $external_body->name; + } $body .= join( ',', - $report->id, $report->created, + $report->id, $report->created, $report->local_coords, $report->category, - $report->state, $report->user_id ) + $report->state, $report->user_id, $body_name ) . "\n"; } $c->res->content_type('text/csv; charset=utf-8'); -- cgit v1.2.3 From 196909405eb7725b52cb098364fc13d6a7591426 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Mon, 9 Sep 2013 18:11:59 +0100 Subject: [Zurich] Quote the external body name in csv --- perllib/FixMyStreet/Cobrand/Zurich.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 502748c90..7e1f64e8e 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -614,7 +614,7 @@ sub admin_stats { $body .= join( ',', $report->id, $report->created, $report->local_coords, $report->category, - $report->state, $report->user_id, $body_name ) + $report->state, $report->user_id, "\"$body_name\"" ) . "\n"; } $c->res->content_type('text/csv; charset=utf-8'); -- cgit v1.2.3 From 3644d6fce8d8e4a6f8aa2e8c5ec37faaa5cb8193 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Mon, 9 Sep 2013 18:12:21 +0100 Subject: [Zurich] Reformat admin csv code --- perllib/FixMyStreet/Cobrand/Zurich.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 7e1f64e8e..d39c804ad 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -612,9 +612,10 @@ sub admin_stats { $body_name = $external_body->name; } $body .= join( ',', - $report->id, $report->created, + $report->id, $report->created, $report->local_coords, $report->category, - $report->state, $report->user_id, "\"$body_name\"" ) + $report->state, $report->user_id, + "\"$body_name\"" ) . "\n"; } $c->res->content_type('text/csv; charset=utf-8'); -- cgit v1.2.3 From d3886845bf52bdb4af465e90a296b91ceb8b6500 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Tue, 10 Sep 2013 14:26:09 +0100 Subject: Add RABX column code and tests --- perllib/FixMyStreet/DB/RABXColumn.pm | 98 ++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 perllib/FixMyStreet/DB/RABXColumn.pm (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/DB/RABXColumn.pm b/perllib/FixMyStreet/DB/RABXColumn.pm new file mode 100644 index 000000000..5f1583018 --- /dev/null +++ b/perllib/FixMyStreet/DB/RABXColumn.pm @@ -0,0 +1,98 @@ +package FixMyStreet::DB::RABXColumn; + +use strict; +use warnings; + +use IO::String; +use RABX; + +=head1 NAME + +FixMyStreet::DB::RABXColumn + +=head2 DESCRIPTION + +This is a helper component that will setup the RABX serialisation for some +fields. This is useful for when you want to persist some data structure such as +hashrefs etc. + +This code will also change the default FilterColumn behaviour so that whenever +your set a column, or specify a RABX'd column in an ->update the value is saved +to the database. The default behaviour is to check if the value is already set, +and for hashrefs this means that changes to the contents are missed as it is +still the same hashref. + +By putting all this code in one place there is also much less repetition. + +=cut + +# Store which columns are RABX cols. +# $RABX_COLUMNS{$class}{$col} = 1 +my %RABX_COLUMNS = (); + +sub _get_class_identifier { + my $class = ref $_[0] || $_[0]; + $class =~ s/.*?(\w+)$/$1/; + return $class; +} + +=head1 METHODS + +=head2 rabx_column + + # In one of your ::Result:: modules + __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); + __PACKAGE__->rabx_column('data'); + +This sets up the filtering to and from the database, and also changes the +set_filtered_column behaviour to not trust the cache. + +=cut + +sub rabx_column { + my ($class, $col) = @_; + + # Apply the filtering for this column + $class->filter_column( + $col => { + filter_from_storage => sub { + my $self = shift; + my $ser = shift; + return undef unless defined $ser; + utf8::encode($ser) if utf8::is_utf8($ser); + my $h = new IO::String($ser); + return RABX::wire_rd($h); + }, + filter_to_storage => sub { + my $self = shift; + my $data = shift; + my $ser = ''; + my $h = new IO::String($ser); + RABX::wire_wr( $data, $h ); + return $ser; + }, + } + ); + + # store that this column is a RABX column. + $RABX_COLUMNS{ _get_class_identifier($class) }{$col} = 1; +} + + +sub set_filtered_column { + my ($self, $col, $val) = @_; + + my $class = ref $self; + + # because filtered objects may be expensive to marshall for storage there + # is a cache that attempts to detect if they have changed or not. For us + # this cache breaks things and our marshalling is cheap, so clear it when + # trying set a column. + delete $self->{_filtered_column}{$col} + if $RABX_COLUMNS{ _get_class_identifier($class) }{$col}; + + return $self->next::method($col, $val); +} + + +1; -- cgit v1.2.3 From affebc1ce59e850ccc50013bdcccc89c6846c89a Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Tue, 10 Sep 2013 14:26:48 +0100 Subject: Switch Token over to use RABXColumn and test that changes to the col behave as expected --- perllib/FixMyStreet/DB/Result/Token.pm | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/DB/Result/Token.pm b/perllib/FixMyStreet/DB/Result/Token.pm index 028300842..5525fe7a5 100644 --- a/perllib/FixMyStreet/DB/Result/Token.pm +++ b/perllib/FixMyStreet/DB/Result/Token.pm @@ -34,8 +34,6 @@ __PACKAGE__->set_primary_key("scope", "token"); # use mySociety::DBHandle qw(dbh); use mySociety::AuthToken; -use IO::String; -use RABX; =head1 NAME @@ -54,26 +52,9 @@ ms_current_timestamp. =cut -__PACKAGE__->filter_column( - data => { - filter_from_storage => sub { - my $self = shift; - my $ser = shift; - return undef unless defined $ser; - utf8::encode($ser) if utf8::is_utf8($ser); - my $h = new IO::String($ser); - return RABX::wire_rd($h); - }, - filter_to_storage => sub { - my $self = shift; - my $data = shift; - my $ser = ''; - my $h = new IO::String($ser); - RABX::wire_wr( $data, $h ); - return $ser; - }, - } -); +__PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); +__PACKAGE__->rabx_column('data'); + sub new { my ( $class, $attrs ) = @_; -- cgit v1.2.3 From 0f0c8e92fa4930a6a951b856bf86e8bbf322a008 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Tue, 10 Sep 2013 14:31:17 +0100 Subject: Use RABXColumn in remaining models that serialize some columns --- perllib/FixMyStreet/DB/Result/Comment.pm | 23 ++-------------- perllib/FixMyStreet/DB/Result/Contact.pm | 22 ++-------------- perllib/FixMyStreet/DB/Result/Problem.pm | 45 +++----------------------------- 3 files changed, 7 insertions(+), 83 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index c747f7fc1..d1626599e 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -85,32 +85,13 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-07-11 18:53:26 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tSejJzLxHD/fMWjpa10lfA -__PACKAGE__->filter_column( - extra => { - filter_from_storage => sub { - my $self = shift; - my $ser = shift; - return undef unless defined $ser; - utf8::encode($ser) if utf8::is_utf8($ser); - my $h = new IO::String($ser); - return RABX::wire_rd($h); - }, - filter_to_storage => sub { - my $self = shift; - my $data = shift; - my $ser = ''; - my $h = new IO::String($ser); - RABX::wire_wr( $data, $h ); - return $ser; - }, - } -); +__PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); +__PACKAGE__->rabx_column('extra'); use DateTime::TimeZone; use Image::Size; use Moose; use namespace::clean -except => [ 'meta' ]; -use RABX; with 'FixMyStreet::Roles::Abuser'; diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm index 551bcd019..5cbf335f1 100644 --- a/perllib/FixMyStreet/DB/Result/Contact.pm +++ b/perllib/FixMyStreet/DB/Result/Contact.pm @@ -60,25 +60,7 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-13 12:34:33 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:imXq3EtrC0FrQwj+E2xfBw -__PACKAGE__->filter_column( - extra => { - filter_from_storage => sub { - my $self = shift; - my $ser = shift; - return undef unless defined $ser; - utf8::encode($ser) if utf8::is_utf8($ser); - my $h = new IO::String($ser); - return RABX::wire_rd($h); - }, - filter_to_storage => sub { - my $self = shift; - my $data = shift; - my $ser = ''; - my $h = new IO::String($ser); - RABX::wire_wr( $data, $h ); - return $ser; - }, - } -); +__PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); +__PACKAGE__->rabx_column('extra'); 1; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index ec15600b6..6aa9695ce 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -135,54 +135,15 @@ __PACKAGE__->has_one( { cascade_copy => 0, cascade_delete => 0 }, ); -__PACKAGE__->filter_column( - extra => { - filter_from_storage => sub { - my $self = shift; - my $ser = shift; - return undef unless defined $ser; - utf8::encode($ser) if utf8::is_utf8($ser); - my $h = new IO::String($ser); - return RABX::wire_rd($h); - }, - filter_to_storage => sub { - my $self = shift; - my $data = shift; - my $ser = ''; - my $h = new IO::String($ser); - RABX::wire_wr( $data, $h ); - return $ser; - }, - } -); - -__PACKAGE__->filter_column( - geocode => { - filter_from_storage => sub { - my $self = shift; - my $ser = shift; - return undef unless defined $ser; - utf8::encode($ser) if utf8::is_utf8($ser); - my $h = new IO::String($ser); - return RABX::wire_rd($h); - }, - filter_to_storage => sub { - my $self = shift; - my $data = shift; - my $ser = ''; - my $h = new IO::String($ser); - RABX::wire_wr( $data, $h ); - return $ser; - }, - } -); +__PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); +__PACKAGE__->rabx_column('extra'); +__PACKAGE__->rabx_column('geocode'); use DateTime::TimeZone; use Image::Size; use Moose; use namespace::clean -except => [ 'meta' ]; use Utils; -use RABX; with 'FixMyStreet::Roles::Abuser'; -- cgit v1.2.3 From 2e4970688c9b48dbd4761587fd169fdb14b9af89 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Fri, 6 Sep 2013 17:11:27 +0100 Subject: Fix a bug in TestMech->log_in_ok that scrambeled the users password. --- perllib/FixMyStreet/TestMech.pm | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index e91c6a1d6..be8f004a5 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -87,8 +87,8 @@ sub log_in_ok { my $user = $mech->create_user_ok($email); - # store the old password and then change it - my $old_password = $user->password; + # remember the old password and then change it to a known one + my $old_password = $user->password || ''; $user->update( { password => 'secret' } ); # log in @@ -99,7 +99,19 @@ sub log_in_ok { $mech->logged_in_ok; # restore the password (if there was one) - $user->update( { password => $old_password } ) if $old_password; + if ($old_password) { + + # Use store_column and then make_column_dirty to bypass the filters that + # would hash the password, otherwise the password required ito log in + # would be the hash of the previous one. + $user->store_column("password", $old_password); + $user->make_column_dirty("password"); + $user->update(); + + # Belt and braces, check that the password has been correctly saved. + die "password not correctly restored after log_in_ok" + if $user->password ne $old_password; + } return $user; } @@ -296,7 +308,7 @@ sub extract_location { $meta = $mech->extract_problem_meta; -Returns the problem meta information ( submitted by, at etc ) from a +Returns the problem meta information ( submitted by, at etc ) from a problem report page =cut -- cgit v1.2.3 From 5357eeadf22d11684bae8c4e5b36afbba6415954 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Fri, 6 Sep 2013 17:12:11 +0100 Subject: Add notes to Zurich cobrand about setting up a dev environment. --- perllib/FixMyStreet/Cobrand/Zurich.pm | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index ffdc1feab..4cc02b932 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -8,6 +8,47 @@ use RABX; use strict; use warnings; +=head1 NAME + +Zurich FixMyStreet cobrand + +=head1 DESCRIPTION + +This module provides the specific functionality for the Zurich FMS cobrand. + +=head1 DEVELOPMENT NOTES + +The admin for Zurich is different to the other cobrands. To access it you need +to be logged in as a user associated with an appropriate body. + +You can create the bodies needed to develop by running the 't/cobrand/zurich.t' +test script with the three C<$mech->delete...> lines at the end commented out. +This should leave you with the bodies and users correctly set up. + +The entries will be something like this (but with different ids). + + Bodies: + id | name | parent | endpoint + ----+---------------+--------+--------------------------- + 1 | Zurich | | + 2 | Division 1 | 1 | division@example.org + 3 | Subdivision A | 2 | subdivision@example.org + 4 | External Body | | external_body@example.org + + Users: + id | email | from_body + ----+------------------+----------- + 2 | dm1@example.org | 2 + 3 | sdm1@example.org | 3 + +The passwords for the users is 'secret'. + +Note: the password hashes are salted with the user's id so cannot be easily +changed. High ids have been used so that it should not conflict with anything +you already have, and the countres set so that they shouldn't in future. + +=cut + sub shorten_recency_if_new_greater_than_fixed { return 0; } -- cgit v1.2.3 From bd0e4f640a265eaaab1a90d2a64c1f5db6f81e87 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Mon, 9 Sep 2013 15:45:04 +0100 Subject: [Zurich] Save internal notes as hidden comments, rather than in the extra field --- perllib/FixMyStreet/Cobrand/Zurich.pm | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 4cc02b932..a677837a9 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -397,19 +397,38 @@ sub admin_report_edit { } - # Problem updates upon submission + # If super or sdm check that the token is correct before proceeding if ( ($type eq 'super' || $type eq 'dm') && $c->req->param('submit') ) { $c->forward('check_token'); + } + + # All types of users can add internal notes + if ( ($type eq 'super' || $type eq 'dm' || $type eq 'sdm') && $c->req->param('submit') ) { + # If there is a new note add it as a comment to the problem (with is_internal_note set true in extra). + if ( my $new_internal_note = $c->req->params->{new_internal_note} ) { + $problem->add_to_comments( { + text => $new_internal_note, + user => $c->user->obj, + state => 'hidden', # seems best fit, should not be shown publicly + mark_fixed => 0, + problem_state => $problem->state, + anonymous => 1, + extra => { is_internal_note => 1 }, + } ); + } + } + # Problem updates upon submission + if ( ($type eq 'super' || $type eq 'dm') && $c->req->param('submit') ) { # Predefine the hash so it's there for lookups # XXX Note you need to shallow copy each time you set it, due to a bug? in FilterColumn. my $extra = $problem->extra || {}; - $extra->{internal_notes} = $c->req->param('internal_notes'); $extra->{publish_photo} = $c->req->params->{publish_photo} || 0; $extra->{third_personal} = $c->req->params->{third_personal} || 0; # Make sure we have a copy of the original detail field $extra->{original_detail} = $problem->detail if !$extra->{original_detail} && $c->req->params->{detail} && $problem->detail ne $c->req->params->{detail}; + # Workflow things my $redirect = 0; my $new_cat = $c->req->params->{category}; @@ -503,14 +522,6 @@ sub admin_report_edit { $db_update = 1; } - my $extra = $problem->extra || {}; - $extra->{internal_notes} ||= ''; - if ($c->req->param('internal_notes') && $c->req->param('internal_notes') ne $extra->{internal_notes}) { - $extra->{internal_notes} = $c->req->param('internal_notes'); - $problem->extra( { %$extra } ); - $db_update = 1; - } - $problem->update if $db_update; # Add new update from status_update -- cgit v1.2.3 From df38951bce57fddf5d4de658b239191f912d5973 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Tue, 10 Sep 2013 17:33:57 +0100 Subject: Update DB/Result/* with latest DBIx::Class::Schema::Loader Version 0.07027 of DBIx::Class::Schema::Loader introduced some changes to the way it generates schemas. > PostgreSQL WARNING: the default for on_delete/on_update attributes for > belongs_to relationships is now 'NO ACTION' not 'CASCADE! The default > for is_deferrable is now 0 not 1. --- perllib/FixMyStreet/DB/Result/Alert.pm | 8 ++++---- perllib/FixMyStreet/DB/Result/AlertSent.pm | 6 +++--- perllib/FixMyStreet/DB/Result/Body.pm | 20 ++++++++++---------- perllib/FixMyStreet/DB/Result/BodyArea.pm | 6 +++--- perllib/FixMyStreet/DB/Result/Comment.pm | 16 ++++++++-------- perllib/FixMyStreet/DB/Result/Contact.pm | 6 +++--- perllib/FixMyStreet/DB/Result/Problem.pm | 6 +++--- perllib/FixMyStreet/DB/Result/Questionnaire.pm | 6 +++--- perllib/FixMyStreet/DB/Result/User.pm | 10 +++++----- 9 files changed, 42 insertions(+), 42 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/DB/Result/Alert.pm b/perllib/FixMyStreet/DB/Result/Alert.pm index fc84c8fd5..4ce72f873 100644 --- a/perllib/FixMyStreet/DB/Result/Alert.pm +++ b/perllib/FixMyStreet/DB/Result/Alert.pm @@ -48,7 +48,7 @@ __PACKAGE__->belongs_to( "alert_type", "FixMyStreet::DB::Result::AlertType", { ref => "alert_type" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); __PACKAGE__->has_many( "alerts_sent", @@ -60,12 +60,12 @@ __PACKAGE__->belongs_to( "user", "FixMyStreet::DB::Result::User", { id => "user_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vump36YxUO4FQi5Do6DwvA +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:d9yIFiTGtbtFaULXZNKstQ # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/perllib/FixMyStreet/DB/Result/AlertSent.pm b/perllib/FixMyStreet/DB/Result/AlertSent.pm index a537c95cd..422e010a9 100644 --- a/perllib/FixMyStreet/DB/Result/AlertSent.pm +++ b/perllib/FixMyStreet/DB/Result/AlertSent.pm @@ -26,12 +26,12 @@ __PACKAGE__->belongs_to( "alert", "FixMyStreet::DB::Result::Alert", { id => "alert_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oN+36hDWJuc0hqkCW9BHOw +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:COwsprqRSNZS1IxJrPYgMQ # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm index 83704563a..b6a044b04 100644 --- a/perllib/FixMyStreet/DB/Result/Body.pm +++ b/perllib/FixMyStreet/DB/Result/Body.pm @@ -20,6 +20,8 @@ __PACKAGE__->add_columns( }, "name", { data_type => "text", is_nullable => 0 }, + "parent", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, "endpoint", { data_type => "text", is_nullable => 1 }, "jurisdiction", @@ -38,8 +40,6 @@ __PACKAGE__->add_columns( { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "send_extended_statuses", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, - "parent", - { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->has_many( @@ -59,10 +59,10 @@ __PACKAGE__->belongs_to( "FixMyStreet::DB::Result::User", { id => "comment_user_id" }, { - is_deferrable => 1, + is_deferrable => 0, join_type => "LEFT", - on_delete => "CASCADE", - on_update => "CASCADE", + on_delete => "NO ACTION", + on_update => "NO ACTION", }, ); __PACKAGE__->has_many( @@ -76,10 +76,10 @@ __PACKAGE__->belongs_to( "FixMyStreet::DB::Result::Body", { id => "parent" }, { - is_deferrable => 1, + is_deferrable => 0, join_type => "LEFT", - on_delete => "CASCADE", - on_update => "CASCADE", + on_delete => "NO ACTION", + on_update => "NO ACTION", }, ); __PACKAGE__->has_many( @@ -90,8 +90,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-19 12:47:10 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DdtXjMWRpz20ZHjtY3oP2w +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:JT0w76BWaDpjAV61WVSYHg sub url { my ( $self, $c ) = @_; diff --git a/perllib/FixMyStreet/DB/Result/BodyArea.pm b/perllib/FixMyStreet/DB/Result/BodyArea.pm index 844a3277d..4447777dc 100644 --- a/perllib/FixMyStreet/DB/Result/BodyArea.pm +++ b/perllib/FixMyStreet/DB/Result/BodyArea.pm @@ -21,12 +21,12 @@ __PACKAGE__->belongs_to( "body", "FixMyStreet::DB::Result::Body", { id => "body_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-19 12:47:10 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aAr+Nadyu8IckZlK6+PTNg +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+hzie6kHleUBoEt199c/nQ __PACKAGE__->set_primary_key(__PACKAGE__->columns); diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index c747f7fc1..c712ad4e1 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -54,6 +54,10 @@ __PACKAGE__->add_columns( { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "problem_state", { data_type => "text", is_nullable => 1 }, + "external_id", + { data_type => "text", is_nullable => 1 }, + "extra", + { data_type => "text", is_nullable => 1 }, "send_fail_count", { data_type => "integer", default_value => 0, is_nullable => 0 }, "send_fail_reason", @@ -62,28 +66,24 @@ __PACKAGE__->add_columns( { data_type => "timestamp", is_nullable => 1 }, "whensent", { data_type => "timestamp", is_nullable => 1 }, - "external_id", - { data_type => "text", is_nullable => 1 }, - "extra", - { data_type => "text", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to( "problem", "FixMyStreet::DB::Result::Problem", { id => "problem_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); __PACKAGE__->belongs_to( "user", "FixMyStreet::DB::Result::User", { id => "user_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-07-11 18:53:26 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tSejJzLxHD/fMWjpa10lfA +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:D/+UWcF7JO/EkCiJaAHUOw __PACKAGE__->filter_column( extra => { diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm index 551bcd019..2e1287a21 100644 --- a/perllib/FixMyStreet/DB/Result/Contact.pm +++ b/perllib/FixMyStreet/DB/Result/Contact.pm @@ -53,12 +53,12 @@ __PACKAGE__->belongs_to( "body", "FixMyStreet::DB::Result::Body", { id => "body_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-13 12:34:33 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:imXq3EtrC0FrQwj+E2xfBw +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hq/BFHDEu4OUI4MSy3OyHg __PACKAGE__->filter_column( extra => { diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index ec15600b6..c8b53e2d1 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -120,12 +120,12 @@ __PACKAGE__->belongs_to( "user", "FixMyStreet::DB::Result::User", { id => "user_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-13 15:13:48 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:H2P3Og37G569nQdQA1IWaA +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:U/4BT8EGfcCLKA/7LX+qyQ # Add fake relationship to stored procedure table __PACKAGE__->has_one( diff --git a/perllib/FixMyStreet/DB/Result/Questionnaire.pm b/perllib/FixMyStreet/DB/Result/Questionnaire.pm index fcaa17d99..7f9c79d9a 100644 --- a/perllib/FixMyStreet/DB/Result/Questionnaire.pm +++ b/perllib/FixMyStreet/DB/Result/Questionnaire.pm @@ -36,12 +36,12 @@ __PACKAGE__->belongs_to( "problem", "FixMyStreet::DB::Result::Problem", { id => "problem_id" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NGlSRjoBpDoIvK3EueqN6Q +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oL1Hk4/bNG14CY74GA75SA use DateTime::TimeZone; use Moose; diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index 481b654c9..523382670 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -58,10 +58,10 @@ __PACKAGE__->belongs_to( "FixMyStreet::DB::Result::Body", { id => "from_body" }, { - is_deferrable => 1, + is_deferrable => 0, join_type => "LEFT", - on_delete => "CASCADE", - on_update => "CASCADE", + on_delete => "NO ACTION", + on_update => "NO ACTION", }, ); __PACKAGE__->has_many( @@ -72,8 +72,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-14 09:23:59 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aw374WQraL5ysOvUmUIU3w +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jRAtXRLRNozCmthAg9p0dA __PACKAGE__->add_columns( "password" => { -- cgit v1.2.3 From bc3c1ab5ad24aea27999b98dfef94031097b70c2 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Tue, 10 Sep 2013 18:11:58 +0100 Subject: [Zurich] Update DB/Result/Body.pm schema --- perllib/FixMyStreet/DB/Result/Body.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm index b6a044b04..c2b0555fb 100644 --- a/perllib/FixMyStreet/DB/Result/Body.pm +++ b/perllib/FixMyStreet/DB/Result/Body.pm @@ -40,6 +40,8 @@ __PACKAGE__->add_columns( { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "send_extended_statuses", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, + "deleted", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->has_many( @@ -90,8 +92,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:JT0w76BWaDpjAV61WVSYHg +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 18:11:23 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hTOxxiiHmC8nmQK/p8dXhQ sub url { my ( $self, $c ) = @_; -- cgit v1.2.3 From 34c5c665c8ff753ece7f2badc17da0fdbe257a28 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Tue, 10 Sep 2013 18:24:10 +0100 Subject: [Zurich] Add deleted to admin body_params method --- perllib/FixMyStreet/App/Controller/Admin.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index ba8f22a05..4973b7c4e 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -413,7 +413,7 @@ sub update_contacts : Private { sub body_params : Private { my ( $self, $c ) = @_; - my @fields = qw/name endpoint jurisdiction api_key send_method send_comments suppress_alerts send_extended_statuses comment_user_id can_be_devolved parent/; + my @fields = qw/name endpoint jurisdiction api_key send_method send_comments suppress_alerts send_extended_statuses comment_user_id can_be_devolved parent deleted/; my %defaults = map { $_ => '' } @fields; %defaults = ( %defaults, send_comments => 0, @@ -422,6 +422,7 @@ sub body_params : Private { send_extended_statuses => 0, can_be_devolved => 0, parent => undef, + deleted => 0, ); my %params = map { $_ => $c->req->param($_) || $defaults{$_} } @fields; return \%params; -- cgit v1.2.3 From 4c9e2cab2a64b47580f7c68960122156f0081239 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Wed, 11 Sep 2013 11:57:00 +0100 Subject: Add extra detail to a comment --- perllib/FixMyStreet/Cobrand/Zurich.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index a677837a9..877f6ff0b 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -484,7 +484,8 @@ sub admin_report_edit { '

' . _('Updated!') . '

'; # do this here otherwise lastupdate and confirmed times - # do not display correctly + # do not display correctly (reloads problem from database, including + # fields modified by the database when saving) $problem->discard_changes; if ( $redirect ) { -- cgit v1.2.3 From c40a543905e4224e0a618d86aa9329be24a53f29 Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Wed, 11 Sep 2013 12:20:33 +0100 Subject: Remove shallow copying of $extra (and notes) as this has been fixed --- perllib/FixMyStreet/Cobrand/Zurich.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 877f6ff0b..5a1a65f7e 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -421,7 +421,6 @@ sub admin_report_edit { # Problem updates upon submission if ( ($type eq 'super' || $type eq 'dm') && $c->req->param('submit') ) { # Predefine the hash so it's there for lookups - # XXX Note you need to shallow copy each time you set it, due to a bug? in FilterColumn. my $extra = $problem->extra || {}; $extra->{publish_photo} = $c->req->params->{publish_photo} || 0; $extra->{third_personal} = $c->req->params->{third_personal} || 0; @@ -461,7 +460,7 @@ sub admin_report_edit { } } - $problem->extra( { %$extra } ); + $problem->extra( $extra ); $problem->title( $c->req->param('title') ); $problem->detail( $c->req->param('detail') ); $problem->latitude( $c->req->param('latitude') ); @@ -470,7 +469,7 @@ sub admin_report_edit { # Final, public, Update from DM if (my $update = $c->req->param('status_update')) { $extra->{public_response} = $update; - $problem->extra( { %$extra } ); + $problem->extra( $extra ); if ($c->req->params->{publish_response}) { $problem->state( 'fixed - council' ); _admin_send_email( $c, 'problem-closed.txt', $problem ); @@ -544,7 +543,7 @@ sub admin_report_edit { if ($c->req->param('no_more_updates')) { my $extra = $problem->extra || {}; $extra->{subdiv_overdue} = $self->overdue( $problem ); - $problem->extra( { %$extra } ); + $problem->extra( $extra ); $problem->bodies_str( $body->parent->id ); $problem->whensent( undef ); $problem->state( 'planned' ); -- cgit v1.2.3 From 35b29430a2c40dc85bcb01e189b8bb4710a5388e Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Wed, 11 Sep 2013 15:17:10 +0100 Subject: [Zurich] Don't store problem_state when creating the internal note comment --- perllib/FixMyStreet/Cobrand/Zurich.pm | 1 - 1 file changed, 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 5a1a65f7e..2b3542a92 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -411,7 +411,6 @@ sub admin_report_edit { user => $c->user->obj, state => 'hidden', # seems best fit, should not be shown publicly mark_fixed => 0, - problem_state => $problem->state, anonymous => 1, extra => { is_internal_note => 1 }, } ); -- cgit v1.2.3 From dec287591b28d4e2eff79f763306168125d6981a Mon Sep 17 00:00:00 2001 From: Edmund von der Burg Date: Wed, 11 Sep 2013 15:24:18 +0100 Subject: [Zurich] create internal note when the category is changed --- perllib/FixMyStreet/Cobrand/Zurich.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 2b3542a92..1bbe3b088 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -426,17 +426,22 @@ sub admin_report_edit { # Make sure we have a copy of the original detail field $extra->{original_detail} = $problem->detail if !$extra->{original_detail} && $c->req->params->{detail} && $problem->detail ne $c->req->params->{detail}; + # Some changes will be accompanied by an internal note, which if needed + # should be stored in this variable. + my $internal_note_text = ""; # Workflow things my $redirect = 0; my $new_cat = $c->req->params->{category}; if ( $new_cat && $new_cat ne $problem->category ) { my $cat = $c->model('DB::Contact')->search( { category => $c->req->params->{category} } )->first; + my $old_cat = $problem->category; $problem->category( $new_cat ); $problem->external_body( undef ); $problem->bodies_str( $cat->body_id ); $problem->whensent( undef ); $extra->{changed_category} = 1; + $internal_note_text = "Weitergeleitet von $old_cat an $new_cat"; $redirect = 1 if $cat->body_id ne $body->id; } elsif ( my $subdiv = $c->req->params->{body_subdivision} ) { $extra->{moderated_overdue} = $self->overdue( $problem ); @@ -486,6 +491,18 @@ sub admin_report_edit { # fields modified by the database when saving) $problem->discard_changes; + # Create an internal note if required + if ($internal_note_text) { + $problem->add_to_comments( { + text => $internal_note_text, + user => $c->user->obj, + state => 'hidden', # seems best fit, should not be shown publicly + mark_fixed => 0, + anonymous => 1, + extra => { is_internal_note => 1 }, + } ); + } + if ( $redirect ) { $c->detach('index'); } -- cgit v1.2.3 From e0dc46b4b86bdd1e52753f63d6ae4a60c52b49ff Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Wed, 11 Sep 2013 16:45:37 +0100 Subject: [Zurich] Don't send problem rejected email unless requested --- perllib/FixMyStreet/Cobrand/Zurich.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index d39c804ad..8e8b79d07 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -396,7 +396,7 @@ sub admin_report_edit { $redirect = 1; } else { $problem->state( $c->req->params->{state} ) if $c->req->params->{state}; - if ( $problem->state eq 'hidden' ) { + if ( $problem->state eq 'hidden' && $c->req->params->{send_rejected_email} ) { _admin_send_email( $c, 'problem-rejected.txt', $problem ); } } -- cgit v1.2.3 From 18ade89f8f1303b184e55630421cd6f9f3e7d17b Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Thu, 12 Sep 2013 11:22:10 +0100 Subject: Add fullsize photo to Photo controller This is used in the Zurich admin to view a full size version of the image before it has been made public. --- perllib/FixMyStreet/App/Controller/Photo.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index 8b00d1533..09afabecf 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -30,17 +30,19 @@ Display a photo =cut -sub during :LocalRegex('^([0-9a-f]{40})\.temp\.jpeg$') { +sub during :LocalRegex('^([0-9a-f]{40})\.(temp|fulltemp)\.jpeg$') { my ( $self, $c ) = @_; - my ( $hash ) = @{ $c->req->captures }; + my ( $hash, $size ) = @{ $c->req->captures }; my $file = file( $c->config->{UPLOAD_DIR}, "$hash.jpeg" ); my $photo = $file->slurp; - if ( $c->cobrand->default_photo_resize ) { - $photo = _shrink( $photo, $c->cobrand->default_photo_resize ); - } else { - $photo = _shrink( $photo, '250x250' ); + if ( $size eq 'temp' ) { + if ( $c->cobrand->default_photo_resize ) { + $photo = _shrink( $photo, $c->cobrand->default_photo_resize ); + } else { + $photo = _shrink( $photo, '250x250' ); + } } $c->forward( 'output', [ $photo ] ); -- cgit v1.2.3 From 30bb1746b703a12d7ec3c698eea63ac9e1183037 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 12 Sep 2013 15:59:27 +0100 Subject: mechanism to stop app store tests being sent In order to allow the iOS app to be tested in the app store we need to allow the user to create a report but we don't want to send it. To allow this hide reports with a specific title during send_reports --- perllib/FixMyStreet/DB/ResultSet/Problem.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet') diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 97d457297..b00daab40 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -259,10 +259,14 @@ sub send_reports { } $cobrand->set_lang_and_domain($row->lang, 1); - if ( $row->is_from_abuser ) { + if ( $row->is_from_abuser) { $row->update( { state => 'hidden' } ); debug_print("hiding because its sender is flagged as an abuser", $row->id) if $debug_mode; next; + } elsif ( $row->title =~ /app store test/i ) { + $row->update( { state => 'hidden' } ); + debug_print("hiding because it is an app store test message", $row->id) if $debug_mode; + next; } # Template variables for the email -- cgit v1.2.3