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