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 _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))
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))
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()