Пример #1
0
    def _registration_created(self, registration, management, **kwargs):
        if management:
            return

        regform = registration.registration_form
        personal_data_form = g.pop('personal_data_form', None)

        if not regform.cern_access_request or not regform.cern_access_request.is_active or not personal_data_form:
            return

        req = get_last_request(registration.event)
        if not req or not req.data['during_registration']:
            return

        required = req.data['during_registration_required']
        if not required and not personal_data_form.request_cern_access.data:
            return

        license_plate = (
            sanitize_license_plate(personal_data_form.license_plate.data)
            if personal_data_form.license_plate.data
            else None
        )

        registration.cern_access_request = CERNAccessRequest(birth_date=personal_data_form.birth_date.data,
                                                             nationality=personal_data_form.nationality.data,
                                                             birth_place=personal_data_form.birth_place.data,
                                                             license_plate=license_plate,
                                                             request_state=CERNAccessRequestState.not_requested,
                                                             reservation_code='')
Пример #2
0
    def _registration_created(self, registration, management, **kwargs):
        if management:
            return

        regform = registration.registration_form
        personal_data_form = g.pop('personal_data_form', None)

        if not regform.cern_access_request or not regform.cern_access_request.is_active or not personal_data_form:
            return

        req = get_last_request(registration.event)
        mode = req.data.get('regform_data_mode')
        if mode not in (RegformDataMode.during_registration,
                        RegformDataMode.during_registration_required):
            return

        required = req.data.get(
            'regform_data_mode'
        ) == RegformDataMode.during_registration_required
        if not required and not personal_data_form.request_cern_access.data:
            return

        registration.cern_access_request = CERNAccessRequest(
            birth_date=personal_data_form.birth_date.data,
            nationality=personal_data_form.nationality.data,
            birth_place=personal_data_form.birth_place.data,
            request_state=CERNAccessRequestState.not_requested,
            reservation_code='')
Пример #3
0
def create_access_request(registration, state, reservation_code):
    """Create CERN access request object for registration."""
    if registration.cern_access_request:
        registration.cern_access_request.request_state = state
        registration.cern_access_request.reservation_code = reservation_code
    else:
        registration.cern_access_request = CERNAccessRequest(
            request_state=state, reservation_code=reservation_code)