aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm9
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm6
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm1
-rw-r--r--t/app/controller/admin.t1
-rw-r--r--t/app/controller/admin_permissions.t2
-rw-r--r--t/app/controller/report_as_other.t26
-rw-r--r--templates/web/base/admin/category-multiselect.html2
-rw-r--r--templates/web/base/report/new/form_user_loggedin.html6
-rw-r--r--templates/web/base/report/update/form_name.html6
-rw-r--r--templates/web/bromley/report/new/after_photo.html8
-rw-r--r--templates/web/bromley/report/update-form.html15
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js3
-rw-r--r--web/cobrands/fixmystreet/staff.js10
15 files changed, 86 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 38e1d4674..186a66a5b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
* Unreleased
- New features:
- Body and category names can now be translated in the admin. #1244
+ - Body users can now create reports as an anonymous user. #1796
- Front end improvements:
- Always show pagination figures even if only one page.
- Admin improvements:
diff --git a/perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm b/perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm
index bcfeb3dd8..ef4a0f219 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm
@@ -62,7 +62,7 @@ sub edit : Path : Args(2) {
my %active_contacts = map { $_->id => 1 } @contacts;
my @all_contacts = map { {
id => $_->id,
- category => $_->category,
+ category => $_->category_display,
active => $active_contacts{$_->id},
} } @live_contacts;
$c->stash->{contacts} = \@all_contacts;
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index ab4c616fb..a8d5b995e 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -201,8 +201,10 @@ sub report_form_ajax : Path('ajax') : Args(0) {
if ($c->user_exists) {
my @bodies = keys %{$c->stash->{bodies}};
my $ca_another_user = $c->user->has_permission_to('contribute_as_another_user', \@bodies);
+ my $ca_anonymous_user = $c->user->has_permission_to('contribute_as_anonymous_user', \@bodies);
my $ca_body = $c->user->from_body && $c->user->has_permission_to('contribute_as_body', \@bodies);
$contribute_as->{another_user} = $ca_another_user if $ca_another_user;
+ $contribute_as->{anonymous_user} = $ca_anonymous_user if $ca_anonymous_user;
$contribute_as->{body} = $ca_body if $ca_body;
}
@@ -742,7 +744,8 @@ sub process_user : Private {
$user->title( $user_title ) if $user_title;
$report->user( $user );
- if ($c->stash->{contributing_as_body} = $user->contributing_as('body', $c, $c->stash->{bodies})) {
+ if ($c->stash->{contributing_as_body} = $user->contributing_as('body', $c, $c->stash->{bodies}) or
+ $c->stash->{contributing_as_anonymous_user} = $user->contributing_as('anonymous_user', $c, $c->stash->{bodies})) {
$report->name($user->from_body->name);
$user->name($user->from_body->name) unless $user->name;
$c->stash->{no_reporter_alert} = 1;
@@ -822,6 +825,8 @@ sub process_report : Private {
# set some simple bool values (note they get inverted)
if ($c->stash->{contributing_as_body}) {
$report->anonymous(0);
+ } elsif ($c->stash->{contributing_as_anonymous_user}) {
+ $report->anonymous(1);
} else {
$report->anonymous( $params{may_show_name} ? 0 : 1 );
}
@@ -1148,7 +1153,7 @@ sub save_user_and_report : Private {
sub created_as_someone_else : Private {
my ($self, $c, $bodies) = @_;
- return $c->stash->{contributing_as_another_user} || $c->stash->{contributing_as_body};
+ return $c->stash->{contributing_as_another_user} || $c->stash->{contributing_as_body} || $c->stash->{contributing_as_anonymous_user};
}
=head2 generate_map
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 59171f97b..068f393f2 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -128,7 +128,7 @@ sub process_user : Private {
$update->user( $user );
# Just in case, make sure the user will have a name
- if ($c->stash->{contributing_as_body}) {
+ if ($c->stash->{contributing_as_body} or $c->stash->{contributing_as_anonymous_user}) {
$user->name($user->from_body->name) unless $user->name;
}
@@ -277,9 +277,13 @@ sub process_update : Private {
$update->mark_open($params{reopen} ? 1 : 0);
$c->stash->{contributing_as_body} = $c->user_exists && $c->user->contributing_as('body', $c, $update->problem->bodies_str_ids);
+ $c->stash->{contributing_as_anonymous_user} = $c->user_exists && $c->user->contributing_as('anonymous_user', $c, $update->problem->bodies_str_ids);
if ($c->stash->{contributing_as_body}) {
$update->name($c->user->from_body->name);
$update->anonymous(0);
+ } elsif ($c->stash->{contributing_as_anonymous_user}) {
+ $update->name($c->user->from_body->name);
+ $update->anonymous(1);
} else {
$update->name($name);
$update->anonymous($c->get_param('may_show_name') ? 0 : 1);
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 1a0bbb0c8..852f380f0 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -710,6 +710,7 @@ sub available_permissions {
report_instruct => _("Instruct contractors to fix problems"), # future use
planned_reports => _("Manage shortlist"),
contribute_as_another_user => _("Create reports/updates on a user's behalf"),
+ contribute_as_anonymous_user => _("Create reports/updates as anonymous user"),
contribute_as_body => _("Create reports/updates as the council"),
view_body_contribute_details => _("See user detail for reports created as the council"),
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 069e00b5e..075ab0fd0 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -1177,6 +1177,7 @@ my %default_perms = (
"permissions[report_inspect]" => undef,
"permissions[report_instruct]" => undef,
"permissions[contribute_as_another_user]" => undef,
+ "permissions[contribute_as_anonymous_user]" => undef,
"permissions[contribute_as_body]" => undef,
"permissions[view_body_contribute_details]" => undef,
"permissions[user_edit]" => undef,
diff --git a/t/app/controller/admin_permissions.t b/t/app/controller/admin_permissions.t
index 0997e1e38..7944cc0b1 100644
--- a/t/app/controller/admin_permissions.t
+++ b/t/app/controller/admin_permissions.t
@@ -146,6 +146,7 @@ FixMyStreet::override_config {
"permissions[report_inspect]" => undef,
"permissions[report_instruct]" => undef,
"permissions[contribute_as_another_user]" => undef,
+ "permissions[contribute_as_anonymous_user]" => undef,
"permissions[contribute_as_body]" => undef,
"permissions[user_edit]" => undef,
"permissions[user_manage_permissions]" => undef,
@@ -178,6 +179,7 @@ FixMyStreet::override_config {
"permissions[report_inspect]" => undef,
"permissions[report_instruct]" => undef,
"permissions[contribute_as_another_user]" => undef,
+ "permissions[contribute_as_anonymous_user]" => undef,
"permissions[contribute_as_body]" => undef,
"permissions[user_edit]" => undef,
"permissions[user_manage_permissions]" => undef,
diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t
index 86c2deb93..daa213e8c 100644
--- a/t/app/controller/report_as_other.t
+++ b/t/app/controller/report_as_other.t
@@ -76,6 +76,20 @@ subtest "Body user, has permission to add report as another (existing) user" =>
push @users, $report->user;
};
+subtest "Body user, has permission to add report as anonymous user" => sub {
+ my $report = add_report(
+ 'contribute_as_anonymous_user',
+ form_as => 'anonymous_user',
+ title => "Test Report",
+ detail => 'Test report details.',
+ category => 'Street lighting',
+ );
+ is $report->name, 'Oxfordshire County Council', 'report name is body';
+ is $report->user->name, 'Body User', 'user name unchanged';
+ is $report->user->id, $user->id, 'user matches';
+ is $report->anonymous, 1, 'report anonymous';
+};
+
subtest "Body user, has permission to add update as council" => sub {
my $update = add_update(
'contribute_as_body',
@@ -119,6 +133,18 @@ subtest "Body user, has permission to add update as another (existing) user" =>
like $mech->get_text_body_from_email, qr/Your update has been logged/;
};
+subtest "Body user, has permission to add update as anonymous user" => sub {
+ my $update = add_update(
+ 'contribute_as_anonymous_user',
+ form_as => 'anonymous_user',
+ update => 'Test Update',
+ );
+ is $update->name, 'Oxfordshire County Council', 'update name is body';
+ is $update->user->name, 'Body User', 'user name unchanged';
+ is $update->user->id, $user->id, 'user matches';
+ is $update->anonymous, 1, 'update anonymous';
+};
+
done_testing();
sub start_report {
diff --git a/templates/web/base/admin/category-multiselect.html b/templates/web/base/admin/category-multiselect.html
index 4e4eceeed..98416204f 100644
--- a/templates/web/base/admin/category-multiselect.html
+++ b/templates/web/base/admin/category-multiselect.html
@@ -4,7 +4,7 @@
<p>
<select class="form-control js-multiple" name="categories" id="categories" multiple data-all="[% loc('All categories') %]">
[% FOR contact IN contacts %]
- <option value="[% contact.id %]" [% 'selected' IF contact.active %]>[% contact.category_display | html %]</option>
+ <option value="[% contact.id %]" [% 'selected' IF contact.active %]>[% contact.category | html %]</option>
[% END %]
</select>
</p>
diff --git a/templates/web/base/report/new/form_user_loggedin.html b/templates/web/base/report/new/form_user_loggedin.html
index d5c347d8c..8e6629273 100644
--- a/templates/web/base/report/new/form_user_loggedin.html
+++ b/templates/web/base/report/new/form_user_loggedin.html
@@ -6,8 +6,9 @@
</div>
[% ELSE %]
[% can_contribute_as_another_user = c.user.has_permission_to("contribute_as_another_user", bodies.keys) %]
+ [% can_contribute_as_anonymous_user = c.user.has_permission_to("contribute_as_anonymous_user", bodies.keys) %]
[% can_contribute_as_body = c.user.from_body AND c.user.has_permission_to("contribute_as_body", bodies.keys) %]
- [% IF can_contribute_as_another_user OR can_contribute_as_body %]
+ [% IF can_contribute_as_another_user OR can_contribute_as_anonymous_user OR can_contribute_as_body %]
[% INCLUDE form_as %]
[% END %]
[% END %]
@@ -16,6 +17,9 @@
<label for="form_as">[% loc('Report as') %]</label>
<select id="form_as" class="form-control js-contribute-as" name="form_as">
<option value="myself" [% c.user.has_body_permission_to('planned_reports') ? '' : 'selected' %]>[% loc('Yourself') %]</option>
+ [% IF js || can_contribute_as_anonymous_user %]
+ <option value="anonymous_user">[% loc('Anonymous user') %]</option>
+ [% END %]
[% IF js || can_contribute_as_another_user %]
<option value="another_user">[% loc('Another user') %]</option>
[% END %]
diff --git a/templates/web/base/report/update/form_name.html b/templates/web/base/report/update/form_name.html
index 926e16878..e4f7ac60c 100644
--- a/templates/web/base/report/update/form_name.html
+++ b/templates/web/base/report/update/form_name.html
@@ -3,15 +3,19 @@
[% PROCESS 'user/_anonymity.html' anonymous = update.anonymous %]
[% can_contribute_as_another_user = c.user.has_permission_to("contribute_as_another_user", problem.bodies_str_ids) %]
+ [% can_contribute_as_anonymous_user = c.user.has_permission_to("contribute_as_anonymous_user", problem.bodies_str_ids) %]
[% can_contribute_as_body = c.user.from_body AND c.user.has_permission_to("contribute_as_body", problem.bodies_str_ids) %]
- [% IF can_contribute_as_another_user OR can_contribute_as_body %]
+ [% IF can_contribute_as_another_user OR can_contribute_as_body OR can_contribute_as_anonymous_user %]
<label for="form_as">[% loc('Provide update as') %]</label>
<select id="form_as" class="form-control js-contribute-as" name="form_as">
<option value="myself" selected>[% loc('Yourself') %]</option>
[% IF can_contribute_as_another_user %]
<option value="another_user">[% loc('Another user') %]</option>
[% END %]
+ [% IF can_contribute_as_anonymous_user %]
+ <option value="anonymous_user">[% loc('Anonymous user') %]</option>
+ [% END %]
[% IF can_contribute_as_body %]
<option value="body">[% c.user.from_body.name %]</option>
[% END %]
diff --git a/templates/web/bromley/report/new/after_photo.html b/templates/web/bromley/report/new/after_photo.html
new file mode 100644
index 000000000..e8fac0d2a
--- /dev/null
+++ b/templates/web/bromley/report/new/after_photo.html
@@ -0,0 +1,8 @@
+<div class="description_tips" aria-label="Tips for perfect photos">
+ <ul class="do">
+ <li>To help us locate the problem, include both a close-up and a wide shot</li>
+ </ul>
+ <ul class="dont">
+ <li>Avoid personal information</li>
+ </ul>
+</div>
diff --git a/templates/web/bromley/report/update-form.html b/templates/web/bromley/report/update-form.html
index a4cbf8ee1..e71e27528 100644
--- a/templates/web/bromley/report/update-form.html
+++ b/templates/web/bromley/report/update-form.html
@@ -34,17 +34,22 @@
</div>
[% END %]
+ <div class="general-notes">
+ <p>Please note that new and separate occurrences of issues
+ should be logged as new reports, to avoid conflicting
+ information or updates and ensure the information is passed
+ promptly to our teams. Please log any new issue via
+ <a href="https://www.bromley.gov.uk/report">https://www.bromley.gov.uk/report</a>
+ using the map marker and description to detail where the issue
+ is located.</p>
+ </div>
+
<label for="form_update">[% loc( 'Update' ) %]</label>
[% IF field_errors.update %]
<div class='form-error'>[% field_errors.update %]</div>
[% END %]
<textarea class="form-control" rows="7" cols="30" name="update" id="form_update" placeholder="[% loc('Please write your update here') %]" required>[% update.text | html %]</textarea>
- <div class="general-notes">
- <p>Please note this comments box can only be used for this report.
- <br><a href="http://www.bromley.gov.uk/report">Report a different issue</a>
- </div>
-
[% IF c.user && c.user.belongs_to_body( problem.bodies_str ) %]
<label for="state">[% loc( 'State' ) %]</label>
[% INCLUDE 'report/inspect/state_groups_select.html' %]
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index 4d38c81d2..291455aa7 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -912,6 +912,9 @@ fixmystreet.update_pin = function(lonlat, savePushState) {
if (!data.contribute_as.another_user) {
$select.find('option[value=another_user]').remove();
}
+ if (!data.contribute_as.anonymous_user) {
+ $select.find('option[value=anonymous_user]').remove();
+ }
if (!data.contribute_as.body) {
$select.find('option[value=body]').remove();
}
diff --git a/web/cobrands/fixmystreet/staff.js b/web/cobrands/fixmystreet/staff.js
index 66f9411cd..95fbad81a 100644
--- a/web/cobrands/fixmystreet/staff.js
+++ b/web/cobrands/fixmystreet/staff.js
@@ -173,21 +173,31 @@ $.extend(fixmystreet.set_up, {
txt = opt.text;
var $emailInput = $('input[name=email]').add('input[name=rznvy]');
var $nameInput = $('input[name=name]');
+ var $phoneInput = $('input[name=phone]');
var $showNameCheckbox = $('input[name=may_show_name]');
var $addAlertCheckbox = $('#form_add_alert');
if (val === 'myself') {
$emailInput.val($emailInput.prop('defaultValue')).prop('disabled', true);
$nameInput.val($nameInput.prop('defaultValue')).prop('disabled', false);
+ $phoneInput.val($phoneInput.prop('defaultValue')).prop('disabled', false);
$showNameCheckbox.prop('checked', false).prop('disabled', false);
$addAlertCheckbox.prop('checked', true).prop('disabled', false);
} else if (val === 'another_user') {
$emailInput.val('').prop('disabled', false);
$nameInput.val('').prop('disabled', false);
+ $phoneInput.val('').prop('disabled', false);
$showNameCheckbox.prop('checked', false).prop('disabled', true);
$addAlertCheckbox.prop('checked', true).prop('disabled', false);
+ } else if (val === 'anonymous_user') {
+ $emailInput.val('-').prop('disabled', true);
+ $nameInput.val('-').prop('disabled', true);
+ $phoneInput.val('-').prop('disabled', true);
+ $showNameCheckbox.prop('checked', false).prop('disabled', true);
+ $addAlertCheckbox.prop('checked', false).prop('disabled', true);
} else if (val === 'body') {
$emailInput.val('-').prop('disabled', true);
$nameInput.val(txt).prop('disabled', true);
+ $phoneInput.val('-').prop('disabled', true);
$showNameCheckbox.prop('checked', true).prop('disabled', true);
$addAlertCheckbox.prop('checked', false).prop('disabled', true);
}