Change up redirects for mod actions

This commit is contained in:
swag 2023-05-12 23:48:29 -04:00
parent 212521e905
commit 7f4f21c454
3 changed files with 12 additions and 18 deletions

View File

@ -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?

View File

@ -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. ⏪");

View File

@ -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 {