Skip to content

Commit

Permalink
Added cioppino.twothumbs for Like/Dislike button, preparing the way t…
Browse files Browse the repository at this point in the history
…o override 'plone.comments' viewlet
  • Loading branch information
Joaquín Rosales committed May 24, 2011
1 parent 0b3dee5 commit 40f3378
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 3 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# -*- Extra requirements: -*- # -*- Extra requirements: -*-
'Plone', 'Plone',
'plone.app.discussion', 'plone.app.discussion',
'cioppino.twothumbs',
'plone.app.dexterity', 'plone.app.dexterity',
'collective.autopermission', 'collective.autopermission',
'collective.testcaselayer', 'collective.testcaselayer',
Expand Down
10 changes: 7 additions & 3 deletions sg/questions/question.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from zope import schema from zope import schema


from Products.CMFCore.interfaces import IContentish from Products.CMFCore.interfaces import IContentish
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from plone.app.layout.globals.interfaces import IViewView from plone.app.layout.globals.interfaces import IViewView
from plone.app.layout.viewlets.interfaces import IBelowContent from plone.app.layout.viewlets.interfaces import IBelowContent
from plone.app.discussion.interfaces import IDiscussionLayer from plone.app.discussion.interfaces import IDiscussionLayer
Expand All @@ -15,15 +16,18 @@
from sg.questions import _ from sg.questions import _




class ISGQuestionsLayer(IDefaultBrowserLayer):
""" Browser layer for sg.questions """

class CommentsRatingViewlet(CommentsViewlet, grok.Viewlet): class CommentsRatingViewlet(CommentsViewlet, grok.Viewlet):
""" This viewlet is added to rate the comment """ """ This viewlet is added to rate the comment """
grok.context(IContentish) grok.context(IContentish)
grok.viewletmanager(IBelowContent) grok.viewletmanager(IBelowContent)
grok.layer(IDiscussionLayer) grok.layer(ISGQuestionsLayer)
grok.view(IViewView) grok.view(IViewView)
grok.name('plone.comments')


class ISGQuestionsLayer(IDefaultBrowserLayer): index = ViewPageTemplateFile('question_templates/rating_viewlet.pt')
""" Browser layer for sg.questions """


class IQuestion(form.Schema): class IQuestion(form.Schema):
""" A content-type for source code snippets. """ """ A content-type for source code snippets. """
Expand Down
167 changes: 167 additions & 0 deletions sg/questions/question_templates/rating_viewlet.pt
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,167 @@
<tal:block tal:define="userHasReplyPermission view/can_reply;
isDiscussionAllowed view/is_discussion_allowed;
isAnonymousDiscussionAllowed view/anonymous_discussion_allowed;
isAnon view/is_anonymous;
canReview view/can_review;
replies python:view.get_replies(canReview);
has_replies python:view.has_replies(canReview);
showCommenterImage view/show_commenter_image;
errors options/state/getErrors|nothing;
wtool context/@@plone_tools/workflow;"
tal:condition="python:isDiscussionAllowed or has_replies"
i18n:domain="plone">

<div class="reply"
tal:condition="python:isAnon and not isAnonymousDiscussionAllowed">
<form tal:attributes="action view/login_action">
<input class="standalone"
style="margin-bottom: 1.25em;"
type="submit"
value="Log in to add comments"
i18n:attributes="value label_login_to_add_comments;"
/>
</form>
</div>

<div class="discussion"
tal:attributes="class python: showCommenterImage and 'discussion showCommenterImage' or 'discussion';"
tal:condition="has_replies">
<tal:getreplies repeat="reply_dict replies">

<div class="comment"
tal:define="reply reply_dict/comment;
depth reply_dict/depth|python:0;
author_home_url python:view.get_commenter_home_url(username=reply.author_username);
has_author_link python:author_home_url and not isAnon;
portrait_url python:view.get_commenter_portrait(reply.author_username);
review_state python:wtool.getInfoFor(reply, 'review_state');"
tal:attributes="class python:'comment replyTreeLevel'+str(depth)+' state-'+str(review_state);
style string:margin-left: ${depth}em;
id string:${reply/getId}"
tal:condition="python:canReview or review_state == 'published'">

<div tal:content="structure comment/@@rate-if-you-dare"/>

<div class="commentImage" tal:condition="showCommenterImage">
<a href="" tal:condition="has_author_link"
tal:attributes="href author_home_url">
<img src="defaultUser.gif"
alt=""
border="0"
height="32"
tal:attributes="src portrait_url;
alt reply/Creator" />
</a>
<img src="defaultUser.gif"
alt=""
border="0"
height="32"
tal:condition="not: has_author_link"
tal:attributes="src portrait_url;
alt reply/Creator" />
</div>

<div class="documentByLine" i18n:domain="plone.app.discussion">
<tal:name>
<a href=""
tal:condition="has_author_link"
tal:content="reply/Creator"
tal:attributes="href author_home_url">
Poster Name
</a>
<span tal:condition="not: has_author_link"
tal:replace="reply/Creator" />
<span tal:condition="not: reply/Creator">Anonymous</span>
</tal:name>
<tal:posted i18n:translate="label_says">says:</tal:posted>
<div class="commentDate"
tal:content="python:view.format_time(reply.modification_date)">
8/23/2001 12:40:44 PM
</div>
</div>

<div class="commentBody">

<span tal:replace="structure python:view.cook(reply.getText())" />

<div class="commentActions">
<form name="delete"
action=""
method="post"
style="display: inline;"
tal:condition="canReview"
tal:attributes="action string:${reply/absolute_url}/@@moderate-delete-comment">
<input name="form.button.DeleteComment"
class="destructive"
type="submit"
value="Delete"
i18n:attributes="value label_delete;"
/>
</form>

<!-- Workflow actions (e.g. 'publish') -->
<form name=""
action=""
method="get"
style="display: inline;"
tal:condition="canReview"
tal:repeat="action reply_dict/actions|nothing"
tal:attributes="action string:${reply/absolute_url}/@@moderate-publish-comment;
name action/id">
<input type="hidden" name="workflow_action" tal:attributes="value action/id" />
<input name="form.button.PublishComment"
class="context"
type="submit"
tal:attributes="value action/title"
i18n:attributes="value"
/>
</form>
</div>


</div>
<button class="context reply-to-comment-button hide allowMultiSubmit"
tal:condition="python:isDiscussionAllowed and (isAnon and isAnonymousDiscussionAllowed or userHasReplyPermission)"
i18n:translate="label_reply">
Reply
</button>
</div>

</tal:getreplies>

<div tal:condition="python: has_replies and not isDiscussionAllowed"
class="discreet"
i18n:translate="label_commenting_disabled">
Commenting has been disabled.
</div>

</div>

<div class="reply"
tal:condition="python:has_replies and (isAnon and not isAnonymousDiscussionAllowed)">
<form tal:attributes="action view/login_action">
<input class="standalone"
style="margin-bottom: 1.25em;"
type="submit"
value="Log in to add comments"
i18n:attributes="value label_login_to_add_comments;"
/>
</form>
</div>

<div id="commenting" class="reply" tal:condition="python:isDiscussionAllowed and (isAnon and isAnonymousDiscussionAllowed or userHasReplyPermission)">

<fieldset>

<legend i18n:translate="label_add_comment">Add comment</legend>
<p tal:content="view/comment_transform_message">
You can add a comment by filling out the form below. Plain text
formatting.
</p>

<div tal:replace="structure view/form/render" />

</fieldset>
</div>

</tal:block>

0 comments on commit 40f3378

Please sign in to comment.