Example #1
0
 def isFollowed(self):
     """判断当前话题是否已被关注,返回boolean"""
     obj = self.context
     aobj = IFollowing(obj)        
     userobject = self.pm().getAuthenticatedMember()
     userid = userobject.getId()
     return aobj.available(userid)
Example #2
0
def SubscriberFollowed(obj,event):
    mp = getToolByName(obj,'portal_membership')
#     import pdb
#     pdb.set_trace()
    userobject = mp.getAuthenticatedMember()
    username = userobject.getId()
    fwqlist = list(userobject.getProperty('myfollowquestion'))
    fwtlist = list(userobject.getProperty('myfollowtopic'))
    fwlist = list(userobject.getProperty('myfollow'))

    
    uuid = IUUID(obj,None)
    if uuid == None:return
    if not (uuid in fwlist):
        fwlist.append(uuid)   
        userobject.setProperties(myfollow=fwlist)
        
    if Iquestion.providedBy(obj) and not(uuid in fwqlist):
        fwqlist.append(uuid)   
        userobject.setProperties(myfollowquestion=fwqlist)        
    if Itopic.providedBy(obj) and not(uuid in fwtlist):
        fwtlist.append(uuid)   
        userobject.setProperties(myfollowtopic=fwtlist)         
        
    evlute = IFollowing(obj)    
    if  evlute.available(username):
        evlute.addFollow(username)
        obj.followernum = evlute.followerNum
        obj.reindexObject() 
Example #3
0
 def isFollowed(self,qbrain):
     """给定问题qbrain,判断该该问题是否已被关注,返回boolean"""
     obj = qbrain.getObject()
     aobj = IFollowing(obj)
     userobject = self.mp().getAuthenticatedMember()
     userid = userobject.getId()         
     return aobj.available(userid)
Example #4
0
 def Questionisfollowed(self,question):
     """判断当前问题是否已被关注,返回boolean"""
     obj = question.getObject()
     aobj = IFollowing(obj)
     
     userobject = self.pm().getAuthenticatedMember()
     userid = userobject.getId()
     return aobj.available(userid)
Example #5
0
 def isFollowed(self):
     """判断当前问题是否已被当前用户关注,返回boolean"""
     obj = (self.context).getParentNode()
     aobj = IFollowing(obj)
     pm = getToolByName(self.context, 'portal_membership')
     userobject = self.pm().getAuthenticatedMember()
     userid = userobject.getId()        
     return aobj.available(userid)
Example #6
0
 def Topicisfollowed(self,topic):
     """判断当前话题是否已被关注,返回boolean"""
     obj = topic.getObject()
     aobj = IFollowing(obj)
     pm = getToolByName(self.context, 'portal_membership')
     userobject = pm.getAuthenticatedMember()
     userid = userobject.getId()       
     return aobj.available(userid)
Example #7
0
    def questionIsFollowed(self,qobj):
        """判断指定的问题是否已被关注,返回boolean"""
#        obj = qbrain.getObject()
        aobj = IFollowing(qobj)
        pm = getToolByName(self.context, 'portal_membership')
        userobject = pm.getAuthenticatedMember()
        userid = userobject.getId()
        return aobj.available(userid)   
Example #8
0
 def Questionisfollowed(self, question):
     """判断当前问题是否已被关注,返回boolean"""
     obj = question.getObject()
     aobj = IFollowing(obj)
     pm = getToolByName(self.context, "portal_membership")
     userobject = pm.getAuthenticatedMember()
     userid = userobject.getId()
     return aobj.available(userid)
Example #9
0
 def isFollowed(self,brain):
     """判断当前问题是否已被当前用户关注,返回boolean"""
     
     userobject = self.mp().getAuthenticatedMember()        
     username = userobject.getId()
     obj = brain.getObject().getParentNode()
     aobj = IFollowing(obj)       
     return aobj.available(username)
Example #10
0
 def isFollowed(self,brain):
     """提供一个问题的brain,判断当前问题是否已被关注,返回boolean"""
     obj = brain.getObject()
     aobj = IFollowing(obj)
     
     userobject = self.pm().getAuthenticatedMember()
     userid = userobject.getId()            
     return aobj.available(userid)
Example #11
0
 def isFollowed(self,qbrain):
     """给定问题qbrain,判断该该问题是否已被关注,返回boolean"""
     obj = qbrain.getObject()
     aobj = IFollowing(obj)
     pm = getToolByName(self.context, 'portal_membership')
     userobject = pm.getAuthenticatedMember()
     userid = userobject.getId()                
     return aobj.available(userid)
Example #12
0
 def isFollowedByQuestion(self,qbrain):
     """根据问题brain判断该问题是否被当前用户关注,返回布尔值
     """
     obj = (self.context).getParentNode()
     aobj = IFollowing(obj)
     
     userobject = self.pm().getAuthenticatedMember()
     userid = userobject.getId()        
     return aobj.available(userid)
Example #13
0
class Follow(base.ViewletBase):

    follow = None
    is_manager = None
    can_follow = None

    # Update methods are guaranteed to be called before rendering for
    # Viewlets and Portlets (Because they are IContentProvider objects)
    # and for z3c.forms and formlib forms. But *not* for normal Browser Pages
    def update(self):
        super(Follow, self).update()

        if self.follow is None:
            self.follow = IFollowing(self.context)

        if self.is_manager is None:
            self.pm = getToolByName(self.context, 'portal_membership')
            self.is_manager = self.pm.checkPermission(
                ViewManagementScreens, self.context)
            self.can_follow = self.pm.checkPermission(
                DoFollow, self.context)

    def Isfollowed(self):
        "是否已被当前用户关注"
        userid = self.pm.getAuthenticatedMember().getId()
        return (self.follow.available(userid))
Example #14
0
    def test_questionfollowed_event(self):
        from emc.kb.contents.question import Iquestion
        from emc.kb.interfaces import IFollowing
        from emc.kb.events import FollowedEvent
        from emc.kb.events import UnFollowedEvent
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Manager',))
        portal.invokeFactory('emc.kb.folder', 'folder')
        portal['folder'].invokeFactory('emc.kb.questionfolder', 'questionfolder')
        portal['folder']['questionfolder'].invokeFactory('emc.kb.question', 'question',
                             description=u"discription",
                             additional=u"additional"

                             )
        
        file=portal['folder']['questionfolder']['question']
        
        event.notify(FollowedEvent(file))
        
        mp = getToolByName(portal,'portal_membership')
        userobject = mp.getAuthenticatedMember()
        username = userobject.getId()
        questionlist = list(userobject.getProperty('myfollow'))

        evlute = IFollowing(file)
        uuid = IUUID(file,None)
        
        self.assertTrue(uuid in questionlist)
        self.assertFalse(evlute.available(username))
        self.assertEqual(1, evlute.followerNum)
        
        event.notify(UnFollowedEvent(file))
        
        mp = getToolByName(portal,'portal_membership')
        userobject = mp.getAuthenticatedMember()
        username = userobject.getId()
        questionlist = list(userobject.getProperty('myfollow'))
        evlute = IFollowing(file)
        
        self.assertFalse(uuid in questionlist)
        self.assertTrue(evlute.available(username))
        self.assertEqual(0, evlute.followerNum)
Example #15
0
    def update(self):
        super(Follow, self).update()

        if self.follow is None:
            self.follow = IFollowing(self.context)

        if self.is_manager is None:
            self.pm = getToolByName(self.context, 'portal_membership')
            self.is_manager = self.pm.checkPermission(
                ViewManagementScreens, self.context)
            self.can_follow = self.pm.checkPermission(
                DoFollow, self.context)
Example #16
0
 def isFollowed(self,brain):
     """判断当前问题是否已被当前用户关注,返回boolean"""
     obj = brain.getObject().getParentNode()
     aobj = IFollowing(obj)         
     return aobj.available(self.username)