예제 #1
0
 def isFollowed(self):
     obj = self.context
     aobj = IEvaluate(obj)
     pm = getToolByName(self.context, 'portal_membership')
     userobject = pm.getAuthenticatedMember()
     userid = userobject.getId()
     return aobj.available(userid)
예제 #2
0
def UnFavoriteAnswer(obj,event):
    """del the answer from the favorite"""
    mp = getToolByName(obj,'portal_membership')
    userobject = mp.getAuthenticatedMember()
    username = userobject.getId()
    favoritelist = list(userobject.getProperty('myfavorite'))
    
    if  obj.id in favoritelist:
        favoritelist.remove(obj.id)
        userobject.setProperties(myfavorite=favoritelist)
        
    evlute = IEvaluate(obj)
    if evlute.favavailable(username):
        evlute.delfavorite(username)
예제 #3
0
def FavoriteAnswer(obj,event):
    """add the answer to favorite"""
    
    mp = getToolByName(obj,'portal_membership')
    userobject = mp.getAuthenticatedMember()
    username = userobject.getId()
    favoritelist = list(userobject.getProperty('myfavorite'))
    
    if not obj.id in favoritelist:
        favoritelist.append(obj.id)
        userobject.setProperties(myfavorite=favoritelist)
        
    evlute = IEvaluate(obj)
    if not evlute.favavailable(username):
        evlute.addfavorite(username)
예제 #4
0
def UnFollowed(obj,event):
    mp = getToolByName(obj,'portal_membership')
    userobject = mp.getAuthenticatedMember()
    username = userobject.getId()
    questionlist = list(userobject.getProperty('myquestions'))
    if obj.id in questionlist:
        questionlist.remove(obj.id)
        userobject.setProperties(myquestions=questionlist)

    evlute = IEvaluate(obj)
    
    if evlute.available(username):
        evlute.delfollow(username)
        obj.followernum = evlute.followerNum
        obj.reindexObject()  
예제 #5
0
def Followed(obj,event):
#    import pdb
#    pdb.set_trace()
    mp = getToolByName(obj,'portal_membership')
    userobject = mp.getAuthenticatedMember()
    username = userobject.getId()
    questionlist = list(userobject.getProperty('myquestions'))
    if not obj.id in questionlist:
        questionlist.append(obj.id)
        userobject.setProperties(myquestions=questionlist)
    evlute = IEvaluate(obj)
    if not evlute.available(username):
        evlute.addfollow(username)
        obj.followernum = evlute.followerNum
        obj.reindexObject()         
예제 #6
0
def disapprove(obj, event):
    """approve the answer"""
    
    mp = getToolByName(obj,'portal_membership')
    userobject= mp.getAuthenticatedMember()
    username = userobject.getId()
    disagreelist = list(userobject.getProperty('myunlike'))
    
    if not obj.id in disagreelist:
        disagreelist.append(obj.id)
        userobject.setProperties(myunlike=disagreelist)
    
    evlute = IEvaluate(obj)
    if not evlute.voteavailabledisapproved(username):
        evlute.disagree(username)
        obj.voteNum = evlute.voteNum
        obj.totalNum = evlute.voteNum - len(evlute.disapproved)
        obj.reindexObject() 
예제 #7
0
    def test_followed_event(self):
        from collective.conference.conference import IConference
        from collective.conference.interfaces import IEvaluate

        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Manager',))
        portal.invokeFactory('collective.conference.conference', 'conference1',
                             title=u'conference1',
                             participants=['member1'])
        portal['conference1'].invokeFactory('collective.conference.session', 'session1',
                             description=u"description",
                             additional=u"additional"

                             )
        
        file=portal['conference1']['session1']
        file=portal['conference1']        
        event.notify(FollowedEvent(file))
        
        mp = getToolByName(portal,'portal_membership')
        userobject = mp.getAuthenticatedMember()
        username = userobject.getUserName()
#        import pdb
#        pdb.set_trace()
        questionlist = userobject.getProperty('myquestions')
        evlute = IEvaluate(file)
        
        self.assertTrue(file.id in questionlist)
        
        self.assertTrue(evlute.favavailable(username))
        self.assertEqual(1, evlute.followerNum)
        
        event.notify(UnfollowedEvent(file))
        
        mp = getToolByName(portal,'portal_membership')
        userobject = mp.getAuthenticatedMember()
        username = userobject.getUserName()
        questionlist = userobject.getProperty('myquestions')
        evlute = IEvaluate(file)
        
        self.assertFalse(file.id in questionlist)
        self.assertFalse(evlute.available(username))
        self.assertEqual(0, evlute.followerNum)
# fire register conf event        
        event.notify(RegisteredConfEvent(file))
        clists = userobject.getProperty('conferences')
        plists = file.participants
        self.assertTrue(file.id in clists)
#        username = '******'
        self.assertTrue(username in plists)
                        
        recorders = userobject.getProperty('bonusrecorder')
        useremail = userobject.getUserName()
     
        self.assertTrue(useremail in recorders[-1])
        self.assertTrue(file.title in recorders[-1])        
# fire unregister conf event        
        event.notify(UnRegisteredConfEvent(file))
        clists = userobject.getProperty('conferences')
        plists = file.participants
        self.assertFalse(file.id in clists)
#        username = '******'
        self.assertFalse(username in plists)
                        
        recorders = userobject.getProperty('bonusrecorder')
        useremail = userobject.getUserName()
     
        self.assertTrue(useremail in recorders[-1])
        self.assertTrue(file.title in recorders[-1])
        
          
# fire register session event        
        event.notify(RegisteredSessionEvent(file))
        slists = userobject.getProperty('speeches')
        plists = file.participants
        speaklists = file.speakers        
        
        self.assertTrue(file.id in slists)
        self.assertTrue(username in plists)
        self.assertTrue(username in speaklists)