Exemplo n.º 1
0
def node_view():
    class _Form(Form):
        destination = TextField('destination', validators=[DataRequired()])
        contact = TextField('contact', validators=[DataRequired()])

    form = _Form()

    if form.validate_on_submit():
        work_flow = yawf.new_work_flow(
            'travel application', lambda work_flow: models.Node(
                name='Submit Travel Application',
                policy_name="Travel",
                work_flow=work_flow,
                handler_group=models.Group.query.filter(models.Group.name ==
                                                        'Customers').one()),
            lambda work_flow: do_commit(
                models.Application(username=current_user.username,
                                   destination=form.destination.data,
                                   contact=form.contact.data,
                                   work_flow=work_flow)).id)
        try:
            work_flow.start()
        except yawf.exceptions.WorkFlowDelayed:
            flash('You have just submitted an travel application')
            return redirect(url_for('node_list_view'))
    return render_template('/request.html', form=form)
Exemplo n.º 2
0
def after_survey_monkey():
    response = models.SurveyMonkey.Response(
        request.args.get("hub"), guid=request.args.get("response_guid"))
    application = models.Application(response)
    application.submit_to_transparent_classroom()
    application.email_schools()
    application.email_parent()
    return render_template('after_survey_monkey.html', application=application)
Exemplo n.º 3
0
def new_application():
    """Begin a new application."""

    if current_user.is_authenticated():
        existing = models.Application.objects(
            submitter=current_user.id).first()
        if existing:
            return redirect(
                url_for('application', application_id=existing.id, step=1))
        else:
            new_app = models.Application(submitter=current_user.id)
            new_app.save()
            utils.send_application_creation_email(new_app)
            return redirect(
                url_for('application', application_id=new_app.id, step=1))

    form = forms.ApplicationFormStep_New()
    if form.validate_on_submit():
        if user_datastore.get_user(form.email.data):
            flash(
                'A user with that email address already exists. Perhaps you meant to log in instead?',
                'error')
            return redirect(url_for('new_application'))
        else:
            registerable.register_user(name=form.name.data,
                                       email=form.email.data,
                                       password=form.password.data,
                                       roles=['student'])

            user = user_datastore.get_user(form.email.data)
            application = models.Application(submitter=user.id)
            application.save()
            utils.send_application_creation_email(application)

            auth.login(user)
            flash((
                'A new account has been created with the email address <b>' +
                user.email +
                '</b>. You don\'t need to complete your application '
                'in one sitting; return later and log back in to continue right where you left off.'
            ), 'success')
            return redirect(
                url_for('application', application_id=application.id, step=2))

    return render_template('application_new.html', form=form)
Exemplo n.º 4
0
def apply_job(db: Session, id: int):
    try:
        db_job = models.Application(job_id=id)
        db.add(db_job)
        db.commit()
        db.refresh(db_job)
        return db_job

    except Exception as e:
        print(e)
        raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Unexpected Error Occurred")
Exemplo n.º 5
0
def add_app():
    f_name = request.json['f_name']
    l_name = request.json['l_name']
    phone = request.json['phone']
    email = request.json['email']
    id_ad = request.json['id_ad']

    new_app = models.Application(f_name, l_name, email, id_ad, phone)

    db.session.add(new_app)
    db.session.commit()

    return schemas.application_Schema.jsonify(new_app)
Exemplo n.º 6
0
 def test_application(self):
     response = models.SurveyMonkey.Response("sandbox", guid=self.guid)
     application = models.Application(response)
     self.assertIsInstance(application.children, list)
     self.assertIsInstance(application.parents, list)
     self.assertIsInstance(application.answers, list)
     self.assertIsInstance(application.children[0].answers, list)
     application.submit_to_transparent_classroom()
     with app.app_context():
         with models.mail.record_messages() as outbox:
             application.email_schools()
             i = len(outbox)
             self.assertGreater(i, 0)
             i = 0
             application.email_parent()
             self.assertGreater(len(outbox), i)
Exemplo n.º 7
0
 def test_application_breaks_transparent_classroom_validations(self):
     response = models.SurveyMonkey.Response("sandbox", guid=self.guid)
     application = models.Application(response)
     application.parents[0].phone.value = "XYZ"
     application.submit_to_transparent_classroom()