Example #1
0
 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))
Example #2
0
 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))
Example #3
0
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