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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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 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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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 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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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/Cobrand/Zurich.pm') 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