sub submission {
my $c = shift;
my $subid = $c->stash('id');
+ my $user = $c->stash('user');
my $submission = $c->model('submissions')->select(subid => $subid);
if (!$submission) {
$c->render('Not found', status => '404');
my $d_id = $submission->{discussion_id};
my $comments = [];
my $discuss = {};
+ my $comment_allowed => 0;
if ($d_id) {
- $discuss = $c->model('discussions')->select(id => $d_id);
+ my $discussions = $c->model('discussions');
+ $discuss = $discussions->select(id => $d_id);
$comments = $c->model('comments')->select(discussion_id => $d_id);
+ $comment_allowed = $discussions->is_comment_allowed(discussion => $discuss,
+ uid => $user->{uid});
}
- $c->render(submission => $submission, discussion => $discuss, comments => $comments);
+ $c->render(submission => $submission,
+ discussion => $discuss,
+ comments => $comments,
+ use_captcha => 1,
+ comment_allowed => $comment_allowed,
+ );
}
sub create {
<div v-if="archived" class="alert alert-info">
この議論は賞味期限が切れたので、アーカイブ化されています。 新たにコメントを付けることはできません。
</div>
- <div v-if="!commentAllowed" class="alert alert-info">
+ <div v-else-if="!commentAllowed" class="alert alert-info">
設定によりコメント投稿は許可されていません。
</div>
<div class="form-inline">
[%#
<button type="button" class="btn btn-default form-control">コメント元ページを表示</button>
%]
- <button type="button" class="btn btn-default form-control" v-if="commentAllowed">
+ <button type="button" class="btn btn-default form-control" v-if="commentAllowed && !archived">
<span class="glyphicon glyphicon-comment"></span>
<span class="btn-text"> コメントを書く</span>
</button>
[%- END %]
};
var page = {};
+ [%- IF discussion.type != 'archived' && comment_allowed %]
+ page.commentAllowed = 1;
+ [%- ELSE %]
+ page.commentAllowed = 0;
+ [%- END %]
+ [%- IF discussion %]
+ page.archived = [% IF discussion.type == 'archived' %]1[% ELSE %]0[% END %];
+ page.discussionID = [% discussion.id %];
+ [%- ELSE %]
+ page.archived = 0;
+ page.discussionID = 0;
+ [%- END %]
[%- IF story && story.content_type == "story" -%]
page.type = 'story';
page.stoid = [% story.stoid %];
page.sid = '[% story.sid %]';
- page.archived = [% IF discussion.type == 'archived' %]1[% ELSE %]0[% END %];
- page.discussionID = [% story.discussion %];
- page.commentAllowed = [% IF comment_allowed; comment_allowed; ELSE; 0; END %];
[%- END -%]
[%- IF journal && journal.content_type == "journal" -%]
page.type = 'journal';
page.id = [% journal.id %];
- page.archived = [% IF discussion.type == 'archived' %]1[% ELSE %]0[% END %];
- page.discussionID = [% IF journal.discussion_id; journal.discussion_id; ELSE; 0; END %];
- page.commentAllowed = [% IF comment_allowed; comment_allowed; ELSE; 0; END %];
[%- END -%]
[%- IF comment && comment.content_type == "comment" -%]
page.parentID = [% comment.parent_id %];
page.stoid = [% discussion.stoid %];
page.sid = '[% discussion.sid %]';
- page.archived = [% IF discussion.type == 'archived' %]1[% ELSE %]0[% END %];
- page.discussionID = [% discussion.id %];
- page.commentAllowed = [% IF comment_allowed; comment_allowed; ELSE; 0; END %];
[%- END -%]
[%- IF story && story.content_type == "poll" -%]
page.type = 'poll';
page.qid = [% story.qid %];
- page.archived = [% IF discussion.type == 'archived' %]1[% ELSE %]0[% END %];
- page.discussionID = [% story.discussion %];
- page.commentAllowed = [% IF comment_allowed; comment_allowed; ELSE; 0; END %];
[%- END -%]
</script>