show login form instead of the commenting form to anonymous users.
svn path=/plone.app.discussion/trunk/; revision=27194
This commit is contained in:
		
							parent
							
								
									77e8093c53
								
							
						
					
					
						commit
						aa50c33d8d
					
				@ -5,6 +5,18 @@
 | 
			
		||||
                   errors options/state/getErrors|nothing;"
 | 
			
		||||
           i18n:domain="plone">
 | 
			
		||||
 | 
			
		||||
    <div class="reply"
 | 
			
		||||
         tal:condition="isAnon">
 | 
			
		||||
        <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:condition="python:replies or (userHasReplyPermission and isDiscussionAllowed) or (isAnon and not userHasReplyPermission and isDiscussionAllowed)">
 | 
			
		||||
        <tal:getreplies repeat="reply_dict replies">
 | 
			
		||||
@ -73,7 +85,21 @@
 | 
			
		||||
        </tal:getreplies>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div class="reply">
 | 
			
		||||
    <div class="reply"
 | 
			
		||||
         tal:condition="isAnon">
 | 
			
		||||
        <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="reply"
 | 
			
		||||
         tal:condition="not:isAnon">
 | 
			
		||||
 | 
			
		||||
        <fieldset>
 | 
			
		||||
 | 
			
		||||
            <legend i18n:translate="legend_add_comment">Add comment</legend>
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,7 @@
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
 | 
			
		||||
from urllib import quote as url_quote
 | 
			
		||||
 | 
			
		||||
from zope.interface import implements
 | 
			
		||||
 | 
			
		||||
from zope.component import createObject
 | 
			
		||||
@ -16,6 +18,8 @@ from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
 | 
			
		||||
 | 
			
		||||
from Products.CMFCore.utils import getToolByName
 | 
			
		||||
 | 
			
		||||
from plone.app.layout.viewlets.common import ViewletBase
 | 
			
		||||
 | 
			
		||||
from plone.app.discussion.interfaces import IComment, IReplies
 | 
			
		||||
from plone.app.discussion.conversation import conversationAdapterFactory
 | 
			
		||||
 | 
			
		||||
@ -32,7 +36,7 @@ class View(BrowserView):
 | 
			
		||||
        comment_id = aq_parent(self).id
 | 
			
		||||
        self.request.response.redirect(aq_parent(aq_parent(aq_parent(self))).absolute_url() + '#comment-' + comment_id)
 | 
			
		||||
 | 
			
		||||
class CommentsViewlet(BrowserView):
 | 
			
		||||
class CommentsViewlet(ViewletBase):
 | 
			
		||||
    """Discussion Viewlet
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
@ -40,13 +44,6 @@ class CommentsViewlet(BrowserView):
 | 
			
		||||
 | 
			
		||||
    template = ViewPageTemplateFile('comments.pt')
 | 
			
		||||
 | 
			
		||||
    def __init__(self, context, request, view, manager):
 | 
			
		||||
        super(CommentsViewlet, self).__init__(context, request)
 | 
			
		||||
        self.__parent__ = view
 | 
			
		||||
        self.view = view
 | 
			
		||||
        self.manager = manager
 | 
			
		||||
        self.portal_state = getMultiAdapter((context, self.request), name=u"plone_portal_state")
 | 
			
		||||
 | 
			
		||||
    def update(self):
 | 
			
		||||
        super(CommentsViewlet, self).update()
 | 
			
		||||
        self.portal_discussion = getToolByName(self.context, 'portal_discussion', None)
 | 
			
		||||
@ -69,6 +66,8 @@ class CommentsViewlet(BrowserView):
 | 
			
		||||
    def is_anonymous(self):
 | 
			
		||||
        return self.portal_state.anonymous()
 | 
			
		||||
 | 
			
		||||
    def login_action(self):
 | 
			
		||||
        return '%s/login_form?came_from=%s' % (self.navigation_root_url, url_quote(self.request.get('URL', '')),)
 | 
			
		||||
 | 
			
		||||
    def format_time(self, time):
 | 
			
		||||
        # TODO: to localized time not working!!!
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user