diff --git a/README.md b/README.md index bb65cdd..8efe52b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/PostText/Controller/Moderator.pm b/lib/PostText/Controller/Moderator.pm index d4be1fd..6c16616 100644 --- a/lib/PostText/Controller/Moderator.pm +++ b/lib/PostText/Controller/Moderator.pm @@ -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; diff --git a/lib/PostText/Model/Moderator.pm b/lib/PostText/Model/Moderator.pm index bdbe5c0..3455af1 100644 --- a/lib/PostText/Model/Moderator.pm +++ b/lib/PostText/Model/Moderator.pm @@ -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; diff --git a/templates/moderator/flagged.html.ep b/templates/moderator/flagged.html.ep index 3744bc3..b4beb5a 100644 --- a/templates/moderator/flagged.html.ep +++ b/templates/moderator/flagged.html.ep @@ -1,4 +1,10 @@ % layout 'default'; % title 'Flagged Posts';

<%= title %>

-

Coming soon, stay tuned.

+<% if ($post_links->[0]) { =%> + +<% } =%>