Exemple #1
0
def register_step_3_area_question(areaid, questionid):
    '''
    Ask the user the given question number in the given area.
    '''

    questionnaire = get_area_questionnaire_or_404(areaid)
    max_questionid = len(questionnaire['questions'])
    try:
        questionid = int(questionid)
        if questionid < 1 or questionid > max_questionid:
            raise ValueError
        question = questionnaire['questions'][questionid - 1]
        next_questionid = None
        prev_questionid = None
        if questionid > 1:
            prev_questionid = questionid - 1
        if questionid < max_questionid:
            next_questionid = questionid + 1
    except ValueError:
        abort(404)

    if request.method == 'POST':
        current_user.set_skill(question['id'], request.form.get('answer'))
        db.session.add(current_user)
        db.session.commit()
        if len(current_user.skills) >= MIN_QUESTIONS_TO_JOIN:
            current_user.set_fully_registered()
            db.session.commit()
        if next_questionid:
            return redirect(
                url_for('views.register_step_3_area_question',
                        areaid=areaid,
                        questionid=next_questionid))
        else:
            return redirect(url_for('views.activity'))

    return render_register_step_3(
        question=question,
        areaid=areaid,
        questionid=questionid,
        next_questionid=next_questionid,
        prev_questionid=prev_questionid,
        max_questionid=max_questionid,
    )
Exemple #2
0
def register_step_3_area_question(areaid, questionid):
    '''
    Ask the user the given question number in the given area.
    '''

    questionnaire = get_area_questionnaire_or_404(areaid)
    max_questionid = len(questionnaire['questions'])
    try:
        questionid = int(questionid)
        if questionid < 1 or questionid > max_questionid:
            raise ValueError
        question = questionnaire['questions'][questionid - 1]
        next_questionid = None
        prev_questionid = None
        if questionid > 1:
            prev_questionid = questionid - 1
        if questionid < max_questionid:
            next_questionid = questionid + 1
    except ValueError:
        abort(404)

    if request.method == 'POST':
        current_user.set_skill(question['id'], request.form.get('answer'))
        db.session.add(current_user)
        db.session.commit()
        if len(current_user.skills) >= MIN_QUESTIONS_TO_JOIN:
            current_user.set_fully_registered()
            db.session.commit()
        if next_questionid:
            return redirect(url_for(
                'views.register_step_3_area_question',
                areaid=areaid, questionid=next_questionid
            ))
        else:
            return redirect(url_for('views.activity'))

    return render_register_step_3(
        question=question,
        areaid=areaid,
        questionid=questionid,
        next_questionid=next_questionid,
        prev_questionid=prev_questionid,
        max_questionid=max_questionid,
    )
Exemple #3
0
def my_expertise_area_question(areaid, questionid):
    '''
    Ask the user the given question number in the given area.
    '''

    questionnaire = get_area_questionnaire_or_404(areaid)
    max_questionid = len(questionnaire['questions'])
    try:
        questionid = int(questionid)
        if questionid < 1 or questionid > max_questionid:
            raise ValueError
        question = questionnaire['questions'][questionid - 1]
        next_questionid = None
        prev_questionid = None
        if questionid > 1:
            prev_questionid = questionid - 1
        if questionid < max_questionid:
            next_questionid = questionid + 1
    except ValueError:
        abort(404)

    if request.method == 'POST':
        current_user.set_skill(question['id'], request.form.get('answer'))
        db.session.add(current_user)
        db.session.commit()
        if next_questionid:
            return redirect(
                url_for('views.my_expertise_area_question',
                        areaid=areaid,
                        questionid=next_questionid))
        else:
            return redirect(url_for('views.my_expertise'))

    return render_user_profile(
        active_tab='expertise',
        in_questionnaire=True,
        question=question,
        areaid=areaid,
        questionid=questionid,
        next_questionid=next_questionid,
        prev_questionid=prev_questionid,
        max_questionid=max_questionid,
    )
Exemple #4
0
def my_expertise_area_question(areaid, questionid):
    '''
    Ask the user the given question number in the given area.
    '''

    questionnaire = get_area_questionnaire_or_404(areaid)
    max_questionid = len(questionnaire['questions'])
    try:
        questionid = int(questionid)
        if questionid < 1 or questionid > max_questionid:
            raise ValueError
        question = questionnaire['questions'][questionid - 1]
        next_questionid = None
        prev_questionid = None
        if questionid > 1:
            prev_questionid = questionid - 1
        if questionid < max_questionid:
            next_questionid = questionid + 1
    except ValueError:
        abort(404)

    if request.method == 'POST':
        current_user.set_skill(question['id'], request.form.get('answer'))
        db.session.add(current_user)
        db.session.commit()
        if next_questionid:
            return redirect(url_for(
                'views.my_expertise_area_question',
                areaid=areaid, questionid=next_questionid
            ))
        else:
            return redirect(url_for('views.my_expertise'))

    return render_user_profile(
        active_tab='expertise',
        in_questionnaire=True,
        question=question,
        areaid=areaid,
        questionid=questionid,
        next_questionid=next_questionid,
        prev_questionid=prev_questionid,
        max_questionid=max_questionid,
    )
Exemple #5
0
def my_expertise_area_question(areaid, questionid):
    """
    Ask the user the given question number in the given area.
    """

    questionnaire = get_area_questionnaire_or_404(areaid)
    max_questionid = len(questionnaire["questions"])
    try:
        questionid = int(questionid)
        if questionid < 1 or questionid > max_questionid:
            raise ValueError
        question = questionnaire["questions"][questionid - 1]
        next_questionid = None
        prev_questionid = None
        if questionid > 1:
            prev_questionid = questionid - 1
        if questionid < max_questionid:
            next_questionid = questionid + 1
    except ValueError:
        abort(404)

    if request.method == "POST":
        current_user.set_skill(question["id"], request.form.get("answer"))
        db.session.add(current_user)
        db.session.commit()
        if next_questionid:
            return redirect(url_for("views.my_expertise_area_question", areaid=areaid, questionid=next_questionid))
        else:
            return redirect(url_for("views.my_expertise"))

    return render_user_profile(
        active_tab="expertise",
        question=question,
        areaid=areaid,
        questionid=questionid,
        next_questionid=next_questionid,
        prev_questionid=prev_questionid,
        max_questionid=max_questionid,
    )
Exemple #6
0
def my_expertise():
    '''
    Allow user to edit their expertise
    '''
    #if 'social-login' not in session:
    #    flash('You need to be authenticated in order to fill your expertise.', 'error')
    #    return redirect(url_for('login'))
    #social_login = session['social-login']
    #userid = social_login['userid']
    if request.method == 'GET':
        return render_template('my-expertise.html')
    elif request.method == 'POST':
        for k, val in request.form.iteritems():
            current_user.set_skill(k, val)
        db.session.add(current_user)
        db.session.commit()
        flash(lazy_gettext("""Your expertise has been updated.<br/>
        What you can do next:
        <ul>
        <li><a href="/search">Search for innovators</a></li>
        <li>Fill another expertise questionnaire below</li>
        <li>View your <a href="/user/{}">public profile</a></li>
        """).format(current_user.id))
        return render_template('my-expertise.html')