Confirmation for bump_thread
This commit is contained in:
parent
ce6d405b1d
commit
f4c9d25139
|
@ -140,13 +140,24 @@ sub feed($self) {
|
||||||
|
|
||||||
sub bump($self) {
|
sub bump($self) {
|
||||||
my $thread_id = $self->param('thread_id');
|
my $thread_id = $self->param('thread_id');
|
||||||
|
my $v = $self->validation;
|
||||||
|
|
||||||
$self->thread->bump($thread_id);
|
$v->optional(captcha => 'trim')->size(4, 4)->like(qr/bump/i);
|
||||||
$self->flash(info => "Thread #$thread_id has been bumped. 🔝");
|
|
||||||
|
|
||||||
$self->redirect_to(
|
if ($v->is_valid) {
|
||||||
$self->url_for('threads_list')->fragment('info')->to_abs
|
my $redirect_url =
|
||||||
);
|
$self->url_for('threads_list')->fragment('info')->to_abs;
|
||||||
|
|
||||||
|
$self->thread->bump($thread_id);
|
||||||
|
$self->flash(info => "Thread #$thread_id has been bumped. 🔝");
|
||||||
|
|
||||||
|
return $self->redirect_to($redirect_url);
|
||||||
|
}
|
||||||
|
elsif ($v->has_error) {
|
||||||
|
$self->stash(status => 400)
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->render;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub flag($self) {
|
sub flag($self) {
|
||||||
|
|
|
@ -87,6 +87,10 @@ subtest 'Bumping thread', sub {
|
||||||
$t->get_ok('/thread/bump/1')->status_is(200)
|
$t->get_ok('/thread/bump/1')->status_is(200)
|
||||||
->element_exists('p[class="stash-with-info"]')
|
->element_exists('p[class="stash-with-info"]')
|
||||||
->text_like(p => qr/Thread #1 has been bumped/);
|
->text_like(p => qr/Thread #1 has been bumped/);
|
||||||
|
|
||||||
|
$t->get_ok('/thread/bump/1' )->status_is(200);
|
||||||
|
$t->get_ok('/thread/bump/65536')->status_is(404);
|
||||||
|
$t->get_ok('/thread/bump/1', form => {captcha => 'bump'})->status_is(400);
|
||||||
};
|
};
|
||||||
|
|
||||||
subtest 'Flagging thread', sub {
|
subtest 'Flagging thread', sub {
|
||||||
|
@ -100,6 +104,7 @@ subtest 'Flagging thread', sub {
|
||||||
|
|
||||||
$t->get_ok('/thread/flag/1' )->status_is(200);
|
$t->get_ok('/thread/flag/1' )->status_is(200);
|
||||||
$t->get_ok('/thread/flag/65536')->status_is(404);
|
$t->get_ok('/thread/flag/65536')->status_is(404);
|
||||||
|
$t->get_ok('/thread/flag/1', form => {captcha => 'flag'})->status_is(400);
|
||||||
};
|
};
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
17
templates/thread/bump.html.ep
Normal file
17
templates/thread/bump.html.ep
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
% layout 'default';
|
||||||
|
% title $thread_id ? "Bump Thread #$thread_id" : '?';
|
||||||
|
<h2 class="page-title"><%= title %></h2>
|
||||||
|
<% if ($thread_id) { =%>
|
||||||
|
<form class="form-body">
|
||||||
|
<div class="form-field">
|
||||||
|
<% if (my $error = validation->error('captcha')) { =%>
|
||||||
|
<p class="field-with-error">Must be between <%= $error->[2] %>
|
||||||
|
and <%= $error->[3] %> characters.</p>
|
||||||
|
<% } =%>
|
||||||
|
<%= label_for captcha => "Enter the word 'bump' to confirm:" %>
|
||||||
|
<%= text_field captcha => id => 'captcha' %>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="form-button">Confirm</button>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
<% } =%>
|
|
@ -11,7 +11,7 @@
|
||||||
<%= label_for captcha => "Enter the word 'flag' to confirm:" %>
|
<%= label_for captcha => "Enter the word 'flag' to confirm:" %>
|
||||||
<%= text_field captcha => id => 'captcha' %>
|
<%= text_field captcha => id => 'captcha' %>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="form-button">Flag</button>
|
<button type="submit" class="form-button">Confirm</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<% } =%>
|
<% } =%>
|
||||||
|
|
Loading…
Reference in a new issue