Implement basic view of flagged posts

This commit is contained in:
swag 2022-12-08 14:54:46 -06:00
parent 4ffa8b2613
commit a4b82238bf
4 changed files with 37 additions and 6 deletions

View File

@ -32,10 +32,7 @@ Run the tests locally (against development environment):
## TODOs
1. Something like
[this](https://paste.lgts.xyz/?575618a432427bd1#DogvKr3pq6LUdezx5MrzccaANybAr6TjUV31iShdxfjB)
for the flagged list which will link to the single remark|thread
views
1. Tests for flagged view? Not much to it but got pulled into work stuff
1. Actions for creating moderators and resetting passwords
1. CSS

View File

@ -2,7 +2,21 @@ package PostText::Controller::Moderator;
use Mojo::Base 'Mojolicious::Controller', -signatures;
sub list($self) { $self->render }
sub flagged($self) {
my $flagged_posts = $self->moderator->flagged;
my $post_links = [map {
if ($_->{'type'} eq 'thread') {
$self->url_for(single_thread => thread_id => $_->{'id'})
}
else {
$self->url_for(single_remark => remark_id => $_->{'id'})
}
} @{$flagged_posts}];
$self->stash(post_links => $post_links);
$self->render;
}
sub login($self) {
my $v;

View File

@ -85,4 +85,18 @@ sub unhide_remark($self, $remark_id) {
END_SQL
}
sub flagged($self) {
$self->pg->db->query(<<~'END_SQL')->hashes
SELECT 'thread' AS type,
thread_id AS id
FROM threads
WHERE flagged_status
UNION
SELECT 'remark',
remark_id
FROM remarks
WHERE flagged_status;
END_SQL
}
1;

View File

@ -1,4 +1,10 @@
% layout 'default';
% title 'Flagged Posts';
<h2><%= title %></h2>
<p>Coming soon, stay tuned.</p>
<% if ($post_links->[0]) { =%>
<ul>
<% for my $link (@{$post_links}) { =%>
<%= link_to $link, $link %><br>
<% } =%>
</ul>
<% } =%>