Implement basic view of flagged posts
This commit is contained in:
parent
4ffa8b2613
commit
a4b82238bf
|
@ -32,10 +32,7 @@ Run the tests locally (against development environment):
|
||||||
|
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
1. Something like
|
1. Tests for flagged view? Not much to it but got pulled into work stuff
|
||||||
[this](https://paste.lgts.xyz/?575618a432427bd1#DogvKr3pq6LUdezx5MrzccaANybAr6TjUV31iShdxfjB)
|
|
||||||
for the flagged list which will link to the single remark|thread
|
|
||||||
views
|
|
||||||
1. Actions for creating moderators and resetting passwords
|
1. Actions for creating moderators and resetting passwords
|
||||||
1. CSS
|
1. CSS
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,21 @@ package PostText::Controller::Moderator;
|
||||||
|
|
||||||
use Mojo::Base 'Mojolicious::Controller', -signatures;
|
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) {
|
sub login($self) {
|
||||||
my $v;
|
my $v;
|
||||||
|
|
|
@ -85,4 +85,18 @@ sub unhide_remark($self, $remark_id) {
|
||||||
END_SQL
|
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;
|
1;
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
% layout 'default';
|
% layout 'default';
|
||||||
% title 'Flagged Posts';
|
% title 'Flagged Posts';
|
||||||
<h2><%= title %></h2>
|
<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>
|
||||||
|
<% } =%>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user