From 7f4f21c454d8aaa5e6c833aeefb6eef804e22152 Mon Sep 17 00:00:00 2001 From: swag Date: Fri, 12 May 2023 23:48:29 -0400 Subject: [PATCH] Change up redirects for mod actions --- README.md | 2 -- lib/PostText/Controller/Moderator.pm | 16 ++++++---------- t/moderator.t | 12 ++++++------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index fa7305f..eca32df 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,6 @@ Run the tests locally (against development environment): ## TODOs -1. Show `bump_tally` and `remark_count` in single thread view -1. Redirect mod/admin back to hidden/flagged where it makes sense 1. CSS 1. "All new posts flagged" mode (require approval for new posts) 1. Tests for mod-only user? diff --git a/lib/PostText/Controller/Moderator.pm b/lib/PostText/Controller/Moderator.pm index 5cb8c0b..6471272 100644 --- a/lib/PostText/Controller/Moderator.pm +++ b/lib/PostText/Controller/Moderator.pm @@ -88,7 +88,7 @@ sub logout($self) { sub unflag_thread($self) { my $thread_id = $self->param('thread_id'); - my $redirect_url = $self->url_for('threads_list')->fragment('info')->to_abs; + my $redirect_url = $self->url_for('flagged_list')->fragment('info')->to_abs; $self->moderator->unflag_thread($thread_id); $self->flash(info => "Thread #$thread_id has been unflagged. ◀️"); @@ -98,8 +98,7 @@ sub unflag_thread($self) { sub hide_thread($self) { my $thread_id = $self->param('thread_id'); - my $redirect_url = $self->url_for(single_thread => thread_id => $thread_id) - ->fragment('info')->to_abs; + my $redirect_url = $self->url_for('flagged_list')->fragment('info')->to_abs; $self->moderator->hide_thread($thread_id); $self->flash(info => "Thread #$thread_id has been hidden. 🫥"); @@ -109,7 +108,7 @@ sub hide_thread($self) { sub unhide_thread($self) { my $thread_id = $self->param('thread_id'); - my $redirect_url = $self->url_for('threads_list')->fragment('info')->to_abs; + my $redirect_url = $self->url_for('hidden_list')->fragment('info')->to_abs; $self->moderator->unhide_thread($thread_id); $self->flash(info => "Thread #$thread_id has been unhidden. ⏪"); @@ -120,8 +119,7 @@ sub unhide_thread($self) { sub unflag_remark($self) { my $remark_id = $self->param('remark_id'); my $thread_id = $self->remark->thread_id_for($remark_id); - my $redirect_url = $self->url_for(single_thread => thread_id => $thread_id) - ->fragment('info')->to_abs; + my $redirect_url = $self->url_for('flagged_list')->fragment('info')->to_abs; $self->moderator->unflag_remark($remark_id); $self->flash(info => "Remark #$remark_id has been unflagged. ◀️"); @@ -131,8 +129,7 @@ sub unflag_remark($self) { sub hide_remark($self) { my $remark_id = $self->param('remark_id'); - my $redirect_url = $self->url_for(single_remark => remark_id => $remark_id) - ->fragment('info')->to_abs; + my $redirect_url = $self->url_for('flagged_list')->fragment('info')->to_abs; $self->moderator->hide_remark($remark_id); $self->flash(info => "Remark #$remark_id has been hidden. 🫥"); @@ -143,8 +140,7 @@ sub hide_remark($self) { sub unhide_remark($self) { my $remark_id = $self->param('remark_id'); my $thread_id = $self->remark->thread_id_for($remark_id); - my $redirect_url = $self->url_for(single_thread => thread_id => $thread_id) - ->fragment('info')->to_abs; + my $redirect_url = $self->url_for('hidden_list')->fragment('info')->to_abs; $self->moderator->unhide_remark($remark_id); $self->flash(info => "Remark #$remark_id has been unhidden. ⏪"); diff --git a/t/moderator.t b/t/moderator.t index acf52a7..7152f1b 100644 --- a/t/moderator.t +++ b/t/moderator.t @@ -39,27 +39,27 @@ subtest Login => sub { subtest Flag => sub { $t->get_ok('/moderator/thread/unflag/1') ->status_is(302) - ->header_like(Location => qr{thread/list}); + ->header_like(Location => qr{moderator/flagged}); $t->get_ok('/moderator/remark/unflag/1') ->status_is(302) - ->header_like(Location => qr{thread/single}); + ->header_like(Location => qr{moderator/flagged}); }; subtest Hide => sub { $t->get_ok('/moderator/thread/hide/1') ->status_is(302) - ->header_like(Location => qr{thread/single}); + ->header_like(Location => qr{moderator/flagged}); $t->get_ok('/moderator/thread/unhide/1') ->status_is(302) - ->header_like(Location => qr{thread/list}); + ->header_like(Location => qr{moderator/hidden}); $t->get_ok('/moderator/remark/hide/1') ->status_is(302) - ->header_like(Location => qr{remark/single}); + ->header_like(Location => qr{moderator/flagged}); $t->get_ok('/moderator/remark/unhide/1') ->status_is(302) - ->header_like(Location => qr{thread/single}); + ->header_like(Location => qr{moderator/hidden}); }; subtest 'Buttons for mods', sub {