def testChangesInAuthorData(self):
        #Checks that changes in the author data updates the author index
        #   correctly
        c1 = Contribution()
        self._conf.addContribution(c1)
        auth1, auth2 = ContributionParticipation(), ContributionParticipation()
        auth1.setFirstName("zFN")
        auth1.setFamilyName("zSN")
        auth1.setEmail("zM")
        auth2.setFirstName("AFN")
        auth2.setFamilyName("ASN")
        auth2.setEmail("aM")
        c1.addPrimaryAuthor(auth1)
        c1.addPrimaryAuthor(auth2)

        idx = self._conf.getAuthorIndex()
        self.assert_(auth1 in idx.getParticipations()[1])
        self.assert_(len(idx.getParticipations()[1]) == 1)
        self.assert_(auth2 in idx.getParticipations()[0])
        self.assert_(len(idx.getParticipations()[0]) == 1)
        auth2.setFamilyName("ZZSN")
        self.assert_(auth1 in idx.getParticipations()[0])
        self.assert_(len(idx.getParticipations()[0]) == 1)
        self.assert_(auth2 in idx.getParticipations()[1])
        self.assert_(len(idx.getParticipations()[1]) == 1)
 def testWithdrawnContrib(self):
     #Withdrawn contributions authors must be searchable
     c1=Contribution()
     self._conf.addContribution(c1)
     auth1=ContributionParticipation()
     auth1.setFamilyName("a")
     auth1.setFirstName("a")
     c1.addPrimaryAuthor(auth1)
     c1.withdraw(self._creator,"ll")
     self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
     auth2=ContributionParticipation()
     auth2.setFamilyName("b")
     auth2.setFirstName("b")
     c1.addPrimaryAuthor(auth2)
 def testChangesInAuthorData(self):
     #Checks that changes in the author data updates the author index 
     #   correctly
     c1=Contribution()
     self._conf.addContribution(c1)
     auth1,auth2=ContributionParticipation(),ContributionParticipation()
     auth1.setFirstName("zFN")
     auth1.setFamilyName("zSN")
     auth1.setEmail("zM")
     auth2.setFirstName("AFN")
     auth2.setFamilyName("ASN")
     auth2.setEmail("aM")
     c1.addPrimaryAuthor(auth1)
     c1.addPrimaryAuthor(auth2)
     
     idx=self._conf.getAuthorIndex()
     self.assert_(auth1 in idx.getParticipations()[1])
     self.assert_(len(idx.getParticipations()[1])==1)
     self.assert_(auth2 in idx.getParticipations()[0])
     self.assert_(len(idx.getParticipations()[0])==1)
     auth2.setFamilyName("ZZSN")
     self.assert_(auth1 in idx.getParticipations()[0])
     self.assert_(len(idx.getParticipations()[0])==1)
     self.assert_(auth2 in idx.getParticipations()[1])
     self.assert_(len(idx.getParticipations()[1])==1)
 def testAuthorsWithSameName(self):
     #one contribution could have 2 authors with the same name
     c1=Contribution()
     self._conf.addContribution(c1)
     auth1=ContributionParticipation()
     auth1.setFamilyName("a")
     auth1.setFirstName("a")
     c1.addPrimaryAuthor(auth1)
     auth2=ContributionParticipation()
     auth2.setFamilyName("a")
     auth2.setFirstName("a")
     c1.addPrimaryAuthor(auth2)
     self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
     c1.removePrimaryAuthor(auth1)
     self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
 def testBasicSearch(self):
     c1=Contribution()
     self._conf.addContribution(c1)
     auth1,auth2=ContributionParticipation(),ContributionParticipation()
     auth1.setFamilyName("a")
     auth1.setFirstName("a")
     auth2.setFamilyName("b")
     auth2.setFirstName("b")
     c1.addPrimaryAuthor(auth1)
     c1.addPrimaryAuthor(auth2)
     self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
     self.assert_(c1 in self._conf.getContribsMatchingAuth("B"))
     self.assert_(len(self._conf.getContribsMatchingAuth("B"))==1)
     auth3=ContributionParticipation()
     auth3.setFamilyName("c")
     auth3.setFirstName("c")
     c1.addCoAuthor(auth3)
     self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
     self.assert_(len(self._conf.getContribsMatchingAuth("c"))==0)
 def testAddAuthor(self):
     c1=Contribution()
     self._conf.addContribution(c1)
     auth1,auth2=ContributionParticipation(),ContributionParticipation()
     auth1.setFamilyName("a")
     auth1.setFirstName("a")
     auth2.setFamilyName("b")
     auth2.setFirstName("b")
     c1.addPrimaryAuthor(auth1)
     self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
     c1.addPrimaryAuthor(auth2)
     self.assert_(len(self._conf.getContribsMatchingAuth("b"))==1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("b"))
     c1.removePrimaryAuthor(auth1)
     self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a"))==0)
     self.assert_(c1 not in self._conf.getContribsMatchingAuth("a"))
     self.assert_(len(self._conf.getContribsMatchingAuth("b"))==1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("b"))
def sync(confId):
    DBMgr.getInstance().startRequest()
    conf = ConferenceHolder().getById(confId)
    counter = []

    if conf is None:
        raise Exception("Error fetching conference")
    else:
        for abstract in conf.getAbstractMgr().getAbstractList():
            if isinstance(abstract.getCurrentStatus(), AbstractStatusAccepted):
                contrib = abstract.getContribution()
                contrib.setTitle(abstract.getTitle())
                contrib.setDescription(abstract.getField('content'))
                contrib.setField('summary', abstract.getField('summary'))
                contrib.setTrack(abstract.getCurrentStatus().getTrack())
                contrib.setType(abstract.getCurrentStatus().getType())

                for auth1 in contrib.getPrimaryAuthorList()[:]:
                    contrib.removePrimaryAuthor(auth1)
                for auth2 in contrib.getCoAuthorList()[:]:
                    contrib.removeCoAuthor(auth2)
                for auth3 in contrib.getSpeakerList()[:]:
                    contrib.removeSpeaker(auth3)
                for auth in abstract.getAuthorList():
                    c_auth = ContributionParticipation()
                    contrib._setAuthorValuesFromAbstract(c_auth, auth)
                    if abstract.isPrimaryAuthor(auth):
                        contrib.addPrimaryAuthor(c_auth)
                    else:
                        contrib.addCoAuthor(c_auth)
                    if abstract.isSpeaker(auth):
                        contrib.addSpeaker(c_auth)

                # TODO: remove the previous submitter...how???
                submitter = contrib.getAbstract().getSubmitter().getUser()
                contrib._grantSubmission(submitter)
                counter.append(contrib.getId())

    DBMgr.getInstance().endRequest()
    print "%s contributions synchronized (%s)" % (len(counter),
                                                  ', '.join(counter))
 def testAddAuthor(self):
     c1 = Contribution()
     self._conf.addContribution(c1)
     auth1, auth2 = ContributionParticipation(), ContributionParticipation()
     auth1.setFamilyName("a")
     auth1.setFirstName("a")
     auth2.setFamilyName("b")
     auth2.setFirstName("b")
     c1.addPrimaryAuthor(auth1)
     self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
     c1.addPrimaryAuthor(auth2)
     self.assert_(len(self._conf.getContribsMatchingAuth("b")) == 1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("b"))
     c1.removePrimaryAuthor(auth1)
     self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 0)
     self.assert_(c1 not in self._conf.getContribsMatchingAuth("a"))
     self.assert_(len(self._conf.getContribsMatchingAuth("b")) == 1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("b"))
Exemple #9
0
def make_participation_from_obj(obj, contrib_participation=None):
    """Convert a user-like object to a ContributionParticipation

    :param obj: The object to take the values of the ContributionParticipation
                from
    :param contrib_participation: In case the return object has been initialised
                                  outside of the function
    :return: a ContributionParticipation object
    """
    if contrib_participation is None:
        contrib_participation = ContributionParticipation()
    contrib_participation.setTitle(obj.getTitle())
    contrib_participation.setFirstName(obj.getName())
    contrib_participation.setFamilyName(obj.getSurName())
    contrib_participation.setEmail(obj.getEmail())
    contrib_participation.setAddress(obj.getAddress())
    contrib_participation.setFax(obj.getFax())
    contrib_participation.setAffiliation(obj.getAffiliation())
    contrib_participation.setPhone(obj.getPhone())
    return contrib_participation
 def testBasicWithdrawal(self):
     c1,c2=Contribution(),Contribution()
     auth1,auth2=ContributionParticipation(),ContributionParticipation()
     self._conf.addContribution(c1)
     self._conf.addContribution(c2)
     auth1.setFirstName("a")
     auth1.setFamilyName("a")
     auth1.setEmail("a")
     auth2.setFirstName("b")
     auth2.setFamilyName("b")
     auth2.setEmail("b")
     c1.addPrimaryAuthor(auth1)
     c2.addPrimaryAuthor(auth2)
     s1=Session()
     sd=datetime(2004, 01, 01, 12, 00, tzinfo=timezone("UTC"))
     ed=datetime(2004, 01, 01, 19, 00, tzinfo=timezone("UTC"))
     s1.setDates(sd,ed)
     slot1=SessionSlot(s1)
     self._conf.addSession(s1)
     s1.addSlot(slot1)
     s1.addContribution(c1)
     s1.addContribution(c2)
     slot1.getSchedule().addEntry(c1.getSchEntry())
     slot1.getSchedule().addEntry(c2.getSchEntry())
     self.assert_(c1.isScheduled())
     self.assert_(c2.isScheduled())
     authIdx=self._conf.getAuthorIndex()
     self.assert_(auth1 in authIdx.getParticipations()[0])
     self.assert_(auth2 in authIdx.getParticipations()[1])
     c1.withdraw(self._creator,"test")
     self.assert_(not c1.isScheduled())
     self.assert_(c2.isScheduled())
     self.assert_(auth1 not in authIdx.getParticipations()[0])
     self.assert_(auth2 in authIdx.getParticipations()[0])
     auth1.setFirstName("aa")
     self.assert_(auth1 not in authIdx.getParticipations()[0])
     self.assert_(auth2 in authIdx.getParticipations()[0])
     auth3,auth4=ContributionParticipation(),ContributionParticipation()
     auth3.setFirstName("c")
     auth3.setFamilyName("c")
     auth3.setEmail("c")
     auth4.setFirstName("d")
     auth4.setFamilyName("d")
     auth4.setEmail("d")
     c1.addPrimaryAuthor(auth3)
     c2.addPrimaryAuthor(auth4)
     self.assert_(auth2 in authIdx.getParticipations()[0])
     self.assert_(auth4 in authIdx.getParticipations()[1])
     self.assertRaises(MaKaCError,slot1.getSchedule().addEntry,c1.getSchEntry())
Exemple #11
0
    def _process( self ):
        params = self._getRequestParams()
        self._errorList = []

        #raise "%s"%params
        taskId = params["taskId"]

        taskObject = self._target.getTask(taskId)
        if params.get("orgin","") == "new" :
            if params.get("ok",None) is None :
                raise MaKaCError("not ok")
                url = urlHandlers.UHTaskDetails.getURL(self._target)
                url.addParam("taskId",params["taskId"])
                self._redirect(url)
                return
            else :
                person = ContributionParticipation()
                person.setFirstName(params["name"])
                person.setFamilyName(params["surName"])
                person.setEmail(params["email"])
                person.setAffiliation(params["affiliation"])
                person.setAddress(params["address"])
                person.setPhone(params["phone"])
                person.setTitle(params["title"])
                person.setFax(params["fax"])
                if not self._alreadyDefined(person, taskObject.getResponsibleList()) :
                    taskObject.addResponsible(person)
                else :
                    self._errorList.append("%s has been already defined as %s of this task"%(person.getFullName(),self._typeName))

        elif params.get("orgin","") == "selected" :
            selectedList = self._normaliseListParam(self._getRequestParams().get("selectedPrincipals",[]))
            for s in selectedList :
                if s[0:8] == "*author*" :
                    auths = self._conf.getAuthorIndex()
                    selected = auths.getById(s[9:])[0]
                else :
                    ph = user.PrincipalHolder()
                    selected = ph.getById(s)
                if isinstance(selected, user.Avatar) :
                    person = ContributionParticipation()
                    person.setDataFromAvatar(selected)
                    if not self._alreadyDefined(person, taskObject.getResponsibleList()) :
                        taskObject.addResponsible(person)
                    else :
                        self._errorList.append("%s has been already defined as %s of this task"%(person.getFullName(),self._typeName))

                elif isinstance(selected, user.Group) :
                    for member in selected.getMemberList() :
                        person = ContributionParticipation()
                        person.setDataFromAvatar(member)
                        if not self._alreadyDefined(person, taskObject.getResponsibleList()) :
                            taskObject.addResponsible(person)
                        else :
                            self._errorList.append("%s has been already defined as %s of this task"%(person.getFullName(),self._typeName))

                else :
                    person = ContributionParticipation()
                    person.setTitle(selected.getTitle())
                    person.setFirstName(selected.getFirstName())
                    person.setFamilyName(selected.getFamilyName())
                    person.setEmail(selected.getEmail())
                    person.setAddress(selected.getAddress())
                    person.setAffiliation(selected.getAffiliation())
                    person.setPhone(selected.getPhone())
                    person.setFax(selected.getFax())
                    if not self._alreadyDefined(person, taskObject.getResponsibleList()) :
                        taskObject.addResponsible(person)
                    else :
                        self._errorList.append("%s has been already defined as %s of this task"%(person.getFullName(),self._typeName))
            else :
                url = urlHandlers.UHTaskDetails.getURL(self._target)
                url.addParam("taskId",params["taskId"])
                self._redirect(url)
                return

        url = urlHandlers.UHTaskDetails.getURL(self._target)
        url.addParam("taskId",params["taskId"])
        self._redirect(url)
Exemple #12
0
    def _process( self ):
        params = self._getRequestParams()
        self._errorList = []

        #raise "%s"%params
        definedList = self._getDefinedList(self._typeName)
        if definedList is None :
            definedList = []

        if params.get("orgin","") == "new" :
            #raise "new"
            if params.get("ok",None) is None :
                raise MaKaCError("not ok")
                self._redirect(urlHandlers.UHTaskNew.getURL(self._target))
                return
            else:
                person = ContributionParticipation()
                person.setFirstName(params["name"])
                person.setFamilyName(params["surName"])
                person.setEmail(params["email"])
                person.setAffiliation(params["affiliation"])
                person.setAddress(params["address"])
                person.setPhone(params["phone"])
                person.setTitle(params["title"])
                person.setFax(params["fax"])
                if not self._alreadyDefined(person, definedList) :
                    definedList.append([person,params.has_key("submissionControl")])
                else :
                    self._errorList.append( _("%s has been already defined as %s of this contribution")%(person.getFullName(),self._typeName))

        elif params.get("orgin","") == "selected" :
            selectedList = self._normaliseListParam(self._getRequestParams().get("selectedPrincipals",[]))
            for s in selectedList :
                if s[0:8] == "*author*" :
                    auths = self._conf.getAuthorIndex()
                    selected = auths.getById(s[9:])[0]
                else :
                    ph = user.PrincipalHolder()
                    selected = ph.getById(s)
                if isinstance(selected, user.Avatar) :
                    person = ContributionParticipation()
                    person.setDataFromAvatar(selected)
                    if not self._alreadyDefined(person, definedList) :
                        definedList.append([person,params.has_key("submissionControl")])
                    else :
                        self._errorList.append( _("%s has been already defined as %s of this contribution")%(person.getFullName(),self._typeName))

                elif isinstance(selected, user.Group) :
                    for member in selected.getMemberList() :
                        person = ContributionParticipation()
                        person.setDataFromAvatar(member)
                        if not self._alreadyDefined(person, definedList) :
                            definedList.append([person,params.has_key("submissionControl")])
                        else :
                            self._errorList.append( _("%s has been already defined as %s of this contribution")%(presenter.getFullName(),self._typeName))
                else :
                    person = ContributionParticipation()
                    person.setTitle(selected.getTitle())
                    person.setFirstName(selected.getFirstName())
                    person.setFamilyName(selected.getFamilyName())
                    person.setEmail(selected.getEmail())
                    person.setAddress(selected.getAddress())
                    person.setAffiliation(selected.getAffiliation())
                    person.setPhone(selected.getPhone())
                    person.setFax(selected.getFax())
                    if not self._alreadyDefined(person, definedList) :
                        definedList.append([person,params.has_key("submissionControl")])
                    else :
                        self._errorList.append( _("%s has been already defined as %s of this contribution")%(person.getFullName(),self._typeName))

        elif params.get("orgin","") == "added" :
            preservedParams = self._getPreservedParams()
            chosen = preservedParams.get("%sChosen"%self._typeName,None)
            if chosen is None or chosen == "" :
                self._redirect(urlHandlers.UHConfModScheduleNewContrib.getURL(self._target))
                return
            index = chosen.find("-")
            taskId = chosen[0:index]
            resId = chosen[index+1:len(chosen)]
            taskObject = self._target.getTask(taskId)
            chosenPerson = taskObject.getResponsibleList()[int(resId)]
            if chosenPerson is None :
                self._redirect(urlHandlers.UHConfModScheduleNewContrib.getURL(self._target))
                return
            person = ContributionParticipation()
            person.setTitle(chosenPerson.getTitle())
            person.setFirstName(chosenPerson.getFirstName())
            person.setFamilyName(chosenPerson.getFamilyName())
            person.setEmail(chosenPerson.getEmail())
            person.setAddress(chosenPerson.getAddress())
            person.setAffiliation(chosenPerson.getAffiliation())
            person.setPhone(chosenPerson.getPhone())
            person.setFax(chosenPerson.getFax())
            if not self._alreadyDefined(person, definedList) :
                definedList.append([person,params.has_key("submissionControl")])
            else :
                self._errorList.append( _("%s has been already defined as %s of this contribution")%(person.getFullName(),self._typeName))
        else :
            self._redirect(urlHandlers.UHConfModifSchedule.getURL(self._target))
            return
        preservedParams = self._getPreservedParams()
        preservedParams["errorMsg"] = self._errorList
        self._preserveParams(preservedParams)
        self._websession.setVar("%sList"%self._typeName,definedList)

        self._redirect(urlHandlers.UHTaskNew.getURL(self._target))
Exemple #13
0
 def testWithdrawnContrib(self):
     #Withdrawn contributions authors must be searchable
     c1 = Contribution()
     self._conf.addContribution(c1)
     auth1 = ContributionParticipation()
     auth1.setFamilyName("a")
     auth1.setFirstName("a")
     c1.addPrimaryAuthor(auth1)
     c1.withdraw(self._creator, "ll")
     self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
     auth2 = ContributionParticipation()
     auth2.setFamilyName("b")
     auth2.setFirstName("b")
     c1.addPrimaryAuthor(auth2)
Exemple #14
0
    def _process(self):
        params = self._getRequestParams()
        self._errorList = []

        #raise "%s"%params
        taskId = params["taskId"]

        taskObject = self._target.getTask(taskId)
        if params.get("orgin", "") == "new":
            if params.get("ok", None) is None:
                raise "not ok"
                url = urlHandlers.UHTaskDetails.getURL(self._target)
                url.addParam("taskId", params["taskId"])
                self._redirect(url)
                return
            else:
                person = ContributionParticipation()
                person.setFirstName(params["name"])
                person.setFamilyName(params["surName"])
                person.setEmail(params["email"])
                person.setAffiliation(params["affiliation"])
                person.setAddress(params["address"])
                person.setPhone(params["phone"])
                person.setTitle(params["title"])
                person.setFax(params["fax"])
                if not self._alreadyDefined(person,
                                            taskObject.getResponsibleList()):
                    taskObject.addResponsible(person)
                else:
                    self._errorList.append(
                        "%s has been already defined as %s of this task" %
                        (person.getFullName(), self._typeName))

        elif params.get("orgin", "") == "selected":
            selectedList = self._normaliseListParam(
                self._getRequestParams().get("selectedPrincipals", []))
            for s in selectedList:
                if s[0:8] == "*author*":
                    auths = self._conf.getAuthorIndex()
                    selected = auths.getById(s[9:])[0]
                else:
                    ph = user.PrincipalHolder()
                    selected = ph.getById(s)
                if isinstance(selected, user.Avatar):
                    person = ContributionParticipation()
                    person.setDataFromAvatar(selected)
                    if not self._alreadyDefined(
                            person, taskObject.getResponsibleList()):
                        taskObject.addResponsible(person)
                    else:
                        self._errorList.append(
                            "%s has been already defined as %s of this task" %
                            (person.getFullName(), self._typeName))

                elif isinstance(selected, user.Group):
                    for member in selected.getMemberList():
                        person = ContributionParticipation()
                        person.setDataFromAvatar(member)
                        if not self._alreadyDefined(
                                person, taskObject.getResponsibleList()):
                            taskObject.addResponsible(person)
                        else:
                            self._errorList.append(
                                "%s has been already defined as %s of this task"
                                % (person.getFullName(), self._typeName))

                else:
                    person = ContributionParticipation()
                    person.setTitle(selected.getTitle())
                    person.setFirstName(selected.getFirstName())
                    person.setFamilyName(selected.getFamilyName())
                    person.setEmail(selected.getEmail())
                    person.setAddress(selected.getAddress())
                    person.setAffiliation(selected.getAffiliation())
                    person.setPhone(selected.getPhone())
                    person.setFax(selected.getFax())
                    if not self._alreadyDefined(
                            person, taskObject.getResponsibleList()):
                        taskObject.addResponsible(person)
                    else:
                        self._errorList.append(
                            "%s has been already defined as %s of this task" %
                            (person.getFullName(), self._typeName))
            else:
                url = urlHandlers.UHTaskDetails.getURL(self._target)
                url.addParam("taskId", params["taskId"])
                self._redirect(url)
                return

        url = urlHandlers.UHTaskDetails.getURL(self._target)
        url.addParam("taskId", params["taskId"])
        self._redirect(url)
class TestElectronicAgreement(IndicoTestCase):

    _requires = [Collaboration_Feature]

    def setUp(self):
        '''
        Create a conference, 0
        Add 2 contributions to this conference, 0 and 1
        To contribution 0 - Add 2 speakers, person1 and person2
        To contribution 1 - Add 1 speaker, person1
        '''
        super(TestElectronicAgreement, self).setUp()

        self._startDBReq()

        self.falseSession = FalseSession()
        # Create few users
        self._creator = Avatar({"name": "God", "email": "*****@*****.**"})
        self._creator.setId("creator")
        # Set God as admin
        AdminList.getInstance().getList().append(self._creator)

        self.person1 = Avatar({"name": "giuseppe", "email": "*****@*****.**"})
        self.person1.setId("spk1")
        self.person2 = Avatar({"name": "gabriele", "email": "*****@*****.**"})
        self.person1.setId("spk2")
        self.person3 = Avatar({"name": "lorenzo", "email": "*****@*****.**"})
        self.person1.setId("spk3")
        self.person4 = Avatar({"name": "silvio", "email": "*****@*****.**"})
        self.person1.setId("spk4")

        ah = AvatarHolder()
        ah.add(self.person1)
        ah.add(self.person2)
        ah.add(self.person3)
        ah.add(self.person4)

        # Create a conference
        category = conference.CategoryManager().getById('0')
        self._conf = category.newConference(self._creator)
        self._conf.setTimezone('UTC')
        sd = datetime(2011, 06, 01, 10, 00, tzinfo=timezone("UTC"))
        ed = datetime(2011, 06, 05, 10, 00, tzinfo=timezone("UTC"))
        self._conf.setDates(
            sd,
            ed,
        )
        ch = ConferenceHolder()
        ch.add(self._conf)

        # Create contributions and add to the conference
        c1, c2 = Contribution(), Contribution()
        self.speaker1, self.speaker2 = ContributionParticipation(
        ), ContributionParticipation()

        self.speaker1.setDataFromAvatar(self.person1)
        self.speaker2.setDataFromAvatar(self.person2)

        self._conf.addContribution(c2)
        self._conf.addContribution(c1)

        # Add speakers to contributions
        c1.addPrimaryAuthor(self.speaker1)
        c2.addPrimaryAuthor(self.speaker2)
        c1.addSpeaker(self.speaker1)
        c2.addSpeaker(self.speaker1)
        c2.addSpeaker(self.speaker2)

        self._conf.enableSessionSlots()

        # Create session and schedule the contributions
        s1 = Session()
        sd = datetime(2011, 06, 02, 12, 00, tzinfo=timezone("UTC"))
        ed = datetime(2011, 06, 02, 19, 00, tzinfo=timezone("UTC"))
        s1.setDates(sd, ed)

        slot1 = SessionSlot(s1)
        self._conf.addSession(s1)
        slot1.setValues({"sDate": sd})
        s1.addSlot(slot1)

        s1.addContribution(c1)
        s1.addContribution(c2)
        slot1.getSchedule().addEntry(c1.getSchEntry())
        slot1.getSchedule().addEntry(c2.getSchEntry())

        self.createAndAcceptBooking()
        self._stopDBReq()

    @with_context('database')
    def testRightsFiltering(self):
        '''
        Test if the managing rights are respected.
        '''
        manager = self._conf.getCSBookingManager()

        # Test that person3 has not access to webcasted talks
        requestType = CollaborationTools.getRequestTypeUserCanManage(
            self._conf, self.person3)
        contributions = manager.getContributionSpeakerByType(requestType)
        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s" %
                                                         (cont, spk.getId()))
                self.assert_(sw.getRequestType() == "recording"
                             or sw.getRequestType() == "both")

        # Test that person4 has not access to recorded talks
        requestType = CollaborationTools.getRequestTypeUserCanManage(
            self._conf, self.person4)
        contributions = manager.getContributionSpeakerByType(requestType)
        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s" %
                                                         (cont, spk.getId()))
                self.assert_(sw.getRequestType() == "webcast"
                             or sw.getRequestType() == "both")

    @with_context('database')
    def testNOEMAILStatus(self):
        '''
        Test if the status of the SpeakerWrapper is correctly updated to NOEMAIL.\n
        '''
        manager = self._conf.getCSBookingManager()

        contributions = manager.getContributionSpeakerByType("both")
        ''' Check change to NOEMAIL status, when delete the email of a speaker (here: speaker1)
            Should change to this status only if the previous status is NOTSIGNED or PENDING
        '''
        for cont in contributions:
            sw = manager.getSpeakerWrapperByUniqueId(
                "%s.%s" % (cont, self.speaker1.getId()))
            if sw:
                #remove the email from NOTSIGNED to NOEMAIL
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.NOEMAIL)

                #reset email, then remove email from PENDING to NOEMAIL
                self.changeEmailService(cont, self.speaker1.getId(),
                                        "*****@*****.**")
                sw.setStatus(SpeakerStatusEnum.PENDING)
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.NOEMAIL)

                #reset email, then remove email from SIGNED to SIGNED (no changes)
                self.changeEmailService(cont, self.speaker1.getId(),
                                        "*****@*****.**")
                sw.setStatus(SpeakerStatusEnum.SIGNED)
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.SIGNED)

                #reset email, then remove email from FROMFILE to FROMFILE (no changes)
                self.changeEmailService(cont, self.speaker1.getId(),
                                        "*****@*****.**")
                sw.setStatus(SpeakerStatusEnum.FROMFILE)
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.FROMFILE)

                #reset email, then remove email from REFUSED to REFUSED (no changes)
                self.changeEmailService(cont, self.speaker1.getId(),
                                        "*****@*****.**")
                sw.setStatus(SpeakerStatusEnum.REFUSED)
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.REFUSED)

    @with_context('database')
    def testPENDINGStatus(self):
        '''
        Test if the status of the SpeakerWrapper is correctly updated to PENDING.\n
        '''
        manager = self._conf.getCSBookingManager()
        contributions = manager.getContributionSpeakerByType("both")

        uniqueIdList = []

        for cont in contributions:
            for spk in contributions[cont]:
                uniqueIdList.append("%s.%s" % (cont, spk.getId()))

        self.sendEmailService(uniqueIdList)

        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s" %
                                                         (cont, spk.getId()))
                self.assert_(sw.getStatus() == SpeakerStatusEnum.PENDING)

    @with_context('database')
    def testSIGNEDStatus(self):
        '''
        Test if the status of the SpeakerWrapper is correctly updated to SIGNED.\n
        '''
        manager = self._conf.getCSBookingManager()
        contributions = manager.getContributionSpeakerByType("both")

        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s" %
                                                         (cont, spk.getId()))
                self.submitAgreementService(sw, 'accept')
                self.assert_(sw.getStatus() == SpeakerStatusEnum.SIGNED)

    @with_context('database')
    def testREFUSEDStatus(self):
        '''
        Test if the status of the SpeakerWrapper is correctly updated to REFUSED.\n
        '''
        manager = self._conf.getCSBookingManager()
        contributions = manager.getContributionSpeakerByType("both")

        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s" %
                                                         (cont, spk.getId()))
                self.submitAgreementService(sw, 'reject')
                self.assert_(sw.getStatus() == SpeakerStatusEnum.REFUSED)

#==========================================================================
# Here useful functions called during the tests

    def createAndAcceptBooking(self):
        manager = self._conf.getCSBookingManager()

        # Create a booking - Recording Request
        bookingParams = {
            'otherComments': '',
            'endDate': '',
            'talkSelection': ['0'],
            'numAttendees': '',
            'talks': '',
            'lectureStyle': 'lecturePresentation',
            'numRemoteViewers': '',
            'startDate': '',
            'postingUrgency': 'withinWeek'
        }
        # Create a booking - Webcast Request
        bookingParamsWeb = {'talkSelection': ['0'], 'talks': 'choose'}

        #Give rights to person3(recordingReq) and person4(webcastReq) (... _creator has both)
        manager.addPluginManager("RecordingRequest", self.person3)
        manager.addPluginManager("WebcastRequest", self.person4)

        if manager.canCreateBooking("RecordingRequest"):
            manager.createBooking("RecordingRequest", bookingParams)
        booking = manager.getSingleBooking("RecordingRequest")
        manager.acceptBooking(booking.getId())

        if manager.canCreateBooking("WebcastRequest"):
            manager.createBooking("WebcastRequest", bookingParamsWeb)
        booking = manager.getSingleBooking("WebcastRequest")
        manager.acceptBooking(booking.getId())

    def changeEmailService(self, contId, spkId, value):

        params = {
            'value': value,
            'confId': self._conf.getId(),
            'contribId': contId,
            'spkId': spkId
        }
        service = SetSpeakerEmailAddress(params, self.falseSession,
                                         self.falseSession)  #weird...
        service._checkParams()
        service._getAnswer()

    def sendEmailService(self, uniqueId):
        fromField = {"name": "No-reply", "email": "*****@*****.**"}
        content = "This is a test {url} {talkTitle}..."

        params = {
            'from': fromField,
            'content': content,
            'uniqueIdList': uniqueId,
            'confId': self._conf.getId()
        }
        service = SendElectronicAgreement(params, self.falseSession,
                                          self.falseSession)
        service._checkParams()
        service._getAnswer()

    def submitAgreementService(self, sw, decision):
        params = {
            'authKey': sw.getUniqueIdHash(),
            'confId': self._conf.getId(),
            'reason': 'because...'
        }

        if decision == 'accept':
            service = AcceptElectronicAgreement(params, self.falseSession,
                                                self.falseSession)
        else:
            service = RejectElectronicAgreement(params, self.falseSession,
                                                self.falseSession)

        service._checkParams()
        service._getAnswer()
Exemple #16
0
 def testBasicSearch(self):
     c1 = Contribution()
     self._conf.addContribution(c1)
     auth1, auth2 = ContributionParticipation(), ContributionParticipation()
     auth1.setFamilyName("a")
     auth1.setFirstName("a")
     auth2.setFamilyName("b")
     auth2.setFirstName("b")
     c1.addPrimaryAuthor(auth1)
     c1.addPrimaryAuthor(auth2)
     self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
     self.assert_(c1 in self._conf.getContribsMatchingAuth("B"))
     self.assert_(len(self._conf.getContribsMatchingAuth("B")) == 1)
     auth3 = ContributionParticipation()
     auth3.setFamilyName("c")
     auth3.setFirstName("c")
     c1.addCoAuthor(auth3)
     self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1)
     self.assert_(len(self._conf.getContribsMatchingAuth("c")) == 0)
Exemple #17
0
 def testBasicIndexing(self):
     #Tests adding a contribution with some authors already on it
     c1=Contribution()
     self._conf.addContribution(c1)
     auth1,auth2=ContributionParticipation(),ContributionParticipation()
     auth1.setFirstName("hector")
     auth1.setFamilyName("sanchez sanmartin")
     auth1.setEmail("*****@*****.**")
     auth2.setFirstName("jose benito")
     auth2.setFamilyName("gonzalez lopez")
     auth2.setEmail("*****@*****.**")
     c1.addPrimaryAuthor(auth1)
     c1.addPrimaryAuthor(auth2)
     idx=self._conf.getAuthorIndex()
     self.assert_(auth1 in idx.getParticipations()[1])
     self.assert_(len(idx.getParticipations()[1])==1)
     self.assert_(auth2 in idx.getParticipations()[0])
     self.assert_(len(idx.getParticipations()[0])==1)
     c2=Contribution()
     self._conf.addContribution(c2)
     auth3,auth4=ContributionParticipation(),ContributionParticipation()
     auth3.setFirstName("hector")
     auth3.setFamilyName("sanchez sanmartin")
     auth3.setEmail("*****@*****.**")
     auth4.setFirstName("jose benito")
     auth4.setFamilyName("gonzalez lopez2")
     auth4.setEmail("*****@*****.**")
     c2.addPrimaryAuthor(auth3)
     c2.addPrimaryAuthor(auth4)
Exemple #18
0
 def testAuthorsWithSameName(self):
     #one contribution could have 2 authors with the same name
     c1 = Contribution()
     self._conf.addContribution(c1)
     auth1 = ContributionParticipation()
     auth1.setFamilyName("a")
     auth1.setFirstName("a")
     c1.addPrimaryAuthor(auth1)
     auth2 = ContributionParticipation()
     auth2.setFamilyName("a")
     auth2.setFirstName("a")
     c1.addPrimaryAuthor(auth2)
     self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
     c1.removePrimaryAuthor(auth1)
     self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1)
     self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1)
     self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
Exemple #19
0
import sys
sys.path.append("c:/development/indico/code/code")
from MaKaC.common import DBMgr
DBMgr.getInstance().startRequest()
from MaKaC.conference import ConferenceHolder, Contribution
from MaKaC.conference import ContributionParticipation
from MaKaC.schedule import LinkedTimeSchEntry
c = ConferenceHolder().getById("2")
sch = []
for entry in c.getSchedule().getEntries():
    sch.append(entry)
    if isinstance(entry,LinkedTimeSchEntry) and \
            isinstance(entry.getOwner(),Contribution):
        for spk in entry.getOwner().speakers:
            p = ContributionParticipation()
            p.setFirstName(spk.getName())
            p.setFamilyName(spk.getSurName())
            p.setTitle(spk.getTitle())
            p.setEmail(spk.getEmail())
            p.setAffiliation(spk.getOrganisation())
            p.setAffiliation(spk.getOrganisation())
            entry.getOwner().addPrimaryAuthor(p)
            entry.getOwner().addSpeaker(p)
        entry.getOwner().speakers = None
c._setSchedule()
for entry in sch:
    c.getSchedule().addEntry(entry)
c = ConferenceHolder().getById("1")
while len(c.getContributionList()) > 0:
    c.removeContribution(c.getContributionList()[0])
Exemple #20
0
    def _process(self):
        params = self._getRequestParams()
        self._errorList = []

        #raise "%s"%params
        definedList = self._getDefinedList(self._typeName)
        if definedList is None:
            definedList = []

        if params.get("orgin", "") == "new":
            #raise "new"
            if params.get("ok", None) is None:
                raise "not ok"
                self._redirect(urlHandlers.UHTaskNew.getURL(self._target))
                return
            else:
                person = ContributionParticipation()
                person.setFirstName(params["name"])
                person.setFamilyName(params["surName"])
                person.setEmail(params["email"])
                person.setAffiliation(params["affiliation"])
                person.setAddress(params["address"])
                person.setPhone(params["phone"])
                person.setTitle(params["title"])
                person.setFax(params["fax"])
                if not self._alreadyDefined(person, definedList):
                    definedList.append(
                        [person, params.has_key("submissionControl")])
                else:
                    self._errorList.append(
                        _("%s has been already defined as %s of this contribution"
                          ) % (person.getFullName(), self._typeName))

        elif params.get("orgin", "") == "selected":
            selectedList = self._normaliseListParam(
                self._getRequestParams().get("selectedPrincipals", []))
            for s in selectedList:
                if s[0:8] == "*author*":
                    auths = self._conf.getAuthorIndex()
                    selected = auths.getById(s[9:])[0]
                else:
                    ph = user.PrincipalHolder()
                    selected = ph.getById(s)
                if isinstance(selected, user.Avatar):
                    person = ContributionParticipation()
                    person.setDataFromAvatar(selected)
                    if not self._alreadyDefined(person, definedList):
                        definedList.append(
                            [person,
                             params.has_key("submissionControl")])
                    else:
                        self._errorList.append(
                            _("%s has been already defined as %s of this contribution"
                              ) % (person.getFullName(), self._typeName))

                elif isinstance(selected, user.Group):
                    for member in selected.getMemberList():
                        person = ContributionParticipation()
                        person.setDataFromAvatar(member)
                        if not self._alreadyDefined(person, definedList):
                            definedList.append(
                                [person,
                                 params.has_key("submissionControl")])
                        else:
                            self._errorList.append(
                                _("%s has been already defined as %s of this contribution"
                                  ) %
                                (presenter.getFullName(), self._typeName))
                else:
                    person = ContributionParticipation()
                    person.setTitle(selected.getTitle())
                    person.setFirstName(selected.getFirstName())
                    person.setFamilyName(selected.getFamilyName())
                    person.setEmail(selected.getEmail())
                    person.setAddress(selected.getAddress())
                    person.setAffiliation(selected.getAffiliation())
                    person.setPhone(selected.getPhone())
                    person.setFax(selected.getFax())
                    if not self._alreadyDefined(person, definedList):
                        definedList.append(
                            [person,
                             params.has_key("submissionControl")])
                    else:
                        self._errorList.append(
                            _("%s has been already defined as %s of this contribution"
                              ) % (person.getFullName(), self._typeName))

        elif params.get("orgin", "") == "added":
            preservedParams = self._getPreservedParams()
            chosen = preservedParams.get("%sChosen" % self._typeName, None)
            if chosen is None or chosen == "":
                self._redirect(
                    urlHandlers.UHConfModScheduleNewContrib.getURL(
                        self._target))
                return
            index = chosen.find("-")
            taskId = chosen[0:index]
            resId = chosen[index + 1:len(chosen)]
            taskObject = self._target.getTask(taskId)
            chosenPerson = taskObject.getResponsibleList()[int(resId)]
            if chosenPerson is None:
                self._redirect(
                    urlHandlers.UHConfModScheduleNewContrib.getURL(
                        self._target))
                return
            person = ContributionParticipation()
            person.setTitle(chosenPerson.getTitle())
            person.setFirstName(chosenPerson.getFirstName())
            person.setFamilyName(chosenPerson.getFamilyName())
            person.setEmail(chosenPerson.getEmail())
            person.setAddress(chosenPerson.getAddress())
            person.setAffiliation(chosenPerson.getAffiliation())
            person.setPhone(chosenPerson.getPhone())
            person.setFax(chosenPerson.getFax())
            if not self._alreadyDefined(person, definedList):
                definedList.append(
                    [person, params.has_key("submissionControl")])
            else:
                self._errorList.append(
                    _("%s has been already defined as %s of this contribution")
                    % (person.getFullName(), self._typeName))
        else:
            self._redirect(urlHandlers.UHConfModifSchedule.getURL(
                self._target))
            return
        preservedParams = self._getPreservedParams()
        preservedParams["errorMsg"] = self._errorList
        self._preserveParams(preservedParams)
        self._websession.setVar("%sList" % self._typeName, definedList)

        self._redirect(urlHandlers.UHTaskNew.getURL(self._target))
class TestElectronicAgreement(IndicoTestCase):

    _requires = ['db.Database', 'util.RequestEnvironment', Collaboration_Feature]

    def setUp(self):
        '''
        Create a conference, 0
        Add 2 contributions to this conference, 0 and 1
        To contribution 0 - Add 2 speakers, person1 and person2
        To contribution 1 - Add 1 speaker, person1
        '''
        super(TestElectronicAgreement, self).setUp()
        with self._context('database', 'request'):

            # Create few users
            self._creator = Avatar({"name":"God", "email":"*****@*****.**"})
            self._creator.setId("creator")
                # Set God as admin
            AdminList.getInstance().getList().append(self._creator)

            self.person1 = Avatar({"name":"giuseppe", "email":"*****@*****.**"})
            self.person1.setId("spk1")
            self.person2 = Avatar({"name":"gabriele", "email":"*****@*****.**"})
            self.person1.setId("spk2")
            self.person3 = Avatar({"name":"lorenzo", "email":"*****@*****.**"})
            self.person1.setId("spk3")
            self.person4 = Avatar({"name":"silvio", "email":"*****@*****.**"})
            self.person1.setId("spk4")

            ah = AvatarHolder()
            ah.add(self.person1)
            ah.add(self.person2)
            ah.add(self.person3)
            ah.add(self.person4)

            # Create a conference
            category = conference.CategoryManager().getById('0')
            self._conf = category.newConference(self._creator)
            self._conf.setTimezone('UTC')
            sd=datetime(2011, 06, 01, 10, 00, tzinfo=timezone("UTC"))
            ed=datetime(2011, 06, 05, 10, 00, tzinfo=timezone("UTC"))
            self._conf.setDates(sd,ed,)
            ch = ConferenceHolder()
            ch.add(self._conf)

            # Create contributions and add to the conference
            c1, c2 = Contribution(), Contribution()
            self.speaker1, self.speaker2 = ContributionParticipation(), ContributionParticipation()

            self.speaker1.setDataFromAvatar(self.person1)
            self.speaker2.setDataFromAvatar(self.person2)

            self._conf.addContribution(c2)
            self._conf.addContribution(c1)

            # Add speakers to contributions
            c1.addPrimaryAuthor(self.speaker1)
            c2.addPrimaryAuthor(self.speaker2)
            c1.addSpeaker(self.speaker1)
            c2.addSpeaker(self.speaker1)
            c2.addSpeaker(self.speaker2)

            self._conf.enableSessionSlots()

            # Create session and schedule the contributions
            s1 = Session()
            sd = datetime(2011, 06, 02, 12, 00, tzinfo=timezone("UTC"))
            ed = datetime(2011, 06, 02, 19, 00, tzinfo=timezone("UTC"))
            s1.setDates(sd, ed)

            slot1 = SessionSlot(s1)
            self._conf.addSession(s1)
            slot1.setValues({"sDate":sd})
            s1.addSlot(slot1)

            s1.addContribution(c1)
            s1.addContribution(c2)
            slot1.getSchedule().addEntry(c1.getSchEntry())
            slot1.getSchedule().addEntry(c2.getSchEntry())
            self.createAndAcceptBooking()

    @with_context('database')
    def testRightsFiltering(self):
        '''
        Test if the managing rights are respected.
        '''
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())

        # Test that person3 has not access to webcasted talks
        requestType = CollaborationTools.getRequestTypeUserCanManage(self._conf, self.person3)
        contributions = manager.getContributionSpeakerByType(requestType)
        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId()))
                self.assert_(sw.getRequestType() == "recording" or sw.getRequestType() == "both")

        # Test that person4 has not access to recorded talks
        requestType = CollaborationTools.getRequestTypeUserCanManage(self._conf, self.person4)
        contributions = manager.getContributionSpeakerByType(requestType)
        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId()))
                self.assert_(sw.getRequestType() == "webcast" or sw.getRequestType() == "both")

    @with_context('database')
    @with_context('request')
    def testNOEMAILStatus(self):
        '''
        Test if the status of the SpeakerWrapper is correctly updated to NOEMAIL.\n
        '''
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())

        contributions = manager.getContributionSpeakerByType("both")

        ''' Check change to NOEMAIL status, when delete the email of a speaker (here: speaker1)
            Should change to this status only if the previous status is NOTSIGNED or PENDING
        '''
        for cont in contributions:
            sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, self.speaker1.getId()))
            if sw:
                #remove the email from NOTSIGNED to NOEMAIL
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.NOEMAIL)

                #reset email, then remove email from PENDING to NOEMAIL
                self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**")
                sw.setStatus(SpeakerStatusEnum.PENDING)
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.NOEMAIL)

                #reset email, then remove email from SIGNED to SIGNED (no changes)
                self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**")
                sw.setStatus(SpeakerStatusEnum.SIGNED)
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.SIGNED)

                #reset email, then remove email from FROMFILE to FROMFILE (no changes)
                self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**")
                sw.setStatus(SpeakerStatusEnum.FROMFILE)
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.FROMFILE)

                #reset email, then remove email from REFUSED to REFUSED (no changes)
                self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**")
                sw.setStatus(SpeakerStatusEnum.REFUSED)
                self.changeEmailService(cont, self.speaker1.getId(), "")
                self.assert_(sw.getStatus() == SpeakerStatusEnum.REFUSED)

    @with_context('database')
    @with_context('request')
    def testPENDINGStatus(self):
        '''
        Test if the status of the SpeakerWrapper is correctly updated to PENDING.\n
        '''
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        contributions = manager.getContributionSpeakerByType("both")

        uniqueIdList = []

        for cont in contributions:
            for spk in contributions[cont]:
                uniqueIdList.append("%s.%s"%(cont, spk.getId()))

        self.sendEmailService(uniqueIdList)

        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId()))
                self.assert_(sw.getStatus() == SpeakerStatusEnum.PENDING)

    @with_context('database')
    @with_context('request')
    def testSIGNEDStatus(self):
        '''
        Test if the status of the SpeakerWrapper is correctly updated to SIGNED.\n
        '''
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        contributions = manager.getContributionSpeakerByType("both")

        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId()))
                self.submitAgreementService(sw, 'accept')
                self.assert_(sw.getStatus() == SpeakerStatusEnum.SIGNED)

    @with_context('database')
    @with_context('request')
    def testREFUSEDStatus(self):
        '''
        Test if the status of the SpeakerWrapper is correctly updated to REFUSED.\n
        '''
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
        contributions = manager.getContributionSpeakerByType("both")

        for cont in contributions:
            for spk in contributions[cont]:
                sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId()))
                self.submitAgreementService(sw, 'reject')
                self.assert_(sw.getStatus() == SpeakerStatusEnum.REFUSED)

#==========================================================================
    # Here useful functions called during the tests
    def createAndAcceptBooking(self):
        manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())

        # Create a booking - Recording Request
        bookingParams =  {
                            'otherComments': '', 'endDate': '', 'talkSelection': ['0'], 'numAttendees': '', 'talks': '',
                            'lectureStyle': 'lecturePresentation', 'numRemoteViewers': '', 'startDate': '', 'postingUrgency': 'withinWeek'
                         }
        # Create a booking - Webcast Request
        bookingParamsWeb =  {
                           'talkSelection': ['0'], 'talks': 'choose'
                        }

        #Give rights to person3(recordingReq) and person4(webcastReq) (... _creator has both)
        manager.addPluginManager("RecordingRequest", self.person3)
        manager.addPluginManager("WebcastRequest", self.person4)

        if manager.canCreateBooking("RecordingRequest"):
            manager.createBooking("RecordingRequest", bookingParams)
        booking = manager.getSingleBooking("RecordingRequest")
        manager.acceptBooking(booking.getId())

        if manager.canCreateBooking("WebcastRequest"):
            manager.createBooking("WebcastRequest", bookingParamsWeb)
        booking = manager.getSingleBooking("WebcastRequest")
        manager.acceptBooking(booking.getId())

    def changeEmailService(self, contId, spkId, value):

        params = {
                  'value':value,
                  'confId':self._conf.getId(),
                  'contribId':contId,
                  'spkId': spkId
                  }
        service = SetSpeakerEmailAddress(params)
        service._checkParams()
        service._getAnswer()

    def sendEmailService(self, uniqueId):
        fromField = {
            "name": "No-reply",
            "email": "*****@*****.**"
            }
        content = "This is a test {url} {talkTitle}..."

        params = {
                  'from': fromField,
                  'content': content,
                  'uniqueIdList': uniqueId,
                  'confId': self._conf.getId()
                  }
        service = SendElectronicAgreement(params)
        service._checkParams()
        service._getAnswer()

    def submitAgreementService(self, sw, decision):
        params = {
                  'authKey':sw.getUniqueIdHash(),
                  'confId': self._conf.getId(),
                  'reason': 'because...'
                  }

        if decision == 'accept':
            service = AcceptElectronicAgreement(params)
        else:
            service = RejectElectronicAgreement(params)

        service._checkParams()
        service._getAnswer()
Exemple #22
0
def make_participation_from_obj(obj, contrib_participation=None):
    """Convert a user-like object to a ContributionParticipation

    :param obj: The object to take the values of the ContributionParticipation
                from
    :param contrib_participation: In case the return object has been initialised
                                  outside of the function
    :return: a ContributionParticipation object
    """
    if contrib_participation is None:
        contrib_participation = ContributionParticipation()
    contrib_participation.setTitle(obj.getTitle())
    contrib_participation.setFirstName(obj.getName())
    contrib_participation.setFamilyName(obj.getSurName())
    contrib_participation.setEmail(obj.getEmail())
    contrib_participation.setAddress(obj.getAddress())
    contrib_participation.setFax(obj.getFax())
    contrib_participation.setAffiliation(obj.getAffiliation())
    contrib_participation.setPhone(obj.getPhone())
    return contrib_participation
Exemple #23
0
 def testBasicIndexing(self):
     #Tests adding a contribution with some authors already on it
     c1 = Contribution()
     self._conf.addContribution(c1)
     auth1, auth2 = ContributionParticipation(), ContributionParticipation()
     auth1.setFirstName("hector")
     auth1.setFamilyName("sanchez sanmartin")
     auth1.setEmail("*****@*****.**")
     auth2.setFirstName("jose benito")
     auth2.setFamilyName("gonzalez lopez")
     auth2.setEmail("*****@*****.**")
     c1.addPrimaryAuthor(auth1)
     c1.addPrimaryAuthor(auth2)
     idx = self._conf.getAuthorIndex()
     self.assert_(auth1 in idx.getParticipations()[1])
     self.assert_(len(idx.getParticipations()[1]) == 1)
     self.assert_(auth2 in idx.getParticipations()[0])
     self.assert_(len(idx.getParticipations()[0]) == 1)
     c2 = Contribution()
     self._conf.addContribution(c2)
     auth3, auth4 = ContributionParticipation(), ContributionParticipation()
     auth3.setFirstName("hector")
     auth3.setFamilyName("sanchez sanmartin")
     auth3.setEmail("*****@*****.**")
     auth4.setFirstName("jose benito")
     auth4.setFamilyName("gonzalez lopez2")
     auth4.setEmail("*****@*****.**")
     c2.addPrimaryAuthor(auth3)
     c2.addPrimaryAuthor(auth4)
    def setUp(self):
        '''
        Create a conference, 0
        Add 2 contributions to this conference, 0 and 1
        To contribution 0 - Add 2 speakers, person1 and person2
        To contribution 1 - Add 1 speaker, person1
        '''
        super(TestElectronicAgreement, self).setUp()

        self._startDBReq()

        self.falseSession = FalseSession()
        # Create few users
        self._creator = Avatar({"name": "God", "email": "*****@*****.**"})
        self._creator.setId("creator")
        # Set God as admin
        AdminList.getInstance().getList().append(self._creator)

        self.person1 = Avatar({"name": "giuseppe", "email": "*****@*****.**"})
        self.person1.setId("spk1")
        self.person2 = Avatar({"name": "gabriele", "email": "*****@*****.**"})
        self.person1.setId("spk2")
        self.person3 = Avatar({"name": "lorenzo", "email": "*****@*****.**"})
        self.person1.setId("spk3")
        self.person4 = Avatar({"name": "silvio", "email": "*****@*****.**"})
        self.person1.setId("spk4")

        ah = AvatarHolder()
        ah.add(self.person1)
        ah.add(self.person2)
        ah.add(self.person3)
        ah.add(self.person4)

        # Create a conference
        category = conference.CategoryManager().getById('0')
        self._conf = category.newConference(self._creator)
        self._conf.setTimezone('UTC')
        sd = datetime(2011, 06, 01, 10, 00, tzinfo=timezone("UTC"))
        ed = datetime(2011, 06, 05, 10, 00, tzinfo=timezone("UTC"))
        self._conf.setDates(
            sd,
            ed,
        )
        ch = ConferenceHolder()
        ch.add(self._conf)

        # Create contributions and add to the conference
        c1, c2 = Contribution(), Contribution()
        self.speaker1, self.speaker2 = ContributionParticipation(
        ), ContributionParticipation()

        self.speaker1.setDataFromAvatar(self.person1)
        self.speaker2.setDataFromAvatar(self.person2)

        self._conf.addContribution(c2)
        self._conf.addContribution(c1)

        # Add speakers to contributions
        c1.addPrimaryAuthor(self.speaker1)
        c2.addPrimaryAuthor(self.speaker2)
        c1.addSpeaker(self.speaker1)
        c2.addSpeaker(self.speaker1)
        c2.addSpeaker(self.speaker2)

        self._conf.enableSessionSlots()

        # Create session and schedule the contributions
        s1 = Session()
        sd = datetime(2011, 06, 02, 12, 00, tzinfo=timezone("UTC"))
        ed = datetime(2011, 06, 02, 19, 00, tzinfo=timezone("UTC"))
        s1.setDates(sd, ed)

        slot1 = SessionSlot(s1)
        self._conf.addSession(s1)
        slot1.setValues({"sDate": sd})
        s1.addSlot(slot1)

        s1.addContribution(c1)
        s1.addContribution(c2)
        slot1.getSchedule().addEntry(c1.getSchEntry())
        slot1.getSchedule().addEntry(c2.getSchEntry())

        self.createAndAcceptBooking()
        self._stopDBReq()
Exemple #25
0
import sys
sys.path.append("c:/development/indico/code/code")
from indico.core.db import DBMgr
DBMgr.getInstance().startRequest()
from MaKaC.conference import ConferenceHolder,Contribution
from MaKaC.conference import ContributionParticipation
from MaKaC.schedule import LinkedTimeSchEntry
c=ConferenceHolder().getById("2")
sch=[]
for entry in c.getSchedule().getEntries():
    sch.append(entry)
    if isinstance(entry,LinkedTimeSchEntry) and \
            isinstance(entry.getOwner(),Contribution):
        for spk in entry.getOwner().speakers:
            p=ContributionParticipation()
            p.setFirstName(spk.getName())
            p.setFamilyName(spk.getSurName())
            p.setTitle(spk.getTitle())
            p.setEmail(spk.getEmail())
            p.setAffiliation(spk.getOrganisation())
            p.setAffiliation(spk.getOrganisation())
            entry.getOwner().addPrimaryAuthor(p)
            entry.getOwner().addSpeaker(p)
        entry.getOwner().speakers=None
c._setSchedule()
for entry in sch:
    c.getSchedule().addEntry(entry)
c=ConferenceHolder().getById("1")
while len(c.getContributionList())>0:
    c.removeContribution(c.getContributionList()[0])
    def setUp(self):
        '''
        Create a conference, 0
        Add 2 contributions to this conference, 0 and 1
        To contribution 0 - Add 2 speakers, person1 and person2
        To contribution 1 - Add 1 speaker, person1
        '''
        super(TestElectronicAgreement, self).setUp()
        with self._context('database', 'request'):

            # Create few users
            self._creator = Avatar({"name":"God", "email":"*****@*****.**"})
            self._creator.setId("creator")
                # Set God as admin
            AdminList.getInstance().getList().append(self._creator)

            self.person1 = Avatar({"name":"giuseppe", "email":"*****@*****.**"})
            self.person1.setId("spk1")
            self.person2 = Avatar({"name":"gabriele", "email":"*****@*****.**"})
            self.person1.setId("spk2")
            self.person3 = Avatar({"name":"lorenzo", "email":"*****@*****.**"})
            self.person1.setId("spk3")
            self.person4 = Avatar({"name":"silvio", "email":"*****@*****.**"})
            self.person1.setId("spk4")

            ah = AvatarHolder()
            ah.add(self.person1)
            ah.add(self.person2)
            ah.add(self.person3)
            ah.add(self.person4)

            # Create a conference
            category = conference.CategoryManager().getById('0')
            self._conf = category.newConference(self._creator)
            self._conf.setTimezone('UTC')
            sd=datetime(2011, 06, 01, 10, 00, tzinfo=timezone("UTC"))
            ed=datetime(2011, 06, 05, 10, 00, tzinfo=timezone("UTC"))
            self._conf.setDates(sd,ed,)
            ch = ConferenceHolder()
            ch.add(self._conf)

            # Create contributions and add to the conference
            c1, c2 = Contribution(), Contribution()
            self.speaker1, self.speaker2 = ContributionParticipation(), ContributionParticipation()

            self.speaker1.setDataFromAvatar(self.person1)
            self.speaker2.setDataFromAvatar(self.person2)

            self._conf.addContribution(c2)
            self._conf.addContribution(c1)

            # Add speakers to contributions
            c1.addPrimaryAuthor(self.speaker1)
            c2.addPrimaryAuthor(self.speaker2)
            c1.addSpeaker(self.speaker1)
            c2.addSpeaker(self.speaker1)
            c2.addSpeaker(self.speaker2)

            self._conf.enableSessionSlots()

            # Create session and schedule the contributions
            s1 = Session()
            sd = datetime(2011, 06, 02, 12, 00, tzinfo=timezone("UTC"))
            ed = datetime(2011, 06, 02, 19, 00, tzinfo=timezone("UTC"))
            s1.setDates(sd, ed)

            slot1 = SessionSlot(s1)
            self._conf.addSession(s1)
            slot1.setValues({"sDate":sd})
            s1.addSlot(slot1)

            s1.addContribution(c1)
            s1.addContribution(c2)
            slot1.getSchedule().addEntry(c1.getSchEntry())
            slot1.getSchedule().addEntry(c2.getSchEntry())
            self.createAndAcceptBooking()
    for abstract in conf.getAbstractMgr().getAbstractList():
        if isinstance(abstract.getCurrentStatus(), AbstractStatusAccepted):
            contrib=abstract.getContribution()
            contrib.setTitle( abstract.getTitle() )
            contrib.setDescription( abstract.getContent() )
            contrib.setSummary( abstract.getSummary() )
            contrib.setTrack( abstract.getCurrentStatus().getTrack() )
            contrib.setType( abstract.getCurrentStatus().getType() )
            for auth1 in contrib.getPrimaryAuthorList()[:]:
                contrib.removePrimaryAuthor(auth1)
            for auth2 in contrib.getCoAuthorList()[:]:
                contrib.removeCoAuthor(auth2)
            for auth3 in contrib.getSpeakerList()[:]:
                contrib.removeSpeaker(auth3)
            for auth in abstract.getAuthorList():
                c_auth = ContributionParticipation()
                contrib._setAuthorValuesFromAbstract( c_auth, auth )
                if abstract.isPrimaryAuthor( auth ):
                    contrib.addPrimaryAuthor( c_auth )
                else:
                    contrib.addCoAuthor( c_auth )
                if abstract.isSpeaker( auth ):
                    contrib.addSpeaker( c_auth )
            # TODO: remove the previous submitter...how???
            contrib._grantSubmission(contrib.getAbstract().getSubmitter().getUser())
            counter.append(contrib.getId())
DBMgr.getInstance().endRequest()
print "contribs ids:%s"%counter
print ""
print "%s contribs sync"%(len(counter))