aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm23
-rw-r--r--t/app/controller/moderate.t12
-rw-r--r--templates/web/base/report/_main.html7
-rw-r--r--templates/web/base/report/update.html7
-rw-r--r--web/cobrands/fixmystreet/staff.js9
-rw-r--r--web/cobrands/sass/_base.scss9
7 files changed, 59 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 67c93128e..4fb18ccfb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@
- Simplify /auth sign in page. #2208
- Enforce maximum photo size server side, strip EXIF data. #2326 #2134
- Don't require two taps on reports list on touchscreens. #2294
+ - Allow moderation to work without JavaScript. #2339
- Admin improvements:
- Allow moderation to potentially change category. #2320
- Add Mark/View private reports permission #2306
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 1951028c8..4e009f8d4 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -92,6 +92,29 @@ sub display :PathPart('') :Chained('id') :Args(0) {
}
}
+sub moderate_report :PathPart('moderate') :Chained('id') :Args(0) {
+ my ( $self, $c ) = @_;
+
+ if ($c->user_exists && $c->user->can_moderate($c->stash->{problem})) {
+ $c->stash->{show_moderation} = 'report';
+ $c->stash->{template} = 'report/display.html';
+ $c->detach('display');
+ }
+ $c->res->redirect($c->stash->{problem}->url);
+}
+
+sub moderate_update :PathPart('moderate') :Chained('id') :Args(1) {
+ my ( $self, $c, $update_id ) = @_;
+
+ my $comment = $c->stash->{problem}->comments->find($update_id);
+ if ($c->user_exists && $comment && $c->user->can_moderate($comment)) {
+ $c->stash->{show_moderation} = $update_id;
+ $c->stash->{template} = 'report/display.html';
+ $c->detach('display');
+ }
+ $c->res->redirect($c->stash->{problem}->url);
+}
+
sub support :Chained('id') :Args(0) {
my ( $self, $c ) = @_;
diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t
index a064a88d4..4eb72ed56 100644
--- a/t/app/controller/moderate.t
+++ b/t/app/controller/moderate.t
@@ -64,6 +64,9 @@ subtest 'Auth' => sub {
$mech->get_ok($REPORT_URL);
$mech->content_lacks('Moderat');
+ $mech->get_ok("$REPORT_URL/moderate");
+ $mech->content_lacks('Moderat');
+
$mech->log_in_ok( $user->email );
$mech->get_ok($REPORT_URL);
@@ -102,6 +105,9 @@ subtest 'Problem moderation' => sub {
subtest 'Post modify title and text' => sub {
$mech->get_ok($REPORT_URL);
+ $mech->content_lacks('show-moderation');
+ $mech->follow_link_ok({ text_regex => qr/^Moderate$/ });
+ $mech->content_contains('show-moderation');
$mech->submit_form_ok({ with_fields => {
%problem_prepopulated,
problem_title => 'Good good',
@@ -335,6 +341,9 @@ subtest 'updates' => sub {
subtest 'Update modify text' => sub {
$mech->get_ok($REPORT_URL);
+ $mech->content_lacks('show-moderation');
+ $mech->follow_link_ok({ text_regex => qr/^Moderate this update$/ });
+ $mech->content_contains('show-moderation');
$mech->submit_form_ok({ with_fields => {
%update_prepopulated,
update_text => 'update good good good',
@@ -446,6 +455,9 @@ subtest 'Now stop being a staff user' => sub {
$user->update({ from_body => undef });
$mech->get_ok($REPORT_URL);
$mech->content_contains('Moderated by Bromley Council');
+
+ $mech->get_ok("$REPORT_URL/moderate/" . $update->id);
+ $mech->content_lacks('Moderate this update');
};
subtest 'And do it as a superuser' => sub {
diff --git a/templates/web/base/report/_main.html b/templates/web/base/report/_main.html
index 6c5537fb4..d40b1db52 100644
--- a/templates/web/base/report/_main.html
+++ b/templates/web/base/report/_main.html
@@ -6,7 +6,9 @@ can_moderate_title = c.user.can_moderate_title(problem, can_moderate)
<a href="[% c.uri_for( '/around', { lat => latitude, lon => longitude } ) %]"
class="problem-back js-back-to-report-list">[% loc('Back to all reports') %]</a>
-<div class="problem-header clearfix" data-lastupdate="[% problem.lastupdate %]">
+<div class="problem-header clearfix
+ [%~ ' show-moderation' IF show_moderation == 'report' ~%]
+ " data-lastupdate="[% problem.lastupdate %]">
[% IF permissions.planned_reports %]
<form method="post" action="/my/planned/change" id="planned_form" class="hidden-label-target">
@@ -129,7 +131,8 @@ can_moderate_title = c.user.can_moderate_title(problem, can_moderate)
[% IF can_moderate OR permissions.planned_reports %]
<div class="moderate-display segmented-control" role="menu">
[% IF can_moderate %]
- <a class="js-moderate btn" role="menuitem" aria-label="[% loc('Moderate this report') %]">[% loc('Moderate') %]</a>
+ <a class="js-moderate btn" role="menuitem" href="/report/[% problem.id %]/moderate"
+ aria-label="[% loc('Moderate this report') %]">[% loc('Moderate') %]</a>
[% END %]
[% IF permissions.planned_reports %]
[%~ IF c.user.is_planned_report(problem) ~%]
diff --git a/templates/web/base/report/update.html b/templates/web/base/report/update.html
index d8b3b5629..bac28dd11 100644
--- a/templates/web/base/report/update.html
+++ b/templates/web/base/report/update.html
@@ -4,12 +4,15 @@
<h4 class="static-with-rule">[% loc('Updates') %]</h4>
<ul class="item-list item-list--updates">
[% END %]
- <li class="item-list__item item-list__item--updates">
+ <li class="item-list__item item-list__item--updates
+ [%~ ' show-moderation' IF show_moderation == update.id ~%]
+ ">
<a name="update_[% update.id %]" class="internal-link-fixed-header"></a>
[% IF can_moderate; original_update = update.moderation_original_data %]
<form method="post" action="/moderate/report/[% problem.id %]/update/[% update.id %]">
<input type="hidden" name="token" value="[% csrf_token %]">
- <input type="button" class="btn js-moderate moderate-display" value="[% loc('Moderate this update') %]">
+ <a role="menuitem" href="/report/[% problem.id %]/moderate/[% update.id %]#update_[% update.id %]"
+ class="btn js-moderate moderate-display">[% loc('Moderate this update') %]</a>
<div class="moderate-edit">
<label><input type="checkbox" class="hide-document" name="update_hide">
[% loc('Hide update completely?') %]</label>
diff --git a/web/cobrands/fixmystreet/staff.js b/web/cobrands/fixmystreet/staff.js
index b8854d1cd..ede6e1381 100644
--- a/web/cobrands/fixmystreet/staff.js
+++ b/web/cobrands/fixmystreet/staff.js
@@ -376,9 +376,9 @@ $.extend(fixmystreet.set_up, {
function add_handlers (elem, word) {
elem.each( function () {
var $elem = $(this);
- $elem.find('.js-moderate').on('click', function () {
- $elem.find('.moderate-display').hide();
- $elem.find('.moderate-edit').show();
+ $elem.find('.js-moderate').on('click', function(e) {
+ e.preventDefault();
+ $elem.toggleClass('show-moderation');
$('#map_sidebar').scrollTop(word === 'problem' ? 0 : $elem[0].offsetTop);
});
@@ -399,8 +399,7 @@ $.extend(fixmystreet.set_up, {
});
$elem.find('.cancel').click( function () {
- $elem.find('.moderate-display').show();
- $elem.find('.moderate-edit').hide();
+ $elem.toggleClass('show-moderation');
$('#map_sidebar').scrollTop(word === 'problem' ? 0 : $elem[0].offsetTop);
});
diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss
index 98e043e0e..282553456 100644
--- a/web/cobrands/sass/_base.scss
+++ b/web/cobrands/sass/_base.scss
@@ -1405,6 +1405,15 @@ input.final-submit {
}
}
+.show-moderation {
+ .moderate-edit {
+ display: block;
+ }
+ .moderate-display {
+ display: none;
+ }
+}
+
.shortlisted-status {
margin-top: 1em;
padding: 1em 1em 1em 4em; // Icon is always displayed on left, even in RtL mode