def _process(self): params = self._getRequestParams() participantId = params["participantId"] status = self._conf.getParticipation().getParticipantById( participantId).getStatus() if status == 'accepted': raise NoReportError(_('You have already accepted the invitation.')) elif status == 'rejected': raise NoReportError(_('You have already rejected the invitation.')) if self._cancel: if not self._conf.getParticipation().setParticipantRejected( participantId): raise NoReportError( "It seems you have been withdrawn from the list of invited participants" ) url = urlHandlers.UHConferenceDisplay.getURL(self._conf) self._redirect(url) elif self._confirm: if not self._conf.getParticipation().setParticipantAccepted( participantId): raise NoReportError( "It seems you have been withdrawn from the list of invited participants" ) url = urlHandlers.UHConferenceDisplay.getURL(self._conf) self._redirect(url) else: return conferences.WPConfModifParticipantsInvite( self, self._conf).display(**params)
def _process(self): if self._cancel: self._redirect( urlHandlers.UHAbstractReviewingNotifTpl.getURL(self._conf)) return elif self._save: if len(self._toList) <= 0: raise NoReportError( _("""At least one "To Address" must be selected""")) elif self._tplCondition is None: #TODO: translate raise NoReportError(_("Choose a condition")) else: self._notifTpl = review.NotificationTemplate() self._setValues() self._conf.getAbstractMgr().addNotificationTpl(self._notifTpl) # Add the condition condWrapper = NotifTplConditionsFactory.getConditionById( self._tplCondition) if condWrapper: condWrapper.addCondition(self._notifTpl, **self._otherData) self._redirect( urlHandlers.UHAbstractModNotifTplDisplay.getURL( self._notifTpl)) return p = WPModCFANotifTplNew(self, self._target) return p.display()
def checkErrors(self): for conv in self.getConvenerList(): if conv.getFirstName().strip() == "": raise NoReportError( _("FIRST NAME has not been specified for convener #%s")%idx ) if conv.getFamilyName().strip() == "": raise NoReportError( _("SURNAME has not been specified for convener #%s")%idx ) if conv.getAffiliation().strip() == "": raise NoReportError( _("AFFILIATION has not been specified for convener #%s")%idx ) if conv.getEmail().strip() == "": raise NoReportError( _("EMAIL has not been specified for convener #%s")%idx )
def _process(self): if not self._cancel: if self._materialTypes != []: p = ConferencePacker(self._conf, self._aw) path = p.pack(self._materialTypes, self._days, self._mainResource, self._fromDate, ZIPFileHandler(), self._sessionList) if not p.getItems(): raise NoReportError(_("The selected package does not contain any items.")) return send_file('full-material.zip', path, 'ZIP', inline=False) else: raise NoReportError( _("You have to select at least one material type")) else: self._redirect( urlHandlers.UHConferenceDisplay.getURL(self._conf))
def _process(self): if not self._target.isScheduled(): raise NoReportError( _("You cannot export the contribution with id %s because it is not scheduled" ) % self._target.getId()) filename = "%s-Contribution.ics" % self._target.getTitle() hook = ContributionHook({}, 'contribution', { 'event': self._conf.getId(), 'idlist': self._contrib.getId(), 'dformat': 'ics' }) res = hook(self.getAW(), self._req) resultFossil = {'results': res[0]} serializer = Serializer.create('ics') data = serializer(resultFossil) self._req.headers_out["Content-Length"] = "%s" % len(data) cfg = Config.getInstance() mimetype = cfg.getFileTypeMimeType("ICAL") self._req.content_type = """%s""" % (mimetype) self._req.headers_out[ "Content-Disposition"] = """inline; filename="%s\"""" % cleanHTMLHeaderFilename( filename) return data
def _checkParams(self, params): l = locators.CategoryWebLocator(params) self._target = l.getObject() if self._target == None: raise NoReportError( _("The specified category with id \"%s\" does not exist or has been deleted" ) % params["categId"])
def _process(self): url = urlHandlers.UHSessionModification.getURL(self._target) params = self._getRequestParams() if self._action == "CANCEL": self._redirect(url) return elif self._action == "MODIFY": title = str(params.get("title", "")) if title.strip() == "": raise NoReportError("session title cannot be empty") else: newSchType = params.get( "tt_type", self._target.getScheduleType()) if self._target.getScheduleType() != newSchType and\ not self._confirmed: p = sessions.WPModEditDataConfirmation(self, self._target) del params["confId"] del params["sessionId"] del params["OK"] return p.display(**params) self._modify(params) self._redirect(url) return p = sessions.WPSessionDataModification(self, self._target) wf = self.getWebFactory() if wf is not None: p = wf.getSessionDataModification(self, self._target) params = self._getRequestParams() return p.display(**params)
def _process(self): if self._cancel: self._redirect( urlHandlers.UHAbstractModNotifTplDisplay.getURL(self._target)) return elif self._save: if len(self._toList) <= 0: raise NoReportError( _("""At least one "To Address" must be seleted """)) p = WPModCFANotifTplEdit(self, self._target) return p.display(title=self._title, subject=self._subject, body=self._body, fromAddr=self._fromAddr, toList=self._toList, ccList=self._ccList) else: self._setValues() self._redirect( urlHandlers.UHAbstractModNotifTplDisplay.getURL( self._target)) return else: p = WPModCFANotifTplEdit(self, self._target) return p.display()
def _checkProtection(self): if self._target.isClosed(): raise NoReportError( _("""The modification of the session "%s" is not allowed because it is closed""" ) % self._target.getTitle()) if self._target.canCoordinate(self.getAW(), "modifContribs"): return RHSessionModifBase._checkProtection(self)
def _checkParams( self, params ): RHAbstractSubmissionBase._checkParams( self, params ) cfaMgr = self._conf.getAbstractMgr() if not params.has_key("abstractId") and params.has_key("contribId"): params["abstractId"] = params["contribId"] self._abstract = self._target = cfaMgr.getAbstractById( params["abstractId"] ) if self._abstract == None: raise NoReportError(_("The abstract you are trying to access does not exist or has been deleted"))
def _process(self): if self._cancel: self._redirect( urlHandlers.UHAbstractReviewingNotifTpl.getURL(self._conf)) return elif self._save: if len(self._toList) <= 0: raise NoReportError( _("""At least one "To Address" must be selected""")) elif self._tplCondition is None: #TODO: translate raise NoReportError(_("Choose a condition")) else: tpl = review.NotificationTemplate() tpl.setName(self._title) tpl.setDescription(self._description) tpl.setTplSubject(self._subject, EmailNotificator.getVarList()) tpl.setTplBody(self._body, EmailNotificator.getVarList()) tpl.setFromAddr(self._fromAddr) tpl.setCCAddrList(self._ccList) tpl.setCAasCCAddr(self._CAasCCAddr) for toAddr in self._toList: toAddrWrapper = NotifTplToAddrsFactory.getToAddrById( toAddr) if toAddrWrapper: toAddrWrapper.addToAddr(tpl) self._conf.getAbstractMgr().addNotificationTpl(tpl) # Add the condition condWrapper = NotifTplConditionsFactory.getConditionById( self._tplCondition) if condWrapper: condWrapper.addCondition(tpl, **self._otherData) self._redirect( urlHandlers.UHAbstractModNotifTplDisplay.getURL(tpl)) return p = WPModCFANotifTplNew(self, self._target) return p.display(title = self._title,\ description = self._description,\ subject = self._subject,\ body = self._body,\ fromAddr = self._fromAddr,\ toList = self._toList,\ ccList = self._ccList)
def _process(self): params = self._getRequestParams() participantId = params["participantId"] status = self._conf.getParticipation().getParticipantById(participantId).getStatus() if status == 'accepted': raise NoReportError(_('You have already accepted the invitation.')) elif status == 'rejected': raise NoReportError(_('You have already rejected the invitation.')) if self._cancel: url = urlHandlers.UHConferenceDisplay.getURL(self._conf) self._redirect(url) elif self._confirm: participant = self._conf.getParticipation().getParticipantById(participantId) participant.setStatusRefused() url = urlHandlers.UHConferenceDisplay.getURL(self._conf) self._redirect(url) else: return conferences.WPConfModifParticipantsRefuse(self, self._conf).display(**params)
def _checkParams( self, params, mustExist = 1 ): if "categId" in params: params["categId"] = escape_html(str(params["categId"])) l = locators.CategoryWebLocator( params, mustExist ) self._target = l.getObject() # throw an error if the category was not found if mustExist and self._target == None: raise NoReportError(_("The specified category with id \"%s\" does not exist or has been deleted")%params["categId"])
def _checkParams(self, params): RHRegistrationFormRegistrantBase._checkParams(self, params) self._regForm = self._conf.getRegistrationForm() if self._conf.getModPay().hasPaymentConditions() and params.get( "conditions", "false") != "on": raise NoReportError( "You cannot pay without accepting the conditions") else: session['conditionsAccepted'] = True
def _checkProtection(self): conferenceDisplay.RHConferenceBaseDisplay._checkProtection(self) if not self._conf.hasEnabledSection( "regForm" ) or not displayMgr.ConfDisplayMgrRegistery().getDisplayMgr( self._conf).getMenu().getLinkByName("registrants").isEnabled(): raise NoReportError( "The registrants list page was disabled by the conference managers" )
def _process(self): if self._target.getType() =="simple_event": raise NoReportError(_("Lectures have no timetable therefore one cannot generate a timetable PDF.")) wf = self.getWebFactory() if wf != None: p=wf.getTimeTableCustomizePDF(self, self._target, self._view) else: p=conferences.WPTimeTableCustomizePDF(self, self._target) return p.display(**self._getRequestParams())
def _process( self ): if self._action == "CANCEL": self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) elif self._action == "VALIDATE": return self._doValidate() else: if isinstance( self._abstract.getCurrentStatus(), review.AbstractStatusAccepted ): raise NoReportError(_("The abstract with id '%s' cannot be edited because it has already been accepted.") % self._abstract.getId()) p = abstracts.WPModEditData(self, self._target, self._abstractData) pars = self._abstractData.toDict() return p.display(**pars)
def _process(self): if self._getAll: url = LogLinkGenerator(self._chatroom).generate() elif self._forEvent: url = LogLinkGenerator(self._chatroom).generate( str(self._conf.getStartDate().date()), str(self._conf.getEndDate().date())) else: url = LogLinkGenerator(self._chatroom).generate( self._sdate, self._edate) req = urllib2.Request(url, None, {'Accept-Charset': 'utf-8'}) document = urllib2.urlopen(req).read() if not document: raise NoReportError(_('No logs were found for these dates')) return document
def _process(self): if not self._target.isScheduled(): raise NoReportError( _("You cannot export the contribution with id {0} because it is not scheduled" ).format(self._target.getId())) filename = "{0}-Contribution.ics".format(self._target.getTitle()) hook = ContributionHook({}, 'contribution', { 'event': self._conf.getId(), 'idlist': self._contrib.getId(), 'dformat': 'ics' }) res = hook(self.getAW()) resultFossil = {'results': res[0]} serializer = Serializer.create('ics') return send_file(filename, StringIO(serializer(resultFossil)), 'ICAL')
def _process(self): if self._cancel: self._redirect( urlHandlers.UHAbstractModNotifTplDisplay.getURL(self._target)) return elif self._save: if len(self._toList) <= 0: raise NoReportError( _("""At least one "To Address" must be seleted """)) p = WPModCFANotifTplEdit(self, self._target) return p.display(title=self._title, subject=self._subject, body=self._body, fromAddr=self._fromAddr, toList=self._toList, ccList=self._ccList) else: self._notifTpl.setName(self._title) self._notifTpl.setDescription(self._description) self._notifTpl.setTplSubject(self._subject, EmailNotificator.getVarList()) self._notifTpl.setTplBody(self._body, EmailNotificator.getVarList()) self._notifTpl.setFromAddr(self._fromAddr) self._notifTpl.setCCAddrList(self._ccList) self._notifTpl.setCAasCCAddr(self._CAasCCAddr) self._notifTpl.clearToAddrs() for toAddr in self._toList: toAddrWrapper = NotifTplToAddrsFactory.getToAddrById( toAddr) if toAddrWrapper: toAddrWrapper.addToAddr(self._notifTpl) self._redirect( urlHandlers.UHAbstractModNotifTplDisplay.getURL( self._target)) return else: p = WPModCFANotifTplEdit(self, self._target) return p.display()
def _checkParams(self, params): try: RHLinkBase._checkParams(self, params) except: raise NoReportError("The file you try to access does not exist.")
def _checkParams(self): """ Extracts startDT, endDT and repeatability from the form, if present. Assigns these values to self, or Nones if values are not present. """ sDay = self._params.get("sDay") eDay = self._params.get("eDay") sMonth = self._params.get("sMonth") eMonth = self._params.get("eMonth") sYear = self._params.get("sYear") eYear = self._params.get("eYear") if sDay and len(sDay.strip()) > 0: sDay = int(sDay.strip()) if eDay and len(eDay.strip()) > 0: eDay = int(eDay.strip()) if sMonth and len(sMonth.strip()) > 0: sMonth = int(sMonth.strip()) # if sYear and sMonth and sDay: # # For format checking # try: # time.strptime(sDay.strip() + "/" + sMonth.strip() + "/" + sYear.strip() , "%d/%m/%Y") # except ValueError: # raise NoReportError(_("The Start Date must be of the form DD/MM/YYYY and must be a valid date.")) if eMonth and len(eMonth.strip()) > 0: eMonth = int(eMonth.strip()) if sYear and len(sYear.strip()) > 0: sYear = int(sYear.strip()) if eYear and len(eYear.strip()) > 0: eYear = int(eYear.strip()) # if eYear and eMonth and eDay: # # For format checking # try: # time.strptime(eDay.strip() + "/" + eMonth.strip() + "/" + eYear.strip() , "%d/%m/%Y") # except ValueError: # raise NoReportError(_("The End Date must be of the form DD/MM/YYYY and must be a valid date.")) sTime = self._params.get("sTime") if sTime and len(sTime.strip()) > 0: sTime = sTime.strip() eTime = self._params.get("eTime") if eTime and len(eTime.strip()) > 0: eTime = eTime.strip() # process sTime and eTime if sTime and eTime: try: time.strptime(sTime, "%H:%M") except ValueError: raise NoReportError( _("The Start Time must be of the form HH:MM and must be a valid time." )) t = sTime.split(':') sHour = int(t[0]) sMinute = int(t[1]) try: time.strptime(eTime, "%H:%M") except ValueError: raise NoReportError( _("The End Time must be of the form HH:MM and must be a valid time." )) t = eTime.split(':') eHour = int(t[0]) eMinute = int(t[1]) self._startDT = None self._endDT = None if sYear and sMonth and sDay and sTime and eYear and eMonth and eDay and eTime: # Full period specified self._startDT = datetime(sYear, sMonth, sDay, sHour, sMinute) self._endDT = datetime(eYear, eMonth, eDay, eHour, eMinute) elif sYear and sMonth and sDay and eYear and eMonth and eDay: # There are no times self._startDT = datetime(sYear, sMonth, sDay, 0, 0, 0) self._endDT = datetime(eYear, eMonth, eDay, 23, 59, 59) elif sTime and eTime: # There are no dates self._startDT = datetime(1990, 1, 1, sHour, sMinute) self._endDT = datetime(2030, 12, 31, eHour, eMinute) self._today = False if self._params.get("day", "") == "today": self._today = True self._startDT = datetime.today().replace(hour=0, minute=0, second=0) self._endDT = self._startDT.replace(hour=23, minute=59, second=59)
def _import(self, file): # check Registration period import datetime import pytz utc = pytz.UTC startDate = self._conf.getRegistrationForm().getStartRegistrationDate() endDate = self._conf.getRegistrationForm().getEndRegistrationDate() current = datetime.datetime.now() current = utc.localize(current) if (current < startDate or current > endDate): raise NoReportError( "Import registrants not authorized, outside registration period.") reader = csv.DictReader(file) i = 1 errors = [] successfuls = [] unsuccessfuls = [] for row in reader: try: # row['Email'] = row['Email'].lower() self._processImportData(row) matchedUsers = AvatarHolder().match({"email": row['Email']}, exact=1) if matchedUsers: user = matchedUsers[0] elif ('Account Creation' in row) and row['Account Creation'].lower( ) == 'yes': # account creation avData = self._mapAvatar(row) user = Avatar(avData) user.activateAccount() login_info = LoginInfo(row['Login'], row['Password']) auth_mgr = AuthenticatorMgr() user_id = auth_mgr.createIdentity(login_info, user, "Local") auth_mgr.add(user_id) AvatarHolder().add(user) else: user = None if not (user): reg = Registrant() # new registration self._conf.addRegistrant(reg, user) else: if user.isRegisteredInConf(self._conf): reg = self._conf.getRegistrantsByEmail(user.getEmail()) else: # not registered, new registration reg = Registrant() reg.setAvatar(user) self._conf.addRegistrant(reg, user) user.addRegistrant(reg) regData = self._mapRegistrant(row) regData['import'] = 'import' reg.setValues(regData, user) self._setAffiliation(reg) successfuls.append(reg.getFullName()) except Exception: errors.append(i) unsuccessfuls.append( row["Surname"] + ", " + row["First Name"] ) # exception : reg or user might not be defined yet finally: i += 1 self.logimport(successfuls, unsuccessfuls) return errors
def _process(self): p = ReviewingPacker(self._conf) path = p.pack(ZIPFileHandler()) if not os.path.getsize(path): raise NoReportError(_('There are no accepted papers.')) return send_file('accepted-papers.zip', path, 'ZIP', inline=False)