Exemple #1
0
 def _registration_modified(self, registration, change, **kwargs):
     """If name of registration changed, updates the ADaMS CERN access request."""
     access_request = registration.cern_access_request
     if access_request and access_request.is_active and ('first_name' in change or 'last_name' in change):
         state = send_adams_post_request(registration.event, [registration], update=True)[0]
         if state == CERNAccessRequestState.active:
             registration.cern_access_request.request_state = state
Exemple #2
0
    def _event_title_changed(self, event, changes, **kwargs):
        """Update event name in the ADaMS CERN access request."""
        if 'title' not in changes:
            return

        requested_registrations = get_requested_registrations(event=event, only_active=True)
        if requested_registrations:
            state = send_adams_post_request(event, requested_registrations, update=True)[0]
            if state == CERNAccessRequestState.active:
                update_access_requests(requested_registrations, state)
    def _process(self):
        start_dt, end_dt = get_access_dates(self.cern_access_request)
        expired = now_utc() > end_dt
        form = AccessIdentityDataForm()
        access_request = self.registration.cern_access_request
        email_ticket = self.registration.registration_form.ticket_on_email
        if access_request is not None and not access_request.has_identity_info and form.validate_on_submit(
        ):
            if expired:
                raise Forbidden

            form.populate_obj(access_request, skip={'license_plate'})
            access_request.license_plate = (
                sanitize_license_plate(form.license_plate.data)
                if form.by_car.data and form.license_plate.data else None)

            db.session.flush()

            # if the user has entered car plate info, we have to provide it to ADAMS
            if form.by_car.data:
                send_adams_post_request(self.event, [self.registration],
                                        update=True)
            if email_ticket:
                send_ticket(self.registration)
            return redirect(
                url_for('.access_identity_data',
                        self.registration.locator.uuid))

        return WPAccessRequestDetails.render_template(
            'identity_data_form.html',
            self.event,
            form=form,
            access_request=access_request,
            start_dt=start_dt,
            end_dt=end_dt,
            expired=expired,
            email_ticket=email_ticket)