Skip to content

Commit 3522388

Browse files
committed
Fixes from making the tag tests
1 parent 8c3cdd9 commit 3522388

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

DB/lib/BlogDB/DB/Result/PendingTag.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,11 @@ __PACKAGE__->has_many(
131131
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Lax0e42Qy8BWDsYZfKmZyw
132132

133133

134-
# You can replace this text with custom code or comments, and it will be preserved on regeneration
134+
sub vote_score {
135+
my ( $self ) = @_;
136+
137+
my $score = $self->search_related('tag_votes', { vote => 1 } )->count || 0;
138+
139+
return $score;
140+
}
135141
1;

Web/lib/BlogDB/Web.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ sub startup ($self) {
6161

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

64+
push @{$c->stash->{errors}}, 'Login required.';
65+
6466
$c->redirect_to( $c->url_for( 'homepage' ) );
6567
return undef;
6668
});

Web/lib/BlogDB/Web/Controller/Tags.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sub post_suggest_tag ($c) {
2020
my $is_adult = $c->stash->{form_adult} = $c->param('is_adult');
2121

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

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

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

8787
my $tag = $c->db->resultset('PendingTag')->search({ name => $tag_name })->first;
88+
89+
push @{$c->stash->{errors}}, "Not authorized."
90+
unless $c->stash->{person}->setting( 'can_manage_tags');
8891

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

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

122+
push @{$c->stash->{errors}}, "Not authorized."
123+
unless $c->stash->{person}->setting( 'can_manage_tags');
124+
119125
push @{$c->stash->{errors}}, "No such tag?"
120126
unless $tag;
121127

0 commit comments

Comments
 (0)