Пример #1
0
    def get(self):
        steps = CheckerWizard("").relevant_steps[:-1]
        if session.checker.category in NO_CALLBACK_CATEGORIES:
            session.store({"outcome": "referred/f2f/means"})
            return redirect(url_for(".find-legal-adviser", category=session.checker.category))

        current_step = {"count": len(steps) + 1, "is_current": True, "is_completed": False}

        return render_template("checker/result/eligible.html", current_step=current_step, steps=steps, form=self.form)
    def get(self, choices="", *args, **kwargs):
        api.create_diagnosis()

        response = api.move([c for c in choices.strip("/").split("/") if c])

        try:
            response_json = response.json()
        except ValueError:
            if current_app.config["DEBUG"]:
                return response.text
            raise

        state = response_json.get("state")
        nodes = response_json.get("nodes", [])

        if state and state != DIAGNOSIS_SCOPE.UNKNOWN:
            api.save(response_json)

            outcome_url = OUTCOME_URLS[state]
            outcome = outcome_url[2]

            if outcome:
                session.store({"outcome": outcome})

            if state == DIAGNOSIS_SCOPE.INELIGIBLE:
                outcome_url = url_for(
                    outcome_url[0],
                    category_name=session.checker.category_slug)
            else:
                outcome_url = url_for(outcome_url[0], **outcome_url[1])
                if state == DIAGNOSIS_SCOPE.OUTOFSCOPE:
                    outcome_url = "%s?category=%s" % (
                        outcome_url, self.get_category_for_larp(session))

            return redirect(outcome_url)

        def add_link(choice):
            choices_list = [choice["id"]]
            if choices:
                choices_list.insert(0, choices.strip("/"))
            choice["url"] = url_for(".diagnosis",
                                    choices="/".join(choices_list))
            return choice

        display_choices = map(add_link, response_json.get("choices", []))

        return render_template("scope/diagnosis.html",
                               choices=display_choices,
                               nodes=nodes)
    def get(self):
        steps = CheckerWizard("").relevant_steps[:-1]
        if session.checker.category in NO_CALLBACK_CATEGORIES:
            session.store({"outcome": "referred/f2f/means"})
            return redirect(
                url_for(".find-legal-adviser",
                        category=session.checker.category))

        current_step = {
            "count": len(steps) + 1,
            "is_current": True,
            "is_completed": False
        }

        return render_template("checker/result/eligible.html",
                               current_step=current_step,
                               steps=steps,
                               form=self.form)
Пример #4
0
def upload(nonce=None, session_id=None):
    if app.config['DEBUG']:
        print(request.files)

    if 'file' not in request.files:
        if app.config['DEBUG']:
            print("error", request.files)
        return "ERROR"
    file = request.files['file']
    if file:
        session = MamookSession(session_id, redis_client)
        savepath = os.path.join(app.config['UPLOAD_FOLDER'],
                                "upload-{}".format(session_id))
        file.save(savepath)
        session.collect("{}: '{}'".format(savepath, file.filename))
        session.store()
        return "OK"
    return "ERROR"
Пример #5
0
    def get(self, choices="", *args, **kwargs):
        api.create_diagnosis()

        response = api.move([c for c in choices.strip("/").split("/") if c])

        try:
            response_json = response.json()
        except ValueError:
            if current_app.config["DEBUG"]:
                return response.text
            raise

        state = response_json.get("state")
        nodes = response_json.get("nodes", [])

        if state and state != DIAGNOSIS_SCOPE.UNKNOWN:
            api.save(response_json)

            outcome_url = OUTCOME_URLS[state]
            outcome = outcome_url[2]

            if outcome:
                session.store({"outcome": outcome})

            if state == DIAGNOSIS_SCOPE.INELIGIBLE:
                outcome_url = url_for(outcome_url[0], category_name=session.checker.category_slug)
            else:
                outcome_url = url_for(outcome_url[0], **outcome_url[1])
                if state == DIAGNOSIS_SCOPE.OUTOFSCOPE:
                    outcome_url = "%s?category=%s" % (outcome_url, session.checker.category)

            return redirect(outcome_url)

        def add_link(choice):
            choices_list = [choice["id"]]
            if choices:
                choices_list.insert(0, choices.strip("/"))
            choice["url"] = url_for(".diagnosis", choices="/".join(choices_list))
            return choice

        display_choices = map(add_link, response_json.get("choices", []))

        return render_template("scope/diagnosis.html", choices=display_choices, nodes=nodes)
Пример #6
0
def event(nonce=None, session_id=None):
    evt = request.json
    session = MamookSession(session_id, redis_client)
    session.record_event(evt)
    if app.config['DEBUG']:
        print(evt, session.state)
    if evt['event'] == 'finishedvideo' and session.state == 'END':
        old = (session_id, nonce)
        session_id, nonce = create_session(redis_client)
        if app.config['DEBUG']:
            print("it's the end!", old, (session_id, nonce))
        resp = make_response("OK")
        resp.set_cookie('session', nonce)
        return resp
    else:
        session.trigger(evt['event'], evt.get('value', None))
        if app.config['DEBUG']:
            print(session.state)
        session.store()
    return "OK"
Пример #7
0
    def complete(self):
        # TODO: Is this still used now that scope diagnosis is taking care of F2F redirects for certain categories?
        if session.checker.needs_face_to_face:
            return redirect(url_for(".face-to-face", category=session.checker.category))

        if session.checker.ineligible:
            session.store(
                {
                    "ineligible_reasons": session.checker.ineligible_reasons,
                    "outcome": "referred/help-organisations/means",
                }
            )
            return redirect(url_for(".help_organisations", category_name=session.checker.category_slug))

        if session.checker.need_more_info:
            session.store({"outcome": "provisional"})
            return redirect(url_for(".provisional"))

        session.store({"outcome": "eligible"})
        return redirect(url_for(".eligible"))
    def complete(self):
        # TODO: Is this still used now that scope diagnosis is taking care of F2F redirects for certain categories?
        if session.checker.needs_face_to_face:
            return self.redirect(
                url_for(".face-to-face", category=session.checker.category))

        if session.checker.ineligible:
            session.store({
                "ineligible_reasons": session.checker.ineligible_reasons,
                "outcome": "referred/help-organisations/means",
            })
            return self.redirect(
                url_for(".help_organisations",
                        category_name=session.checker.category_slug))

        if session.checker.need_more_info:
            session.store({"outcome": "provisional"})
            return self.redirect(url_for(".provisional"))

        session.store({"outcome": "eligible"})
        return self.redirect(url_for(".eligible"))