def _handleSet(self): mapper = ShortURLMapper() if self._value: try: UtilsConference.validateShortURL(self._value, self._target) except ValueError, e: raise NoReportError(e.message)
def _checkParams(self): AdminService._checkParams(self) pm = ParameterManager(self._params) user_id = pm.extract("userId", pType=int, allowEmpty=False) self._user = User.get(user_id) if self._user is None: raise NoReportError(_("The user that you are trying to login as does not exist anymore in the database"))
def _getAnswer(self): if len(self._target.getReviewing().getResourceList()) == 0: raise NoReportError( _("You need to attach a paper before submitting a revision.")) self._target.getReviewManager().getLastReview().setAuthorSubmitted( True) return True
def _checkParams(self): AdminService._checkParams(self) pm = ParameterManager(self._params) self._userId = pm.extract("userId", pType=str, allowEmpty=False) self._av = AvatarHolder().getById(self._userId) if self._av == None: raise NoReportError(_("The user that you are trying to login as does not exist anymore in the database"))
def _checkProtection(self): CollaborationBookingModifBase._checkProtection(self) if not RCVideoServicesUser.hasRights(self.getAW().getUser(), self._bookingType): raise NoReportError( _("You dot have access to modify a %s booking") % self._bookingType)
def _getAnswer(self): for user in self._userList: if user["_type"] == "Avatar": # new speaker ah = AvatarHolder() av = ah.getById(user["id"]) if av is None: raise NoReportError( _("The user with email %s that you are adding does not exist anymore in the database" ) % user["email"]) part = self._newParticipant(av) elif user[ "_type"] == "ContributionParticipation": # adding existing author to speaker part = self._contribution.getAuthorById(user["id"]) self._contribution.addSpeaker(part) if self._submissionRights and part: self._contribution.grantSubmission(part) if self._kindOfList == "prAuthor": return self._getParticipantsList( self._contribution.getPrimaryAuthorList()) elif self._kindOfList == "coAuthor": return self._getParticipantsList( self._contribution.getCoAuthorList()) elif self._kindOfList == "speaker": return self._getParticipantsList( self._contribution.getSpeakerList()) else: raise ServiceError("ERR-UK0", _("Invalid kind of list of users."))
def _getAnswer(self): av = AvatarHolder().getById(self._submitterId) if av is None: raise NoReportError( _("It seems this user has been removed from the database or has been merged into another. Please remove it and add it again." )) self._newParticipant(av) return self._getSubmittersList()
def _getAnswer(self): ah = PrincipalHolder() for user in self._userList: av = ah.getById(user["id"]) if av is None: raise NoReportError(_("The user with email %s that you are adding does not exist anymore in the database") % user["email"]) self._contribution.grantSubmission(av) return self._getSubmittersList()
def _getAnswer(self): ph = PrincipalHolder() for user in self._userList: principal = ph.getById(user["id"]) if principal is None: raise NoReportError(_("The user that you are trying to add does not exist anymore in the database")) self._group.addMember(principal) return fossilize(self._group.getMemberList())
def _getAnswer(self): ph = PrincipalHolder() for user in self._userList: principal = ph.getById(user["id"]) if principal is None and user["_type"] == "Avatar": raise NoReportError(_("The user with email %s that you are adding does not exist anymore in the database") % user["email"]) self._contribution.grantModification(ph.getById(user["id"])) return self._getManagersList()
def _checkParams(self): ConferenceModifBase._checkParams(self) pm = ParameterManager(self._params) submitterId = pm.extract("submitterId", pType=str, allowEmpty=False) abstractId = pm.extract("abstractId", pType=str, allowEmpty=False) self._abstract = self._conf.getAbstractMgr().getAbstractById(abstractId) self._submitter = user.AvatarHolder().getById(submitterId) if self._submitter is None: raise NoReportError(_("The user that you are changing does not exist anymore in the database"))
def _getAnswer(self): try: entry = session.pop('login_as_orig_user') except KeyError: raise NoReportError(_('No login-as history entry found')) session.user = User.get(entry['user_id']) session.update(entry['session_data']) return True
def _getAnswer(self): av = user.AvatarHolder().match({"email": self._secondaryEmai}, forceWithoutExtAuth=True) if av and av[0] != self._user: raise NoReportError( _("The email address %s is already used by another user.") % self._secondaryEmai) self._user.addSecondaryEmail(self._secondaryEmail) return True
def _getAnswer(self): try: entry = session.pop('login_as_orig_user') except KeyError: raise NoReportError(_('No login-as history entry found')) session.user = AvatarHolder().getById(entry['user_id']) session.timezone = entry['timezone'] return True
def _checkParams(self): ConferenceModifBase._checkParams(self) pm = ParameterManager(self._params.get('value'), timezone=self._conf.getTimezone()) try: self._startDate = pm.extract('startDate', pType=datetime.datetime) self._endDate = pm.extract('endDate', pType=datetime.datetime) except ValueError, e: raise NoReportError("Warning", e.message)
def _getAnswer(self): minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() adminList = minfo.getAdminList() ph = PrincipalHolder() for user in self._userList: principal = ph.getById(user["id"]) if principal is None: raise NoReportError(_("The user that you are trying to add does not exist anymore in the database")) adminList.grant(principal) return fossilize(minfo.getAdminList())
def invokeMethod(self, method, params, req): MAX_RETRIES = 10 # clear the context ContextManager.destroy() DBMgr.getInstance().startRequest() # room booking database _startRequestSpecific2RH() # notify components that the request has started self._notify('requestStarted', req) forcedConflicts = Config.getInstance().getForceConflicts() retry = MAX_RETRIES try: while retry > 0: if retry < MAX_RETRIES: # notify components that the request is being retried self._notify('requestRetry', req, MAX_RETRIES - retry) try: # delete all queued emails GenericMailer.flushQueue(False) DBMgr.getInstance().sync() try: result = processRequest(method, copy.deepcopy(params), req) except MaKaC.errors.NoReportError, e: raise NoReportError(e.getMsg()) # notify components that the request has ended self._notify('requestFinished', req) # Raise a conflict error if enabled. This allows detecting conflict-related issues easily. if retry > (MAX_RETRIES - forcedConflicts): raise ConflictError _endRequestSpecific2RH(True) DBMgr.getInstance().endRequest(True) GenericMailer.flushQueue(True) # send emails break except ConflictError: _abortSpecific2RH() DBMgr.getInstance().abort() retry -= 1 continue except ClientDisconnected: _abortSpecific2RH() DBMgr.getInstance().abort() retry -= 1 time.sleep(MAX_RETRIES - retry) continue
def _getAnswer(self): if not self._registrant_ids: raise NoReportError(_("No registrants were selected to check-in")) dates_changed = {} for registrant_id in self._registrant_ids: registrant = self._conf.getRegistrantById(registrant_id) if not registrant.isCheckedIn(): registrant.setCheckedIn(True) checkInDate = registrant.getAdjustedCheckInDate() dates_changed[registrant_id] = format_datetime(checkInDate) return {"dates": dates_changed}
def index(self, element): self._indexCheck() # self.get is equivalent to root['IndexByCRName'] if self.get().has_key(element.getTitle()): for cr in self.get()[element.getTitle()]: #if there is a chat room repeated in the server (either ours or an external one) we have a problem if cr.getTitle() == element.getTitle() and cr.getHost() == element.getHost(): raise NoReportError( _('There is already a chat room in that server with that name, please choose another one')) else: self.get()[element.getTitle()] = OOTreeSet() self.get()[element.getTitle()].insert(element)
def _getAnswer(self): av = AvatarHolder().getById(self._submitterId) if av is None: raise NoReportError(_("It seems this user has been removed from the database or has been merged into another. Please remove it and add it again.")) participant = self._getParticipantByEmail(av.getEmail()) if self._kindOfList == "prAuthor": self._contribution.removePrimaryAuthor(participant, removeSpeaker=0) elif self._kindOfList == "coAuthor": self._contribution.removeCoAuthor(participant, removeSpeaker=0) elif self._kindOfList == "speaker": self._contribution.removeSpeaker(participant) return self._getSubmittersList()
def _getAnswer(self): ph = PrincipalHolder() for user in self._userList: person = ph.getById(user["id"]) if person is None: raise NoReportError( _("The user with email %s that you are adding does not exist anymore in the database" ) % user["email"]) if self._kindOfList == "manager": self._session.grantModification(person) elif self._kindOfList == "coordinator": self._session.addCoordinator(person) return self._getSessionChairList()
def _checkParams(self): CollaborationBase._checkParams(self) if self._params.has_key('bookingId'): self._bookingId = self._params['bookingId'] self._booking = self._CSBookingManager.getBooking(self._bookingId) if self._booking == None: raise NoReportError( _("The booking that you are trying to modify does not exist. Maybe it was already deleted, please refresh the page." )) self._bookingType = self._booking.getType() self._bookingPlugin = self._booking.getPlugin() self._pm = ParameterManager(self._params) else: raise CollaborationException( _("Booking id not set when trying to modify a booking on meeting " ) + str(self._conf.getId()) + _(" with the service ") + str(self.__class__))
def retrieveUsers(params, fieldName="userList"): pm = ParameterManager(params) userList = pm.extract(fieldName, pType=list, allowEmpty = True) avatars = [] newUsers = [] editedAvatars = [] ph = user.PrincipalHolder() for userDict in userList: id = userDict['id'] if id.startswith('newUser'): newUsers.append(userDict) elif id.startswith('edited'): editedAvatars.append((ph.getById(id[6:]), userDict)) else: principal = ph.getById(id) if principal is None: raise NoReportError(_("The user with email %s that you are adding does not exist anymore in the database") % userDict["email"]) avatars.append(ph.getById(id)) return avatars, newUsers, editedAvatars
def _getAnswer(self): consumers = dict((consumer.getName(), consumer) for consumer in ConsumerHolder().getList()) if "indico-checkin" not in consumers: raise NoReportError( _("There is no indico-checkin consumer key for OAuth")) # QRCode (Version 6 with error correction L can contain up to 106 bytes) qr = QRCode(version=6, error_correction=constants.ERROR_CORRECT_M, box_size=4, border=1) oauth_checkin = consumers["indico-checkin"] config = Config.getInstance() baseURL = config.getBaseSecureURL() if config.getBaseSecureURL( ) else config.getBaseURL() qr_data = { "event_id": self._conf.getId(), "title": self._conf.getTitle(), "date": format_date(self._conf.getAdjustedStartDate()), "server": { "baseUrl": baseURL, "consumerKey": oauth_checkin.getId(), "consumerSecret": oauth_checkin.getSecret(), } } json_qr_data = json.dumps(qr_data) qr.add_data(json_qr_data) qr.make(fit=True) qr_img = qr.make_image() output = StringIO() qr_img._img.save(output, format="png") im_data = output.getvalue() return 'data:image/png;base64,{0}'.format(base64.b64encode(im_data))
def _checkParams(self): """ Checks the materialId, and retrieves the material using it """ self._material = None self._conf = None l = locators.WebLocator() try: l.setResource(self._params, 0) self._target = l.getObject() if isinstance(self._target, conference.Resource): self._resource = self._target self._material = self._target.getOwner() if isinstance(self._target, conference.Material): self._material = self._target if isinstance(self._target, conference.Category): self._categ = self._target else: self._conf = self._target.getConference() if self._conf == None: self._categ = self._target.getCategory() except Exception, e: if self._target is None: raise NoReportError( _("The resource with does not exist anymore. Please refresh the page." )) else: raise ServiceError("ERR-M0", str(e))
def _checkParams(self): try: l = locators.WebLocator() self._material = None self._conf = None l.setMaterial(self._params, 0) self._target = l.getObject() #if isinstance(self._target, conference.Material): self._material = self._target self._conf = self._target.getConference() if self._conf == None: self._categ = self._target else: self._categ = self._conf.getOwner() ## TODO: remove this, since material/resource creation ## doesn't come through this method ## if isinstance(self._target, conference.Category): ## self._categ = self._target ## else: ## self._conf = self._target.getConference() ## if self._conf == None: ## self._categ=self._target.getCategory() except Exception, e: if self._target is None: raise NoReportError( _("The material with does not exist anymore. Please refresh the page." )) else: raise ServiceError("ERR-M0", str(e))
def process(self): try: return ConferenceTextModificationBase.process(self) except HTMLSecurityError as e: raise NoReportError(e.message)
def process(self): try: return ContributionReviewingHTMLModificationBase.process(self) except HTMLSecurityError as e: raise NoReportError(e.message)
def process(self): try: return super(ContributionReviewingCommentsModification, self).process() except HTMLSecurityError as e: raise NoReportError(e.message)
def _getAnswer(self): if self._user: idxs = indexes.IndexesHolder() funcGet = "get%s%s" % (self._dataType[0].upper(), self._dataType[1:]) funcSet = "set%s%s" % (self._dataType[0].upper(), self._dataType[1:]) if self._dataType == "title": if self._value in TitlesRegistry().getList(): self._user.setTitle(self._value) else: raise NoReportError(_("Invalid title value")) elif self._dataType == "surName": self._user.setFieldSynced('surName', False) surName = idxs.getById("surName") surName.unindexUser(self._avatar) self._user.setSurName(self._value) surName.indexUser(self._avatar) elif self._dataType == "name": self._user.setFieldSynced('firstName', False) name = idxs.getById("name") name.unindexUser(self._avatar) self._user.setName(self._value) name.indexUser(self._avatar) elif self._dataType == "organisation": self._user.setFieldSynced('affiliation', False) org = idxs.getById("organisation") org.unindexUser(self._avatar) self._user.setOrganisation(self._value) org.indexUser(self._avatar) elif self._dataType == "email": # Check if there is any user with this email address if self._value != self._avatar.getEmail(): other = user.AvatarHolder().match({"email": self._value}, forceWithoutExtAuth=True) if other and other[0] != self._avatar: raise NoReportError( _("The email address %s is already used by another user." ) % self._value) email = idxs.getById("email") email.unindexUser(self._avatar) self._user.setEmail(self._value) email.indexUser(self._avatar) elif self._dataType == "secondaryEmails": emailList = self._buildEmailList() secondaryEmails = [] # check if every secondary email is valid for email in emailList: if email != "": av = user.AvatarHolder().match( {"email": email}, forceWithoutExtAuth=True) if av and av[0] != self._avatar: raise NoReportError( _("The email address %s is already used by another user." ) % email) else: secondaryEmails.append(email) self._user.setSecondaryEmails(secondaryEmails) return ", ".join(self._user.getSecondaryEmails()) elif self._dataType == "telephone": self._user.setFieldSynced('phone', False) self._user.setTelephone(self._value) elif self._dataType == "fax": self._user.setFieldSynced('fax', False) self._user.setFax(self._value) else: getattr(self._user, funcSet)(self._value) return getattr(self._user, funcGet)() else: raise ServiceError("ERR-U5", _("User id not specified"))