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 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 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 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 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 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 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 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 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 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 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 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 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())
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)
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))
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]) DBMgr.getInstance().endRequest()
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)
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))
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]) DBMgr.getInstance().endRequest()