Skip to content

Commit

Permalink
Fixes from making the tag tests
Browse files Browse the repository at this point in the history
  • Loading branch information
symkat committed Nov 27, 2021
1 parent 8c3cdd9 commit 3522388
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion DB/lib/BlogDB/DB/Result/PendingTag.pm
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,11 @@ __PACKAGE__->has_many(
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Lax0e42Qy8BWDsYZfKmZyw


# You can replace this text with custom code or comments, and it will be preserved on regeneration
sub vote_score {
my ( $self ) = @_;

my $score = $self->search_related('tag_votes', { vote => 1 } )->count || 0;

return $score;
}
1;
2 changes: 2 additions & 0 deletions Web/lib/BlogDB/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ sub startup ($self) {

return 1 if $c->stash->{person};

push @{$c->stash->{errors}}, 'Login required.';

$c->redirect_to( $c->url_for( 'homepage' ) );
return undef;
});
Expand Down
8 changes: 7 additions & 1 deletion Web/lib/BlogDB/Web/Controller/Tags.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sub post_suggest_tag ($c) {
my $is_adult = $c->stash->{form_adult} = $c->param('is_adult');

push @{$c->stash->{errors}}, "Tag names must start with a letter, and may only contain letters and numbers."
unless $tag_name =~ m/^[a-zA-Z][a-zA-Z0-9]+$/;
unless $tag_name =~ m/^[a-zA-Z][a-zA-Z0-9_]+$/;

return 0 if $c->stash->{errors};

Expand Down Expand Up @@ -85,6 +85,9 @@ sub post_delete_tag ($c) {
my $tag_name = $c->stash->{form_tag} = $c->param('tag');

my $tag = $c->db->resultset('PendingTag')->search({ name => $tag_name })->first;

push @{$c->stash->{errors}}, "Not authorized."
unless $c->stash->{person}->setting( 'can_manage_tags');

push @{$c->stash->{errors}}, "No such tag?"
unless $tag;
Expand Down Expand Up @@ -116,6 +119,9 @@ sub post_approve_tag ($c) {

my $tag = $c->db->resultset('PendingTag')->search({ name => $tag_name })->first;

push @{$c->stash->{errors}}, "Not authorized."
unless $c->stash->{person}->setting( 'can_manage_tags');

push @{$c->stash->{errors}}, "No such tag?"
unless $tag;

Expand Down

0 comments on commit 3522388

Please sign in to comment.