def _sendErrorEmail(self, e): ty, ex, tb = sys.exc_info() tracebackList = traceback.format_list(traceback.extract_tb(tb)) text = ( _( """ Offline website creation for the [event:%s] had caused an error while running the task. - Request from user: %s <%s> - Details of the exception: %s - Traceback: %s -- <Indico support> indico-project @ cern.ch """ ) % (self._conf.getId(), self._toUser.getFullName(), self._toUser.getEmail(), e, "\n".join(tracebackList)) ) maildata = { "fromAddr": Config.getInstance().getSupportEmail(), "toList": [Config.getInstance().getSupportEmail()], "subject": _("[Indico] Error in task: Offline website creation"), "body": text, } GenericMailer.send(GenericNotification(maildata))
def _sendMail(self, currentList, newManager): if isinstance(newManager, AvatarUserWrapper): managerName = newManager.getStraightFullName() else: managerName = newManager.getName() text = ( _( """Dear managers, %s has been added as manager for the category '%s': %s Best regards, Indico Team """ ) % (managerName, self._categ.getName(), UHCategModifAC.getURL(self._categ)) ) maildata = { "fromAddr": "%s" % Config.getInstance().getNoReplyEmail(), "toList": [manager.getEmail() for manager in currentList], "subject": "New category manager", "body": text, } GenericMailer.send(GenericNotification(maildata))
def _sendReport( self ): cfg = Config.getInstance() # if no e-mail address was specified, # add a default one if self._userMail: fromAddr = self._userMail else: fromAddr = '*****@*****.**' toAddr = Config.getInstance().getSupportEmail() Logger.get('errorReport').debug('mailing %s' % toAddr) subject = "[Indico@%s] Error report"%cfg.getBaseURL() request_info = self._requestInfo or '' if isinstance(request_info, (dict, list)): request_info = pformat(request_info) # build the message body body = [ "-" * 20, "Error details\n", self._code, self._message, "Inner error: " + str(self._inner), request_info, "-" * 20 ] maildata = {"fromAddr": fromAddr, "toList": [toAddr], "subject": subject, "body": "\n".join(body)} GenericMailer.send(GenericNotification(maildata))
def _sendReport(self): info = HelperMaKaCInfo().getMaKaCInfoInstance() cfg = Config.getInstance() # if no e-mail address was specified, # add a default one if self._userMail: fromAddr = self._userMail else: fromAddr = "*****@*****.**" toAddr = info.getSupportEmail() Logger.get("errorReport").debug("mailing %s" % toAddr) subject = "[Indico@%s] Error report" % cfg.getBaseURL() # build the message body body = [ "-" * 20, "Error details\n", self._code, self._message, "Inner error: " + str(self._inner), str(self._requestInfo), "-" * 20, ] maildata = {"fromAddr": fromAddr, "toList": [toAddr], "subject": subject, "body": "\n".join(body)} # send it GenericMailer.send(GenericNotification(maildata))
def notify(self,registrant,params): if params.has_key("conf"): GenericMailer.sendAndLog(self.apply(registrant,params), params["conf"], log.ModuleNames.REGISTRATION) else: GenericMailer.send(self.apply(registrant,params))
def setStatusDeclined(self, responsibleUser=None, sendMail=True): if self._status != "pending" : return False self._status = "declined" logData = self.getParticipantData() logData["subject"] = _("%s : status set to DECLINED")%self.getWholeName() self.getConference().getLogHandler().logAction(logData,"participants",responsibleUser) if sendMail: data = {} data["fromAddr"] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getSupportEmail() confTitle = self._participation.getConference().getTitle() data["subject"] = _("Your application for attendance in %s declined")%confTitle toList = [] toList.append(self._email) title = "" if self._title == "" or self._title is None : title = self._firstName else: title = self._title data["toList"] = toList data["body"] = _(""" Dear %s %s, your request to attend the %s has been declined by the event manager. Your Indico """)%(title, self._familyName, confTitle) GenericMailer.sendAndLog(GenericNotification(data),self.getConference(),"participants",responsibleUser) return True
def askForExcuse(self, eventManager, toIdList): data = self.prepareAskForExcuse(eventManager,toIdList) if data is None : return False GenericMailer.sendAndLog(GenericNotification(data),self._conference,"participants",eventManager) return True
def run(self, check=True): import smtplib from MaKaC.webinterface.mail import GenericMailer, GenericNotification # prepare the mail send = self._prepare(check=check) # _prepare decided we shouldn't send the mail? if not send: return addrs = [smtplib.quoteaddr(x) for x in self.toAddr] ccaddrs = [smtplib.quoteaddr(x) for x in self.ccAddr] if len(addrs) + len(ccaddrs) == 0: self.getLogger().warning("Attention: mail contains no recipients!") else: self.getLogger().info("Sending mail To: %s, CC: %s" % (addrs, ccaddrs)) for user in self.toUser: addrs.append(smtplib.quoteaddr(user.getEmail())) GenericMailer.send( GenericNotification( { "fromAddr": self.fromAddr, "toList": addrs, "ccList": ccaddrs, "subject": self.subject, "body": self.text, } ) )
def run(self, check=True): import smtplib from MaKaC.webinterface.mail import GenericMailer, GenericNotification # prepare the mail send = self._prepare(check=check) # _prepare decided we shouldn't send the mail? if not send: return # just in case some ill-behaved code generates empty addresses addrs = list(smtplib.quoteaddr(x) for x in self.toAddr if x) ccaddrs = list(smtplib.quoteaddr(x) for x in self.ccAddr if x) if len(addrs) + len(ccaddrs) == 0: self.getLogger().warning("Attention: no recipients, mail won't be sent") else: self.getLogger().info("Sending mail To: %s, CC: %s" % (addrs, ccaddrs)) for user in self.toUser: addrs.append(smtplib.quoteaddr(user.getEmail())) if addrs or ccaddrs: GenericMailer.send(GenericNotification({"fromAddr": self.fromAddr, "toList": addrs, "ccList": ccaddrs, "subject": self.subject, "body": self.text }))
def _sendReport(self): cfg = Config.getInstance() # if no e-mail address was specified, # add a default one if self._userMail: fromAddr = self._userMail else: fromAddr = '*****@*****.**' toAddr = Config.getInstance().getSupportEmail() Logger.get('errorReport').debug('mailing %s' % toAddr) subject = "[Indico@{}] Error report".format( url_parse(cfg.getBaseURL()).netloc) request_info = self._requestInfo or '' if isinstance(request_info, (dict, list)): request_info = pformat(request_info) # build the message body body = [ "-" * 20, "Error details\n", self._code, self._message, "Inner error: " + str(self._inner), request_info, "-" * 20 ] maildata = { "fromAddr": fromAddr, "toList": [toAddr], "subject": subject, "body": "\n".join(body) } GenericMailer.send(GenericNotification(maildata))
def notify(self,registrant,params): if params.has_key("conf"): GenericMailer.sendAndLog(self.apply(registrant,params), params["conf"], 'Registration') else: GenericMailer.send(self.apply(registrant,params))
def _sendErrorEmail(self, e): ty, ex, tb = sys.exc_info() tracebackList = traceback.format_list(traceback.extract_tb(tb)) text = _(""" Offline website creation for the [event:%s] had caused an error while running the task. - Request from user: %s <%s> - Details of the exception: %s - Traceback: %s -- <Indico support> indico-project @ cern.ch """) % (self._conf.getId(), self._toUser.getFullName(), self._toUser.getEmail(), e, "\n".join(tracebackList)) maildata = { "fromAddr": Config.getInstance().getSupportEmail(), "toList": [Config.getInstance().getSupportEmail()], "subject": _("[Indico] Error in task: Offline website creation"), "body": text } GenericMailer.send(GenericNotification(maildata))
def notify(self, abstract, tpl): #if no from address is specified we should put the default one if tpl.getFromAddr().strip() == "": tpl.setFromAddr(tpl.getConference().getSupportInfo().getEmail( returnNoReply=True)) GenericMailer.send(self.apply(abstract, tpl))
def askForExcuse(self, eventManager, toIdList): data = self.prepareAskForExcuse(eventManager, toIdList) if data is None: return False GenericMailer.sendAndLog(GenericNotification(data), self._conference, "participants", eventManager) return True
def askForExcuse(self, eventManager, toIdList): data = self.prepareAskForExcuse(eventManager, toIdList) if data is None : return False GenericMailer.sendAndLog(GenericNotification(data), self._conference, log.ModuleNames.PARTICIPANTS) return True
def askForExcuse(self, eventManager, toIdList): data = self.prepareAskForExcuse(eventManager, toIdList) if data is None: return False GenericMailer.sendAndLog(GenericNotification(data), self._conference, log.ModuleNames.PARTICIPANTS) return True
def _sendReport(self): cfg = Config.getInstance() fromAddr = self._userMail toAddr = cfg.getSupportEmail() subject = "[Indico@%s] Error report" % cfg.getBaseURL() body = ["-"*20, "User Comments\n", "%s\n\n" % self._comments, "-"*20, "Error details\n", self._msg, "-" * 20] maildata = {"fromAddr": fromAddr, "toList": [toAddr], "subject": subject, "body": "\n".join(body)} GenericMailer.send(GenericNotification(maildata), skipQueue=True)
def _process_retry_setup(self): # clear the fossile cache at the start of each request fossilize.clearCache() # clear after-commit queue flush_after_commit_queue(False) # delete all queued emails GenericMailer.flushQueue(False) # clear the existing redis pipeline if self._redisPipeline: self._redisPipeline.reset()
def notifyAll(self,params): subj=params.get("subject","") b=params.get("body","") fa=params.get("from","") tl=params.get("to",[]) cc = params.get("cc",[]) notification = Notification(subject=subj,body=b,fromAddr=fa,toList=tl,ccList=cc) if params.has_key("conf"): GenericMailer.sendAndLog(notification, params["conf"]) else: GenericMailer.send(notification)
def run(self): addrs = [] ccaddrs = [] for addr in self.toAddr: addrs.append(smtplib.quoteaddr(addr)) for ccaddr in self.ccAddr: ccaddrs.append(smtplib.quoteaddr(ccaddr)) for user in self.toUser: addrs.append(smtplib.quoteaddr(user.getEmail())) maildata = { "fromAddr": self.fromAddr, "toList": addrs, "ccList": ccaddrs, "subject": self.subject, "body": self.text } GenericMailer.send(GenericNotification(maildata))
def notifyAll(self,params): subj=params.get("subject","") b=params.get("body","") fa=params.get("from","") tl=params.get("to",[]) cc = params.get("cc",[]) notification = Notification(subject=subj,body=b,fromAddr=fa,toList=tl,ccList=cc) if params.has_key("conf"): GenericMailer.sendAndLog(notification, params["conf"], log.ModuleNames.REGISTRATION) else: GenericMailer.send(notification)
def addPendingParticipant(self, participant): if participant.getConference().getId() != self._conference.getId(): return False if participant.getId() is not None: return False if self.alreadyParticipating(participant) != 0: return False if self.getAutoAccept(): self.addParticipant(participant) else: self._pendingParticipantList["%d" % self._newPendingId()] = participant logData = participant.getParticipantData() logData["subject"] = _( "New pending participant : %s") % participant.getWholeName() self._conference.getLogHandler().logAction(logData, "participants") participant.setStatusPending() profileURL = urlHandlers.UHConfModifParticipantsPendingDetails.getURL( self._conference) profileURL.addParam("pendingId", self._lastPendingId()) toList = [] creator = self._conference.getCreator() if isinstance(creator, Avatar): toList.append(creator.getEmail()) for manager in self._conference.getAccessController( ).getModifierList(): if isinstance(manager, Avatar): toList.append(manager.getEmail()) data = {} data["toList"] = toList data["fromAddr"] = info.HelperMaKaCInfo.getMaKaCInfoInstance( ).getSupportEmail() data["subject"] = _("New pending participant for %s" ) % self._conference.getTitle() data["body"] = _(""" Dear Event Manager, a new person is asking for participation in %s. Personal profile of this pending participant is available at %s Please take this candidature into consideration and accept or reject it Your Indico """) % (self._conference.getTitle(), profileURL) GenericMailer.send(GenericNotification(data)) self.notifyModification() return True
def _sendEmail(self, ofu): text = _(""" Offline website creation for your event was finished and you can recover the zip file from the following URL: <%s> Thanks for using Indico -- Indico """)%ofu maildata = { "fromAddr": Config.getInstance().getSupportEmail(), "toList": [self._toUser.getEmail()], "subject": _("[Indico] Offline website creation done"), "body": text } GenericMailer.send(GenericNotification(maildata))
def _sendEmail(self, ofu): text = _(""" Offline website creation for your event was finished and you can recover the zip file from the following URL: <%s> Thanks for using Indico -- Indico """)%ofu maildata = { "fromAddr": info.HelperMaKaCInfo.getMaKaCInfoInstance().getSupportEmail(), "toList": [self._toUser.getEmail()], "subject": _("[Indico] Offline website creation done"), "body": text } GenericMailer.send(GenericNotification(maildata))
def _process( self ): count = 0 for abstract in self._abstracts: dict = AbstractNotification(self._conf, abstract).getDict() s = self._notifTpl.getTplSubject() b = self._notifTpl.getTplBody() maildata = { "fromAddr": self._notifTpl.getFromAddr(), "toList": [abstract.getSubmitter().getEmail()], "subject": s%dict, "body": text } GenericMailer.send(GenericNotification(maildata)) self._conf.newSentMail(abstract.getSubmitter(), mail.getSubject(), b%dict) count += 1 #self._redirect(urlHandlers.UHConfAbstractManagment.getURL(self._conf)) p = conferences.WPAbstractSendNotificationMail(self, self._conf, count ) return p.display()
def _process_success(self): Logger.get('requestHandler').info('Request {} successful'.format(request)) # request is succesfull, now, doing tasks that must be done only once try: flush_after_commit_queue(True) GenericMailer.flushQueue(True) # send emails self._deleteTempFiles() except: Logger.get('mail').exception('Mail sending operation failed') # execute redis pipeline if we have one if self._redisPipeline: try: self._redisPipeline.execute() except RedisError: Logger.get('redis').exception('Could not execute pipeline')
def _process_success(self): Logger.get('requestHandler').info('Request successful') # request is succesfull, now, doing tasks that must be done only once try: flush_after_commit_queue(True) GenericMailer.flushQueue(True) # send emails self._deleteTempFiles() except: Logger.get('mail').exception('Mail sending operation failed') # execute redis pipeline if we have one if self._redisPipeline: try: self._redisPipeline.execute() except RedisError: Logger.get('redis').exception('Could not execute pipeline')
def addParticipant(self, participant, eventManager=None): # check if it's worth to add the participant if participant.getConference().getId() != self._conference.getId(): return False self.removePendingParticipant(participant) if not participant.setId(self._newParticipantId()): return False if self.alreadyParticipating(participant) != 0: return False self._participantList["%d" % self._lastParticipantId()] = participant # remove him from the "pending" list if participant in self._pendingParticipantList.values(): for k in self._pendingParticipantList.keys(): if self._pendingParticipantList[k] == participant: del self._pendingParticipantList[k] break logData = participant.getParticipantData() logData["subject"] = _( "New participant added : %s") % participant.getWholeName() self._conference.getLogHandler().logAction( logData, log.ModuleNames.PARTICIPANTS) participant.setStatusAdded() # check if an e-mail should be sent... if self._addedInfo: # to notify the user of his/her addition if eventManager is None: return False data = self.prepareAddedInfo(participant, eventManager) GenericMailer.sendAndLog(GenericNotification(data), self._conference, log.ModuleNames.PARTICIPANTS) avatar = participant.getAvatar() if avatar is None: # or to encourage him/her to register at Indico #self.sendEncouragementToCreateAccount(participant) pass else: # OK, if we have an avatar, let's keep things consistent avatar.linkTo(self._conference, "participant") self.notifyModification() return True
def _sendMail(self, currentList, newManager): if isinstance(newManager, AvatarUserWrapper): managerName = newManager.getStraightFullName() else: managerName = newManager.getName() text = _("""Dear managers, %s has been added as manager for the category '%s': %s Best regards, Indico Team """) % (managerName, self._categ.getName(), UHCategModifAC.getURL(self._categ)) maildata = { "fromAddr": "%s" % Config.getInstance().getNoReplyEmail(), "toList": [manager.getEmail() for manager in currentList], "subject": "New category manager", "body": text } GenericMailer.send(GenericNotification(maildata))
def addParticipant(self, participant, eventManager = None): # check if it's worth to add the participant if participant.getConference().getId() != self._conference.getId() : return False self.removePendingParticipant(participant) if not participant.setId(self._newParticipantId()): return False if self.alreadyParticipating(participant) != 0 : return False self._participantList["%d"%self._lastParticipantId()] = participant # remove him from the "pending" list if participant in self._pendingParticipantList.values() : for k in self._pendingParticipantList.keys() : if self._pendingParticipantList[k] == participant : del self._pendingParticipantList[k] break logData = participant.getParticipantData() logData["subject"] = _("New participant added : %s")%participant.getWholeName() self._conference.getLogHandler().logAction(logData, log.ModuleNames.PARTICIPANTS) participant.setStatusAdded() # check if an e-mail should be sent... if self._addedInfo : # to notify the user of his/her addition if eventManager is None : return False data = self.prepareAddedInfo(participant, eventManager) GenericMailer.sendAndLog(GenericNotification(data), self._conference, log.ModuleNames.PARTICIPANTS) avatar = participant.getAvatar() if avatar is None : # or to encourage him/her to register at Indico #self.sendEncouragementToCreateAccount(participant) pass else: # OK, if we have an avatar, let's keep things consistent avatar.linkTo(self._conference,"participant") self.notifyModification() return True
def addPendingParticipant(self, participant): if participant.getConference().getId() != self._conference.getId() : return False if participant.getId() is not None : return False if self.alreadyParticipating(participant) != 0 : return False if self.isAutoAccept(): self.addParticipant(participant) else: self._pendingParticipantList["%d"%self._newPendingId()] = participant logData = participant.getParticipantData() logData["subject"] = _("New pending participant : %s")%participant.getWholeName() self._conference.getLogHandler().logAction(logData, log.ModuleNames.PARTICIPANTS) participant.setStatusPending() profileURL = urlHandlers.UHConfModifParticipantsPending.getURL(self._conference) toList = [] creator=self._conference.getCreator() if isinstance(creator, Avatar) : toList.append(creator.getEmail()) for manager in self._conference.getAccessController().getModifierList() : if isinstance(manager, Avatar) : toList.append(manager.getEmail()) data = {} data["toList"] = toList data["fromAddr"] = Config.getInstance().getSupportEmail() data["subject"] = _("New pending participant for %s")%self._conference.getTitle() data["body"] = """ Dear Event Manager, a new person is asking for participation in %s. Personal profile of this pending participant is available at %s Please take this candidature into consideration and accept or reject it Your Indico """%(self._conference.getTitle(), profileURL) GenericMailer.send(GenericNotification(data)) self.notifyModification() return True
def addParticipant(self, participant, eventManager = None): # check if it's worth to add the participant if participant.getConference().getId() != self._conference.getId() : return False self.removePendingParticipant(participant) if not participant.setId(self._newParticipantId()): return False if self.alreadyParticipating(participant) != 0 : return False self._participantList["%d"%self._lastParticipantId()] = participant # remove him from the "pending" list if participant in self._pendingParticipantList.values() : for k in self._pendingParticipantList.keys() : if self._pendingParticipantList[k] == participant : del self._pendingParticipantList[k] break self.getConference().log(EventLogRealm.management, EventLogKind.positive, u'Participants', u'Participant added: {}'.format(to_unicode(participant.getName())), session.user, data=participant.getParticipantData()) participant.setStatusAdded() # check if an e-mail should be sent... if self._addedInfo : # to notify the user of his/her addition if eventManager is None : return False data = self.prepareAddedInfo(participant, eventManager) GenericMailer.sendAndLog(GenericNotification(data), self._conference, 'Participants') avatar = participant.getAvatar() if avatar is None : # or to encourage him/her to register at Indico #self.sendEncouragementToCreateAccount(participant) pass else: # OK, if we have an avatar, let's keep things consistent avatar.linkTo(self._conference,"participant") self.notifyModification() return True
def sendSpecialEmail(self, participantsIdList, eventManager, data): if participantsIdList is None : return False if eventManager is None : return False if len(participantsIdList) == 0: return True if data.get("subject",None) is None : return False if data.get("body",None) is None : return False data["fromAddr"] = eventManager.getEmail() toList = [] for id in participantsIdList : participant = self._participantList.get(id,None) if Participant is not None : toList.append(p.getEmail()) data["toList"] = toList GenericMailer.sendAndLog(GenericNotification(data),self._conference,"participants",eventManager) return True
def _sendSecondaryEmailNotifiication(self, email): data = {} data["toList"] = [email] data["fromAddr"] = Config.getInstance().getSupportEmail() data["subject"] = """[Indico] Email address confirmation""" data["body"] = """Dear %s, You have added a new email to your secondary email list. In order to confirm and activate this new email address, please open in your web browser the following URL: %s Once you have done it, the email address will appear in your profile. Best regards, Indico Team""" % (self._user.getStraightFullName(), url_for('user.userRegistration-validateSecondaryEmail', userId=self._user.getId(), key=md5(email).hexdigest(), _external=True)) GenericMailer.send(GenericNotification(data))
def setStatusDeclined(self, responsibleUser=None, sendMail=True): if self._status != "pending": return False self._status = "declined" logData = self.getParticipantData() logData["subject"] = _( "%s : status set to DECLINED") % self.getWholeName() self.getConference().getLogHandler().logAction(logData, "participants", responsibleUser) if sendMail: data = {} data["fromAddr"] = info.HelperMaKaCInfo.getMaKaCInfoInstance( ).getSupportEmail() confTitle = self._participation.getConference().getTitle() data["subject"] = _( "Your application for attendance in %s declined") % confTitle toList = [] toList.append(self._email) title = "" if self._title == "" or self._title is None: title = self._firstName else: title = self._title data["toList"] = toList data["body"] = _(""" Dear %s %s, your request to attend the %s has been declined by the event manager. Your Indico """) % (title, self._familyName, confTitle) GenericMailer.sendAndLog(GenericNotification(data), self.getConference(), "participants", responsibleUser) return True
def sendEncouragementToCreateAccount(self, participant): if participant is None: return False if participant.getEmail() is None or participant.getEmail() == "": return None data = {} title = participant.getTitle() if title is None or title == "": title = participant.getFirstName() createURL = urlHandlers.UHUserCreation.getURL() data["fromAddr"] = info.HelperMaKaCInfo.getMaKaCInfoInstance( ).getSupportEmail() toList = [] toList.append(participant.getEmail()) data["toList"] = toList data["subject"] = _("Invitation to create an Indico account") data["body"] = _(""" Dear %s %s, You have been added as a participant to '%s' and you have started to use the Indico system. Most probably you are going to use it in the future, participating in other events supported by Indico. Therefore we strongly recommend that you create your personal Indico Account - storing your personal data it will make your work with Indico easier and allow you access more sophisticated features of the system. To proceed in creating your Indico Account simply click on the following link : %s Please use this email address when creating your account: %s Your Indico """)%(participant.getFirstName(), participant.getFamilyName(), \ self._conference.getTitle(), \ createURL, participant.getEmail()) GenericMailer.sendAndLog(GenericNotification(data), self._conference, "participants") return True
def sendSpecialEmail(self, participantsIdList, eventManager, data): if participantsIdList is None: return False if eventManager is None: return False if len(participantsIdList) == 0: return True if data.get("subject", None) is None: return False if data.get("body", None) is None: return False data["fromAddr"] = eventManager.getEmail() toList = [] for userId in participantsIdList: participant = self._participantList.get(userId, None) if participant is not None: toList.append(participant.getEmail()) data["toList"] = toList GenericMailer.sendAndLog(GenericNotification(data), self._conference, log.ModuleNames.PARTICIPANTS) return True
def sendEncouragementToCreateAccount(self, participant): if participant is None : return False if participant.getEmail() is None or participant.getEmail() == "" : return None data = {} title = participant.getTitle() if title is None or title == "" : title = participant.getFirstName() createURL = urlHandlers.UHUserCreation.getURL() data["fromAddr"] = Config.getInstance().getNoReplyEmail() toList = [] toList.append(participant.getEmail()) data["toList"] = toList data["subject"] = _("Invitation to create an Indico account") data["body"] = _(""" Dear %s %s, You have been added as a participant to '%s' and you have started to use the Indico system. Most probably you are going to use it in the future, participating in other events supported by Indico. Therefore we strongly recommend that you create your personal Indico Account - storing your personal data it will make your work with Indico easier and allow you access more sophisticated features of the system. To proceed in creating your Indico Account simply click on the following link : %s Please use this email address when creating your account: %s Your Indico """)%(participant.getFirstName(), participant.getFamilyName(), \ self._conference.getTitle(), \ createURL, participant.getEmail()) GenericMailer.sendAndLog(GenericNotification(data),self._conference,"participants") return True
def addPendingParticipant(self, participant): if participant.getConference().getId() != self._conference.getId() : return False if participant.getId() is not None : return False if self.alreadyParticipating(participant) != 0 : return False if self.isAutoAccept(): self.addParticipant(participant) else: self._pendingParticipantList["%d"%self._newPendingId()] = participant self.getConference().log(EventLogRealm.participants, EventLogKind.positive, u'Participants', u'New participation request: {}'.format(to_unicode(participant.getName())), session.user, data=participant.getParticipantData()) participant.setStatusPending() profileURL = urlHandlers.UHConfModifParticipantsPending.getURL(self._conference) data = {} data["toList"] = self._conference.all_manager_emails data["fromAddr"] = Config.getInstance().getSupportEmail() data["subject"] = _("New pending participant for %s")%self._conference.getTitle() data["body"] = """ Dear Event Manager, a new person is asking for participation in %s. Personal profile of this pending participant is available at %s Please take this candidature into consideration and accept or reject it Your Indico """%(self._conference.getTitle(), profileURL) GenericMailer.send(GenericNotification(data)) self.notifyModification() return True
def process( self, params ): """ """ profile = Config.getInstance().getProfile() proffilename = "" res = "" MAX_RETRIES = 10 retry = MAX_RETRIES textLog = [] self._startTime = datetime.now() # clear the context ContextManager.destroy() ContextManager.set('currentRH', self) #redirect to https if necessary if self._checkHttpsRedirect(): return DBMgr.getInstance().startRequest() self._startRequestSpecific2RH() # I.e. implemented by Room Booking request handlers textLog.append("%s : Database request started"%(datetime.now() - self._startTime)) Logger.get('requestHandler').info('[pid=%s] Request %s started (%s)' % (os.getpid(),id(self._req), self._req.unparsed_uri)) # notify components that the request has started self._notify('requestStarted', self._req) forcedConflicts = Config.getInstance().getForceConflicts() try: while retry>0: if retry < MAX_RETRIES: # notify components that the request is being retried self._notify('requestRetry', self._req, MAX_RETRIES - retry) try: Logger.get('requestHandler').info('\t[pid=%s] from host %s' % (os.getpid(), self.getHostIP())) try: # clear the fossile cache at the start of each request fossilize.clearCache() # delete all queued emails GenericMailer.flushQueue(False) DBMgr.getInstance().sync() # keep a link to the web session in the access wrapper # this is used for checking access/modification key existence # in the user session self._aw.setIP( self.getHostIP() ) self._aw.setSession(self._getSession()) #raise(str(dir(self._websession))) self._setSessionUser() self._setLang(params) if self._getAuth(): if self._getUser(): Logger.get('requestHandler').info('Request %s identified with user %s (%s)' % (id(self._req), self._getUser().getFullName(), self._getUser().getId())) if not self._tohttps and Config.getInstance().getAuthenticatedEnforceSecure(): self._tohttps = True if self._checkHttpsRedirect(): return #if self._getUser() != None and self._getUser().getId() == "893": # profile = True self._reqParams = copy.copy( params ) self._checkParams( self._reqParams ) self._checkProtection() security.Sanitization.sanitizationCheck(self._target, self._reqParams, self._aw, self._doNotSanitizeFields) if self._doProcess: if profile: import profile, pstats proffilename = os.path.join(Config.getInstance().getTempDir(), "stone%s.prof" % str(random.random())) result = [None] profile.runctx("result[0] = self._process()", globals(), locals(), proffilename) res = result[0] else: res = self._process() # Save web session, just when needed sm = session.getSessionManager() sm.maintain_session(self._req, self._websession) # notify components that the request has finished self._notify('requestFinished', self._req) # Raise a conflict error if enabled. This allows detecting conflict-related issues easily. if retry > (MAX_RETRIES - forcedConflicts): raise ConflictError self._endRequestSpecific2RH( True ) # I.e. implemented by Room Booking request handlers DBMgr.getInstance().endRequest( True ) Logger.get('requestHandler').info('Request %s successful' % (id(self._req))) #request succesfull, now, doing tas that must be done only once try: GenericMailer.flushQueue(True) # send emails self._deleteTempFiles() except: Logger.get('mail').exception('Mail sending operation failed') pass break except MaKaCError, e: #DBMgr.getInstance().endRequest(False) res = self._processError(e) except (ConflictError, POSKeyError): import traceback # only log conflict if it wasn't forced if retry <= (MAX_RETRIES - forcedConflicts): Logger.get('requestHandler').warning('Conflict in Database! (Request %s)\n%s' % (id(self._req), traceback.format_exc())) self._abortSpecific2RH() DBMgr.getInstance().abort() retry -= 1 continue except ClientDisconnected: Logger.get('requestHandler').warning('Client Disconnected! (Request %s)' % id(self._req) ) self._abortSpecific2RH() DBMgr.getInstance().abort() retry -= 1 time.sleep(10-retry) continue except KeyAccessError, e: #Key Access error treatment res = self._processKeyAccessError( e ) self._endRequestSpecific2RH( False ) DBMgr.getInstance().endRequest(False)
def process(self, params): """ """ profile = Config.getInstance().getProfile() proffilename = "" res = "" MAX_RETRIES = 10 retry = MAX_RETRIES textLog = [] self._startTime = datetime.now() # clear the context ContextManager.destroy() ContextManager.set('currentRH', self) #redirect to https if necessary if self._checkHttpsRedirect(): return DBMgr.getInstance().startRequest() self._startRequestSpecific2RH( ) # I.e. implemented by Room Booking request handlers textLog.append("%s : Database request started" % (datetime.now() - self._startTime)) Logger.get('requestHandler').info( '[pid=%s] Request %s started (%s)' % (os.getpid(), id(self._req), self._req.unparsed_uri)) # notify components that the request has started self._notify('requestStarted', self._req) forcedConflicts = Config.getInstance().getForceConflicts() try: while retry > 0: if retry < MAX_RETRIES: # notify components that the request is being retried self._notify('requestRetry', self._req, MAX_RETRIES - retry) try: Logger.get('requestHandler').info( '\t[pid=%s] from host %s' % (os.getpid(), self.getHostIP())) try: # clear the fossile cache at the start of each request fossilize.clearCache() # delete all queued emails GenericMailer.flushQueue(False) DBMgr.getInstance().sync() # keep a link to the web session in the access wrapper # this is used for checking access/modification key existence # in the user session self._aw.setIP(self.getHostIP()) self._aw.setSession(self._getSession()) #raise(str(dir(self._websession))) self._setSessionUser() self._setLang(params) if self._getAuth(): if self._getUser(): Logger.get('requestHandler').info( 'Request %s identified with user %s (%s)' % (id(self._req), self._getUser().getFullName(), self._getUser().getId())) if not self._tohttps and Config.getInstance( ).getAuthenticatedEnforceSecure(): self._tohttps = True if self._checkHttpsRedirect(): return #if self._getUser() != None and self._getUser().getId() == "893": # profile = True self._reqParams = copy.copy(params) self._checkParams(self._reqParams) self._checkProtection() security.Sanitization.sanitizationCheck( self._target, self._reqParams, self._aw, self._doNotSanitizeFields) if self._doProcess: if profile: import profile, pstats proffilename = os.path.join( Config.getInstance().getTempDir(), "stone%s.prof" % str(random.random())) result = [None] profile.runctx("result[0] = self._process()", globals(), locals(), proffilename) res = result[0] else: res = self._process() # Save web session, just when needed sm = session.getSessionManager() sm.maintain_session(self._req, self._websession) # notify components that the request has finished self._notify('requestFinished', self._req) # Raise a conflict error if enabled. This allows detecting conflict-related issues easily. if retry > (MAX_RETRIES - forcedConflicts): raise ConflictError self._endRequestSpecific2RH( True ) # I.e. implemented by Room Booking request handlers DBMgr.getInstance().endRequest(True) Logger.get('requestHandler').info( 'Request %s successful' % (id(self._req))) #request succesfull, now, doing tas that must be done only once try: GenericMailer.flushQueue(True) # send emails self._deleteTempFiles() except: Logger.get('mail').exception( 'Mail sending operation failed') pass break except MaKaCError, e: #DBMgr.getInstance().endRequest(False) res = self._processError(e) except (ConflictError, POSKeyError): import traceback # only log conflict if it wasn't forced if retry <= (MAX_RETRIES - forcedConflicts): Logger.get('requestHandler').warning( 'Conflict in Database! (Request %s)\n%s' % (id(self._req), traceback.format_exc())) self._abortSpecific2RH() DBMgr.getInstance().abort() retry -= 1 continue except ClientDisconnected: Logger.get('requestHandler').warning( 'Client Disconnected! (Request %s)' % id(self._req)) self._abortSpecific2RH() DBMgr.getInstance().abort() retry -= 1 time.sleep(10 - retry) continue except KeyAccessError, e: #Key Access error treatment res = self._processKeyAccessError(e) self._endRequestSpecific2RH(False) DBMgr.getInstance().endRequest(False)
def sendNegotiationInfo(self): if self._dateNgotiation is None : return False if not self._dateNegotiation.isFinished() : return False data = {} data["fromAddr"] = Config.getInstance().getNoReplyEmail() if len(self._dateNegotiation.getSolutionList()) == 0: """ TODO: Prepate URLs..!! """ settingURL = ">>must be prepared yet..!!<<" data["subject"] = _("Negotiation algorithm finished - FAILED to find date") toList = [] for manager in self._conference.getManagerList() : if isinstance(manager, Avatar) : toList.append(manager.getEmail()) data["toList"] = toList data["body"] = _(""" Dear Event Manager, negotiation algorithm has finished its work on finding the date for %s, yet it didn't managed to find any solution satisfying all (or almost all) given restrictions. Setting the event's date is now up to you at %s Your Indico """)%(self._conference.getTitle(), settingURL) elif not self.dateNegotiation.isAutomatic : """ TODO: Prepate URLs..!! """ choseURL = ">>must be prepared yet..!!<<" data["subject"] = _("Negotiation algorithm finished - SUCCSEEDED") toList = [] for manager in self._conference.getManagerList() : if isinstance(manager, Avatar) : toList.append(manager.getEmail()) data["toList"] = toList data["body"] = _(""" Dear Event Manager, negotiation algorithm has finished its work on finding the date for %s, now you are kindly requested to choose the most siutable date from the list of solution which is avaliable at %s Your Indico """)%(self._conference.getTitle(), choseURL) else : data["subject"] = _("Date of the %s setteled")%self._conference.getTitle() toList = [] for p in self._participantList.valuess() : toList.append(p.getEmail()) data["toList"] = toList data["body"] = _(""" Dear Participant, negotiation algorithm has just set the date of the %s to : start date : %s end date : %s Wishing you a pleasent and interesting time - Your Indico """)%(self._conference.getTitle(), \ self._conference.getAdjustedStartDate(), self._conference.getAdjustedEndDate()) GenericMailer.send(GenericNotification(data)) return True
def notify(self,abstract,tpl): sm=GenericMailer.send(self.apply(abstract,tpl))
def sendNegotiationInfo(self): if self._dateNgotiation is None: return False if not self._dateNegotiation.isFinished(): return False data = {} data["fromAddr"] = info.HelperMaKaCInfo.getMaKaCInfoInstance( ).getSupportEmail() if len(self._dateNegotiation.getSolutionList()) == 0: """ TODO: Prepate URLs..!! """ settingURL = ">>must be prepared yet..!!<<" data["subject"] = _( "Negotiation algorithm finished - FAILED to find date") toList = [] for manager in self._conference.getManagerList(): if isinstance(manager, Avatar): toList.append(manager.getEmail()) data["toList"] = toList data["body"] = _(""" Dear Event Manager, negotiation algorithm has finished its work on finding the date for %s, yet it didn't managed to find any solution satisfying all (or almost all) given restrictions. Setting the event's date is now up to you at %s Your Indico """) % (self._conference.getTitle(), settingURL) elif not self.dateNegotiation.isAutomatic: """ TODO: Prepate URLs..!! """ choseURL = ">>must be prepared yet..!!<<" data["subject"] = _("Negotiation algorithm finished - SUCCSEEDED") toList = [] for manager in self._conference.getManagerList(): if isinstance(manager, Avatar): toList.append(manager.getEmail()) data["toList"] = toList data["body"] = _(""" Dear Event Manager, negotiation algorithm has finished its work on finding the date for %s, now you are kindly requested to choose the most siutable date from the list of solution which is avaliable at %s Your Indico """) % (self._conference.getTitle(), choseURL) else: data["subject"] = _( "Date of the %s setteled") % self._conference.getTitle() toList = [] for p in self._participantList.valuess(): toList.append(p.getEmail()) data["toList"] = toList data["body"] = _(""" Dear Participant, negotiation algorithm has just set the date of the %s to : start date : %s end date : %s Wishing you a pleasent and interesting time - Your Indico """)%(self._conference.getTitle(), \ self._conference.getAdjustedStartDate(), self._conference.getAdjustedEndDate()) GenericMailer.send(GenericNotification(data)) return True
def notify(self, registrant, params): if params.has_key("conf"): GenericMailer.sendAndLog(self.apply(registrant, params), params["conf"], 'Registration') else: GenericMailer.send(self.apply(registrant, params))
def inviteParticipant(self, participant, eventManager): if participant.getConference().getId() != self._conference.getId() : return False if not participant.setId(self._newParticipantId()): return False if eventManager is None : return False if self.alreadyParticipating(participant) != 0 : return False self._participantList["%d"%self._lastParticipantId()] = participant logData = participant.getParticipantData() logData["subject"] = _("New participant invited : %s")%participant.getWholeName() self._conference.getLogHandler().logAction(logData,"participants",eventManager) participant.setStatusInvited() data = {} title = "" firstName = "" familyName = "" eventURL = urlHandlers.UHConferenceDisplay.getURL( self._conference ) actionURL = urlHandlers.UHConfParticipantsInvitation.getURL( self._conference ) actionURL.addParam("participantId","%d"%self._lastParticipantId()) toList = [] if participant.getAvatar() is not None : toList.append(participant.getAvatar().getEmail()) data["toList"] = toList title = participant.getAvatar().getTitle() familyName = participant.getAvatar().getFamilyName() firstName = participant.getAvatar().getFirstName() else : toList.append(participant.getEmail()) data["toList"] = toList title = participant.getTitle() familyName = participant.getFamilyName() firstName = participant.getFamilyName() locationName = locationAddress = "" if self._conference.getLocation() is not None : locationName = self._conference.getLocation().getName() locationAddress = self._conference.getLocation().getAddress() if data["toList"] is None or len(data["toList"]) == 0 : return False if title is None or title == "" : title = firstName data["fromAddr"] = eventManager.getEmail() data["subject"] = _("Invitation to %s")%self._conference.getTitle() data["body"] = _(""" Dear %s %s, %s %s, event manager of '%s' would like to invite you to take part in this event, which will take place on %s in %s, %s. Further information on this event are available at %s You are kindly requested to accept or decline your participation in this event by clicking on the link below : %s Looking forward to meeting you at %s Your Indico on behalf of %s %s """)%(title, familyName, \ eventManager.getFirstName(), eventManager.getFamilyName(), \ self._conference.getTitle(), \ self._conference.getAdjustedStartDate(), \ locationName, locationAddress, \ eventURL, actionURL, \ self._conference.getTitle(), \ eventManager.getFirstName(), eventManager.getFamilyName()) GenericMailer.sendAndLog(GenericNotification(data),self._conference,"participants") #if participant.getAvatar() is None : # self.sendEncouragementToCreateAccount(participant) self.notifyModification() return True
def _sendEmails(self): if hasattr(self, "_emailsToBeSent"): for email in self._emailsToBeSent: GenericMailer.send(GenericNotification(email))
def inviteParticipant(self, participant, eventManager): if participant.getConference().getId() != self._conference.getId(): return False if not participant.setId(self._newParticipantId()): return False if eventManager is None: return False if self.alreadyParticipating(participant) != 0: return False self._participantList["%d" % self._lastParticipantId()] = participant logData = participant.getParticipantData() logData["subject"] = _( "New participant invited : %s") % participant.getWholeName() self._conference.getLogHandler().logAction(logData, "participants", eventManager) participant.setStatusInvited() data = {} title = "" firstName = "" familyName = "" eventURL = urlHandlers.UHConferenceDisplay.getURL(self._conference) actionURL = urlHandlers.UHConfParticipantsInvitation.getURL( self._conference) actionURL.addParam("participantId", "%d" % self._lastParticipantId()) toList = [] if participant.getAvatar() is not None: toList.append(participant.getAvatar().getEmail()) data["toList"] = toList title = participant.getAvatar().getTitle() familyName = participant.getAvatar().getFamilyName() firstName = participant.getAvatar().getFirstName() else: toList.append(participant.getEmail()) data["toList"] = toList title = participant.getTitle() familyName = participant.getFamilyName() firstName = participant.getFamilyName() locationName = locationAddress = "" if self._conference.getLocation() is not None: locationName = self._conference.getLocation().getName() locationAddress = self._conference.getLocation().getAddress() if data["toList"] is None or len(data["toList"]) == 0: return False if title is None or title == "": title = firstName data["fromAddr"] = eventManager.getEmail() data["subject"] = _("Invitation to %s") % self._conference.getTitle() data["body"] = _(""" Dear %s %s, %s %s, event manager of '%s' would like to invite you to take part in this event, which will take place on %s in %s, %s. Further information on this event are available at %s You are kindly requested to accept or decline your participation in this event by clicking on the link below : %s Looking forward to meeting you at %s Your Indico on behalf of %s %s """)%(title, familyName, \ eventManager.getFirstName(), eventManager.getFamilyName(), \ self._conference.getTitle(), \ self._conference.getAdjustedStartDate(), \ locationName, locationAddress, \ eventURL, actionURL, \ self._conference.getTitle(), \ eventManager.getFirstName(), eventManager.getFamilyName()) GenericMailer.sendAndLog(GenericNotification(data), self._conference, "participants") #if participant.getAvatar() is None : # self.sendEncouragementToCreateAccount(participant) self.notifyModification() return True
def notify(self, abstract, tpl): # if no from address is specified we should put the default one if tpl.getFromAddr().strip() == "": tpl.setFromAddr(tpl.getConference().getSupportInfo().getEmail(returnNoReply=True)) GenericMailer.send(self.apply(abstract, tpl))