aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--docs/_includes/admin-tasks-content.md3
-rw-r--r--docs/assets/img/pro-user-guide/report-public-update.pngbin10740 -> 39301 bytes
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm7
-rw-r--r--t/app/controller/report_inspect.t31
-rw-r--r--templates/web/base/report/_inspect.html2
-rw-r--r--templates/web/base/report/inspect/public_update.html3
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js11
-rw-r--r--web/cobrands/fixmystreet/staff.js8
9 files changed, 55 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e7f42fdc0..de9b71d38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -61,6 +61,7 @@
- Disable category rename on Open311 categories when unprotected. #2957
- In category admin, group is already shown elsewhere.
- Add assigned_(users|categories)_only functionality.
+ - Inspectors can now include a photo with public updates. #2902
- Bugfixes:
- Application user in Docker container can't install packages. #2914
- Look at all categories when sending reports.
diff --git a/docs/_includes/admin-tasks-content.md b/docs/_includes/admin-tasks-content.md
index ac9e81f9e..cd6043c25 100644
--- a/docs/_includes/admin-tasks-content.md
+++ b/docs/_includes/admin-tasks-content.md
@@ -350,6 +350,9 @@ If ‘Create reports/updates as the council’ is ticked in the staff user’s a
updates will be labeled as from the council rather than the staff member’s name. For the sake of
staff privacy, this is usually preferable.
+Staff with appropriate permissions can also attach an image to the update, which will then be
+displayed publicly alongside the text update.
+
This option is also available via the general 'Update' box under the main report.
#### Requests for more information
diff --git a/docs/assets/img/pro-user-guide/report-public-update.png b/docs/assets/img/pro-user-guide/report-public-update.png
index e6b4ac587..d4b390a70 100644
--- a/docs/assets/img/pro-user-guide/report-public-update.png
+++ b/docs/assets/img/pro-user-guide/report-public-update.png
Binary files differ
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index dd7abc563..991064f55 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -554,6 +554,12 @@ sub inspect : Private {
$c->cobrand->call_hook(report_inspect_update_extra => $problem);
+ $c->forward('/photo/process_photo');
+ if ( my $photo_error = delete $c->stash->{photo_error} ) {
+ $valid = 0;
+ push @{ $c->stash->{errors} }, $photo_error;
+ }
+
if ($valid) {
$problem->lastupdate( \'current_timestamp' );
$problem->update;
@@ -574,6 +580,7 @@ sub inspect : Private {
created => $timestamp,
confirmed => $timestamp,
user => $c->user->obj,
+ photo => $c->stash->{upload_fileid} || undef,
%update_params,
} );
}
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index de9d689cd..48dceaf04 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -1,5 +1,6 @@
use FixMyStreet::TestMech;
use Test::MockModule;
+use Path::Class;
my $mech = FixMyStreet::TestMech->new;
@@ -42,6 +43,9 @@ my $user = $mech->log_in_ok('body@example.com');
$user->set_extra_metadata('categories', [ $contact->id ]);
$user->update( { from_body => $oxon } );
+my $sample_file = file(__FILE__)->parent->file("sample.jpg")->stringify;
+ok -e $sample_file, "sample file $sample_file exists";
+
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.uk/',
ALLOWED_COBRANDS => 'fixmystreet',
@@ -589,7 +593,27 @@ FixMyStreet::override_config {
$mech->get_ok("/report/$report_id");
$mech->content_contains('Nearest calculated address', 'Address displayed');
$mech->content_contains('Constitution Hill, London, SW1A', 'Correct address displayed');
- }
+ };
+
+ subtest "test upload photo with public updates" => sub {
+ $user->user_body_permissions->delete;
+ $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_inspect' });
+
+ $report->state('confirmed');
+ $report->update;
+ $mech->get_ok("/report/$report_id");
+ $mech->submit_form_ok({ button => 'save', with_fields => {
+ public_update => "This is a public update.", include_update => "1",
+ state => 'action scheduled',
+ photo1 => [ [ $sample_file, undef, Content_Type => 'image/jpeg' ], 1 ],
+ } });
+ $report->discard_changes;
+ my $comment = $report->comments(undef, { rows => 1, order_by => { -desc => "id" }})->first;
+ is $comment->photo, '74e3362283b6ef0c48686fb0e161da4043bbcc97.jpeg', 'photo added to comment';
+ $mech->get_ok("/report/$report_id");
+ $mech->content_contains("/photo/c/" . $comment->id . ".0.jpeg");
+ };
+
};
foreach my $test (
@@ -705,7 +729,10 @@ FixMyStreet::override_config {
priority => $rp->id,
include_update => '1',
detailed_information => 'XXX164XXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
- traffic_information => ''
+ traffic_information => '',
+ photo1 => '',
+ photo2 => '',
+ photo3 => '',
};
my $values = $mech->visible_form_values('report_inspect_form');
is_deeply $values, $expected_fields, 'correct form fields present';
diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html
index 88fbdd70b..30848b5d4 100644
--- a/templates/web/base/report/_inspect.html
+++ b/templates/web/base/report/_inspect.html
@@ -5,7 +5,7 @@
[% INCLUDE 'errors.html' %]
- <form name="report_inspect_form" id="report_inspect_form" method="post" action="[% c.uri_for( '/report', problem.id ) %]" class="validate">
+ <form name="report_inspect_form" id="report_inspect_form" method="post" action="[% c.uri_for( '/report', problem.id ) %]" class="validate"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %]>
[% INCLUDE 'report/inspect/information.html' %]
diff --git a/templates/web/base/report/inspect/public_update.html b/templates/web/base/report/inspect/public_update.html
index be07d7b89..31940b6ee 100644
--- a/templates/web/base/report/inspect/public_update.html
+++ b/templates/web/base/report/inspect/public_update.html
@@ -7,8 +7,11 @@
[% loc('Save with a public update') %]
</label>
</p>
+ <div id="public_update_form_fields">
+ [% INCLUDE report/form/photo_upload.html %]
<p>
<label for="public_update">[% loc('Public update:') %]</label>
[% INCLUDE 'admin/response_templates_select.html' for='public_update' %]
<textarea rows="2" name="public_update" id="public_update" class="form-control">[% public_update | html %]</textarea>
</p>
+ </div>
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index 032140298..8073530c6 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -660,6 +660,11 @@ $.extend(fixmystreet.set_up, {
},
dropzone: function($context) {
+ if ('Dropzone' in window) {
+ Dropzone.autoDiscover = false;
+ } else {
+ return;
+ }
// Pass a jQuery element, eg $('.foobar'), into this function
// to limit all the selectors to that element. Handy if you want
@@ -670,12 +675,6 @@ $.extend(fixmystreet.set_up, {
$context = $(document);
}
- if ('Dropzone' in window) {
- Dropzone.autoDiscover = false;
- } else {
- return;
- }
-
var forms = $('[for="form_photo"], .js-photo-label', $context).closest('form');
forms.each(function() {
// Internal $context is the individual form with the photo upload inside
diff --git a/web/cobrands/fixmystreet/staff.js b/web/cobrands/fixmystreet/staff.js
index 89d7cab39..e62ae6ba7 100644
--- a/web/cobrands/fixmystreet/staff.js
+++ b/web/cobrands/fixmystreet/staff.js
@@ -137,6 +137,10 @@ fixmystreet.staff_set_up = {
document.getElementById('side-inspect').scrollIntoView();
}
+ // make sure dropzone is set up, otherwise loading problem with
+ // JS leaves this uninitialized.
+ fixmystreet.set_up.dropzone($inspect_form);
+
function updateTemplates(opts) {
opts.category = opts.category || $inspect_form.find('[name=category]').val();
opts.state = opts.state || $inspect_form.find('[name=state]').val();
@@ -212,9 +216,9 @@ fixmystreet.staff_set_up = {
var $checkbox = $(this);
var toggle_public_update = function() {
if ($checkbox.prop('checked')) {
- $('#public_update').parents('p').show();
+ $('#public_update_form_fields').show();
} else {
- $('#public_update').parents('p').hide();
+ $('#public_update_form_fields').hide();
}
};
$checkbox.on('change', function() {