Added buttons for the mod stuff; had to restructure things to make room for mod remark stuff
This commit is contained in:
parent
088daa120d
commit
d01acbcde2
|
@ -32,8 +32,7 @@ Run the tests locally (against development environment):
|
||||||
|
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
1. Add buttons in single thread and single remark views for mods to
|
1. Something like
|
||||||
hide flagged posts; something like
|
|
||||||
[this](https://paste.lgts.xyz/?575618a432427bd1#DogvKr3pq6LUdezx5MrzccaANybAr6TjUV31iShdxfjB)
|
[this](https://paste.lgts.xyz/?575618a432427bd1#DogvKr3pq6LUdezx5MrzccaANybAr6TjUV31iShdxfjB)
|
||||||
for the flagged list which will link to the single remark|thread
|
for the flagged list which will link to the single remark|thread
|
||||||
views
|
views
|
||||||
|
|
|
@ -147,16 +147,18 @@ sub startup($self) {
|
||||||
->to('moderator#flagged')
|
->to('moderator#flagged')
|
||||||
->name('flagged_list');
|
->name('flagged_list');
|
||||||
|
|
||||||
$moderator->get('/unflag/:thread_id', [thread_id => qr/\d+/])
|
my $mod_thread = $moderator->under('/thread');
|
||||||
->to('moderator#unflag')
|
|
||||||
|
$mod_thread->get('/unflag/:thread_id', [thread_id => qr/\d+/])
|
||||||
|
->to('moderator#unflag_thread')
|
||||||
->name('unflag_thread');
|
->name('unflag_thread');
|
||||||
|
|
||||||
$moderator->get('/hide/:thread_id', [thread_id => qr/\d+/])
|
$mod_thread->get('/hide/:thread_id', [thread_id => qr/\d+/])
|
||||||
->to('moderator#hide')
|
->to('moderator#hide_thread')
|
||||||
->name('hide_thread');
|
->name('hide_thread');
|
||||||
|
|
||||||
$moderator->get('/unhide/:thread_id', [thread_id => qr/\d+/])
|
$mod_thread->get('/unhide/:thread_id', [thread_id => qr/\d+/])
|
||||||
->to('moderator#unhide')
|
->to('moderator#unhide_thread')
|
||||||
->name('unhide_thread');
|
->name('unhide_thread');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,32 +57,32 @@ sub logout($self) {
|
||||||
$self->redirect_to('threads_list');
|
$self->redirect_to('threads_list');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub unflag($self) {
|
sub unflag_thread($self) {
|
||||||
my $thread_id = $self->param('thread_id');
|
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('threads_list')->fragment('info')->to_abs;
|
||||||
|
|
||||||
$self->moderator->unflag($thread_id);
|
$self->moderator->unflag_thread($thread_id);
|
||||||
$self->flash(info => "Thread #$thread_id has been unflagged. ◀️");
|
$self->flash(info => "Thread #$thread_id has been unflagged. ◀️");
|
||||||
|
|
||||||
$self->redirect_to($redirect_url);
|
$self->redirect_to($redirect_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub hide($self) {
|
sub hide_thread($self) {
|
||||||
my $thread_id = $self->param('thread_id');
|
my $thread_id = $self->param('thread_id');
|
||||||
my $redirect_url = $self->url_for(single_thread => thread_id => $thread_id)
|
my $redirect_url = $self->url_for(single_thread => thread_id => $thread_id)
|
||||||
->fragment('info')->to_abs;
|
->fragment('info')->to_abs;
|
||||||
|
|
||||||
$self->moderator->hide($thread_id);
|
$self->moderator->hide_thread($thread_id);
|
||||||
$self->flash(info => "Thread #$thread_id has been hidden. 🫥");
|
$self->flash(info => "Thread #$thread_id has been hidden. 🫥");
|
||||||
|
|
||||||
$self->redirect_to($redirect_url);
|
$self->redirect_to($redirect_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub unhide($self) {
|
sub unhide_thread($self) {
|
||||||
my $thread_id = $self->param('thread_id');
|
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('threads_list')->fragment('info')->to_abs;
|
||||||
|
|
||||||
$self->moderator->unhide($thread_id);
|
$self->moderator->unhide_thread($thread_id);
|
||||||
$self->flash(info => "Thread #$thread_id has been unhidden. ⏪");
|
$self->flash(info => "Thread #$thread_id has been unhidden. ⏪");
|
||||||
|
|
||||||
$self->redirect_to($redirect_url);
|
$self->redirect_to($redirect_url);
|
||||||
|
|
|
@ -35,7 +35,7 @@ sub get_name($self, $mod_id) {
|
||||||
END_SQL
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
sub unflag($self, $thread_id) {
|
sub unflag_thread($self, $thread_id) {
|
||||||
$self->pg->db->query(<<~'END_SQL', $thread_id)
|
$self->pg->db->query(<<~'END_SQL', $thread_id)
|
||||||
UPDATE threads
|
UPDATE threads
|
||||||
SET flagged_status = FALSE
|
SET flagged_status = FALSE
|
||||||
|
@ -43,7 +43,7 @@ sub unflag($self, $thread_id) {
|
||||||
END_SQL
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
sub hide($self, $thread_id) {
|
sub hide_thread($self, $thread_id) {
|
||||||
$self->pg->db->query(<<~'END_SQL', $thread_id)
|
$self->pg->db->query(<<~'END_SQL', $thread_id)
|
||||||
UPDATE threads
|
UPDATE threads
|
||||||
SET hidden_status = TRUE,
|
SET hidden_status = TRUE,
|
||||||
|
@ -52,7 +52,7 @@ sub hide($self, $thread_id) {
|
||||||
END_SQL
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
sub unhide($self, $thread_id) {
|
sub unhide_thread($self, $thread_id) {
|
||||||
$self->pg->db->query(<<~'END_SQL', $thread_id)
|
$self->pg->db->query(<<~'END_SQL', $thread_id)
|
||||||
UPDATE threads
|
UPDATE threads
|
||||||
SET hidden_status = FALSE
|
SET hidden_status = FALSE
|
||||||
|
|
|
@ -41,19 +41,43 @@ subtest Login => sub {
|
||||||
|
|
||||||
# Do these subs while logged in
|
# Do these subs while logged in
|
||||||
subtest Flag => sub {
|
subtest Flag => sub {
|
||||||
$t->get_ok('/moderator/unflag/1')
|
$t->get_ok('/moderator/thread/unflag/1')
|
||||||
->status_is(302)
|
->status_is(302)
|
||||||
->header_like(Location => qr{thread/list});
|
->header_like(Location => qr{thread/list});
|
||||||
|
|
||||||
|
#$t->get_ok('/moderator/remark/unflag/1')
|
||||||
|
# ->status_is(302)
|
||||||
|
# ->header_like(Location => qr{thread/single});
|
||||||
};
|
};
|
||||||
|
|
||||||
subtest Hide => sub {
|
subtest Hide => sub {
|
||||||
$t->get_ok('/moderator/hide/1')
|
$t->get_ok('/moderator/thread/hide/1')
|
||||||
->status_is(302)
|
->status_is(302)
|
||||||
->header_like(Location => qr{thread/single/1});
|
->header_like(Location => qr{thread/single});
|
||||||
|
$t->get_ok('/moderator/thread/unhide/1')
|
||||||
$t->get_ok('/moderator/unhide/1')
|
|
||||||
->status_is(302)
|
->status_is(302)
|
||||||
->header_like(Location => qr{thread/list});
|
->header_like(Location => qr{thread/list});
|
||||||
|
|
||||||
|
#$t->get_ok('/moderator/remark/hide/1')
|
||||||
|
# ->status_is(302)
|
||||||
|
# ->header_like(Location => qr{thread/single});
|
||||||
|
#$t->get_ok('/moderator/remark/unhide/1')
|
||||||
|
# ->status_is(302)
|
||||||
|
# ->header_like(Location => qr{thread/single});
|
||||||
|
};
|
||||||
|
|
||||||
|
subtest 'Buttons for mods', sub {
|
||||||
|
$t->get_ok('/thread/single/1')
|
||||||
|
->status_is(200)
|
||||||
|
->element_exists('a[href*="/hide/1"]' )
|
||||||
|
->element_exists('a[href*="/unhide/1"]')
|
||||||
|
->element_exists('a[href*="/unflag/1"]');
|
||||||
|
|
||||||
|
#$t->get_ok('/remark/single/1')
|
||||||
|
# ->status_is(200)
|
||||||
|
# ->element_exists('a[href*="/hide/1"]' )
|
||||||
|
# ->element_exists('a[href*="/unhide/1"]')
|
||||||
|
# ->element_exists('a[href*="/unflag/1"]');
|
||||||
};
|
};
|
||||||
|
|
||||||
$t->get_ok('/logout')
|
$t->get_ok('/logout')
|
||||||
|
|
|
@ -14,6 +14,13 @@
|
||||||
<%= link_to Bump => bump_thread => {thread_id => $thread->{'id'}} %>
|
<%= link_to Bump => bump_thread => {thread_id => $thread->{'id'}} %>
|
||||||
<%= link_to Flag => flag_thread => {thread_id => $thread->{'id'}} %>
|
<%= link_to Flag => flag_thread => {thread_id => $thread->{'id'}} %>
|
||||||
</nav>
|
</nav>
|
||||||
|
<% if (is_mod) { =%>
|
||||||
|
<nav>
|
||||||
|
<%= link_to Hide => hide_thread => {thread_id => $thread->{'id'}} %>
|
||||||
|
<%= link_to Unhide => unhide_thread => {thread_id => $thread->{'id'}} %>
|
||||||
|
<%= link_to Unflag => unflag_thread => {thread_id => $thread->{'id'}} %>
|
||||||
|
</nav>
|
||||||
|
<% } =%>
|
||||||
<% if (my $first_remark = $remarks->[0]) { =%>
|
<% if (my $first_remark = $remarks->[0]) { =%>
|
||||||
<div class="remarks" id="remarks">
|
<div class="remarks" id="remarks">
|
||||||
<h3>Remarks</h3>
|
<h3>Remarks</h3>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user