From: hylom Date: Thu, 5 Oct 2017 10:47:22 +0000 (+0900) Subject: fix comment allowed/denyed related problems X-Git-Tag: v0.1.1~317 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=79f1b36903cde2095a025b9c9f0fdbc71c0c7068;p=newslash%2Fnewslash.git fix comment allowed/denyed related problems --- diff --git a/src/newslash_web/lib/Newslash/Web/Controller/Story.pm b/src/newslash_web/lib/Newslash/Web/Controller/Story.pm index 4da706e1..8d236c95 100644 --- a/src/newslash_web/lib/Newslash/Web/Controller/Story.pm +++ b/src/newslash_web/lib/Newslash/Web/Controller/Story.pm @@ -52,6 +52,7 @@ sub story { params => $params, authors => $authors, use_captcha => 1, + comment_allowed => 1, ); } diff --git a/src/newslash_web/lib/Newslash/Web/Controller/Submission.pm b/src/newslash_web/lib/Newslash/Web/Controller/Submission.pm index 765cd7f2..f2fdd19e 100644 --- a/src/newslash_web/lib/Newslash/Web/Controller/Submission.pm +++ b/src/newslash_web/lib/Newslash/Web/Controller/Submission.pm @@ -5,6 +5,7 @@ use Data::Dumper; 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'); @@ -13,12 +14,21 @@ sub submission { 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 { diff --git a/src/newslash_web/templates/common/comment/comment_header.html.tt2 b/src/newslash_web/templates/common/comment/comment_header.html.tt2 index eb146861..253be765 100644 --- a/src/newslash_web/templates/common/comment/comment_header.html.tt2 +++ b/src/newslash_web/templates/common/comment/comment_header.html.tt2 @@ -2,14 +2,14 @@
この議論は賞味期限が切れたので、アーカイブ化されています。 新たにコメントを付けることはできません。
-
+
設定によりコメント投稿は許可されていません。
[%# %] - diff --git a/src/newslash_web/templates/common/js_vars.html.tt2 b/src/newslash_web/templates/common/js_vars.html.tt2 index f5d6c15f..c1e89612 100644 --- a/src/newslash_web/templates/common/js_vars.html.tt2 +++ b/src/newslash_web/templates/common/js_vars.html.tt2 @@ -10,22 +10,28 @@ [%- 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" -%] @@ -34,17 +40,11 @@ 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 -%]