def iter_people(cls, event): req = Request.find_latest_for_event(event, AVRequest.name) if not req or req.state != RequestState.accepted or 'recording' not in req.data[ 'services']: return if event.type == 'lecture': for link in event.person_links: yield SpeakerPersonInfo(link.full_name, link.email or None, data={ 'type': 'lecture_speaker', 'id': link.id, 'person_id': link.person_id }) else: contribs = [x[0] for x in get_selected_contributions(req)] for contrib in contribs: for link in contrib.person_links: if not link.is_speaker: continue yield SpeakerPersonInfo(link.full_name, link.email or None, data={ 'type': 'contribution', 'contribution': contribution_id(contrib), 'id': link.id, 'person_id': link.person_id })
def process_form(self): form = self.form if not form.validate_on_submit(): return if not self.request or not self.request.can_be_modified: req = Request(event=self.event, definition=self.definition, created_by_user=session.user) new = True else: req = self.request new = False try: self.definition.send(req, form.data) except RequestModuleError: self.commit = False flash_msg = _( 'There was a problem sending your request ({0}). Please contact support.' ) flash(flash_msg.format(self.definition.title), 'error') else: if new: flash_msg = _("Your request ({0}) has been sent.") else: flash_msg = _("Your request ({0}) has been modified.") flash(flash_msg.format(self.definition.title), 'success') if self.is_manager: return redirect( url_for('.event_requests_details', self.event, type=self.definition.name)) else: return redirect(url_for('.event_requests', self.event))
def process_form(self): form = self.form if not form.validate_on_submit(): return if not self.request or not self.request.can_be_modified: req = Request(event_new=self.event_new, definition=self.definition, created_by_user=session.user) new = True else: req = self.request new = False self.definition.send(req, form.data) if new: flash_msg = _( "Your request ({0}) has been sent. " "You will be notified by e-mail once it has been accepted or rejected." ) else: flash_msg = _("Your request ({0}) has been modified.") flash(flash_msg.format(self.definition.title), 'success') if self.is_manager: return redirect( url_for('.event_requests_details', self.event_new, type=self.definition.name)) else: return redirect(url_for('.event_requests', self.event_new))
def _event_deleted(event, **kwargs): event_id = int(event.id) query = Request.find( Request.event_id == event_id, Request.state.in_((RequestState.accepted, RequestState.pending))) for req in query: req.definition.withdraw(req, notify_event_managers=False)
def _event_deleted(event, **kwargs): if not event.id.isdigit(): return event_id = int(event.id) requests = Request.find(event_id=event_id) for req in requests.filter(Request.state.in_((RequestState.accepted, RequestState.pending))): req.definition.withdraw(req, notify_event_managers=False) requests.delete()
def _process_args(self): RHManageEventBase._process_args(self) try: self.definition = get_request_definitions()[request.view_args['type']] except KeyError: raise NotFound self.request = Request.find_latest_for_event(self.event, self.definition.name) if self._require_request and not self.request: raise NotFound
def _checkParams(self, params): RHConferenceModifBase._checkParams(self, params) try: self.definition = get_request_definitions()[request.view_args['type']] except KeyError: raise NotFound self.request = Request.find_latest_for_event(self.event_new, self.definition.name) if self._require_request and not self.request: raise NotFound
def _process_args(self): RHManageEventBase._process_args(self) try: self.definition = get_request_definitions()[request.view_args['type']] except KeyError: raise NotFound self.request = Request.find_latest_for_event(self.event, self.definition.name) if self._require_request and not self.request: raise NotFound
def _checkParams(self, params): RHConferenceModifBase._checkParams(self, params) try: self.definition = get_request_definitions()[request.view_args['type']] except KeyError: raise NotFound self.request = Request.find_latest_for_event(self.event_new, self.definition.name) if self._require_request and not self.request: raise NotFound
def _on_event_update(self, event, **kwargs): changes = kwargs['changes'] if not changes.viewkeys() & {'location_data', 'start_dt', 'end_dt'}: return request = Request.find_latest_for_event(event, RoomAssistanceRequest.name) if not request or request.state != RequestState.accepted: return if 'location_data' in changes and not event_has_room_with_support_attached( event): request.definition.reject( request, { 'comment': render_plugin_template('auto_reject_no_supported_room.txt') }, User.get_system_user()) request.data = dict(request.data, occurrences=[]) flash( _("The new event location is not in the list of the rooms supported by the room assistance team. " "Room assistance request has been rejected and support will not be provided." ), 'warning') if changes.viewkeys() & {'start_dt', 'end_dt'}: tz = pytz.timezone(config.DEFAULT_TIMEZONE) occurrences = { dateutil.parser.parse(occ).astimezone(tz) for occ in request.data['occurrences'] } req_dates = {occ.date() for occ in occurrences} event_dates = set(event.iter_days()) old_dates = req_dates - event_dates has_overlapping_dates = req_dates & event_dates if not has_overlapping_dates: request.definition.reject( request, { 'comment': render_plugin_template( 'auto_reject_no_overlapping_dates.txt') }, User.get_system_user()) request.data = dict(request.data, occurrences=[]) flash( _("The new event dates don't overlap with the existing room assistance request for this event. " "Room assistance request has been rejected and support will not be provided." ), 'warning') elif old_dates and has_overlapping_dates: new_data = dict(request.data) new_data['occurrences'] = [ occ.astimezone(pytz.utc).isoformat() for occ in occurrences if occ.date() in req_dates & event_dates ] request.data = new_data flash( _("Room assistance had been requested for days that are not between the updated start/end " "dates. Support will not be provided on these days anymore." ), 'warning')
def _get_event_webcast_url(self, event): req = Request.find_latest_for_event(event, AVRequest.name) if not req or req.state != RequestState.accepted or 'webcast' not in req.data['services']: return None url = req.data.get('custom_webcast_url') or self.settings.get('webcast_url') try: return url.format(event_id=event.id) except Exception: self.logger.exception('Could not build webcast URL') return None
def _process(self): definitions = get_request_definitions() if not definitions: raise NotFound requests = Request.find_latest_for_event(self.event) if self.protection_overridden: definitions = {name: def_ for name, def_ in definitions.iteritems() if def_.can_be_managed(session.user)} requests = {name: req for name, req in requests.iteritems() if req.definition and req.definition.can_be_managed(session.user)} return WPRequestsEventManagement.render_template('events/requests/event_requests.html', self.event, definitions=definitions, requests=requests)
def _process(self): definitions = get_request_definitions() if not definitions: raise NotFound requests = Request.find_latest_for_event(self.event) if self.protection_overridden: definitions = {name: def_ for name, def_ in definitions.iteritems() if def_.can_be_managed(session.user)} requests = {name: req for name, req in requests.iteritems() if req.definition and req.definition.can_be_managed(session.user)} return WPRequestsEventManagement.render_template('events/requests/event_requests.html', self.event, definitions=definitions, requests=requests)
def _get_vc_assistance_request_link(self, event, **kwargs): from definition import VCAssistanceRequest req = Request.find_latest_for_event(event, VCAssistanceRequest.name) support_email = VCAssistanceRequestPlugin.settings.get('support_email') return render_plugin_template( 'vc_assistance_request_link.html', event=event, name=VCAssistanceRequest.name, request_accepted=req is not None and req.state == RequestState.accepted, has_capable_vc_room_attached=has_vc_rooms_attached_to_capable( event), support_email=support_email)
def _event_updated(self, event, changes, **kwargs): req = Request.find_latest_for_event(event, VCAssistanceRequest.name) if not req or req.state != RequestState.accepted: return if 'start_dt' in changes and not start_time_within_working_hours( event): flash( _("The new event start time is out of working hours so videoconference assistance cannot be " "provided."), 'warning') if 'location_data' in changes and not has_vc_rooms_attached_to_capable( event): flash( _("The new event location doesn't have videoconference capabilities so videoconference " "assistance cannot be provided."), 'warning')
def mock_access_request(dummy_event, dummy_regform, dummy_user, app, request): data = { 'email': dummy_user.email, 'first_name': dummy_user.first_name, 'last_name': dummy_user.last_name, 'affiliation': dummy_user.affiliation, 'phone': dummy_user.phone, 'position': 'Business Relationship Manager', 'user': dummy_user } data.update(request.param.get('personal_data', {})) with app.test_request_context(method='POST', data=data): session.user = dummy_user session.lang = 'en_GB' CERNAccessPlugin.settings.acls.add_principal('authorized_users', dummy_user) g.rh = RHRegistrationForm() g.rh.regform = dummy_regform req = Request(event=dummy_event, definition=CERNAccessRequestDefinition(), created_by_user=dummy_user, data={ 'comment': 'no comments', 'regforms': [dummy_regform.id], 'during_registration': request.param['during_registration'], 'during_registration_required': request.param['during_registration_required'], 'start_dt_override': None, 'end_dt_override': None }) CERNAccessRequestDefinition.send(req, { 'start_dt_override': None, 'end_dt_override': None }) yield
def _merge_users(target, source, **kwargs): Request.find(created_by_id=source.id).update({Request.created_by_id: target.id}) Request.find(processed_by_id=source.id).update({Request.processed_by_id: target.id})
def _merge_users(user, merged, **kwargs): new_id = int(user.id) old_id = int(merged.id) Request.find(created_by_id=old_id).update({'created_by_id': new_id}) Request.find(processed_by_id=old_id).update({'processed_by_id': new_id})
def _event_deleted(event, **kwargs): event_id = int(event.id) query = Request.find(Request.event_id == event_id, Request.state.in_((RequestState.accepted, RequestState.pending))) for req in query: req.definition.withdraw(req, notify_event_managers=False)
def _register_event_change(self, event): req = Request.find_latest_for_event(event, AVRequest.name) if not req: return g.setdefault('av_request_changes', set()).add(req)
def _merge_users(target, source, **kwargs): Request.find(created_by_id=source.id).update( {Request.created_by_id: target.id}) Request.find(processed_by_id=source.id).update( {Request.processed_by_id: target.id})
def get_last_request(event): """Return the last CERN Acess request for the event.""" from indico_cern_access.definition import CERNAccessRequestDefinition return Request.find_latest_for_event(event, CERNAccessRequestDefinition.name)
def _merge_users(target, source, **kwargs): from indico.modules.events.requests.models.requests import Request Request.find(created_by_id=source.id).update( {Request.created_by_id: target.id}) Request.find(processed_by_id=source.id).update( {Request.processed_by_id: target.id})
def _merge_users(target, source, **kwargs): from indico.modules.events.requests.models.requests import Request Request.find(created_by_id=source.id).update({Request.created_by_id: target.id}) Request.find(processed_by_id=source.id).update({Request.processed_by_id: target.id})