<commit_before>from flask import Blueprint
from flask import render_template
from flask import request
from flask import jsonify
from db.models import FreshmanEvalData
from db.models import EvalSettings

intro_evals_form_bp = Blueprint('intro_evals_form_bp', __name__)

@intro_evals_form_bp.route('/intro_evals_form/')
def display_intro_evals_form():
    # get user data
    user_name = request.headers.get('x-webauth-user')

    evalData = FreshmanEvalData.query.filter(
                FreshmanEvalData.uid == user_name).first()

    is_open = EvalSettings.query.first().intro_form_active
    # return names in 'first last (username)' format
    return render_template('intro_evals_form.html',
                           username = user_name,
                           social_events = evalData.social_events,
                           other_notes = evalData.other_notes,
                           is_open = is_open)

@intro_evals_form_bp.route('/intro_evals/submit', methods=['POST'])
def submit_intro_evals():
    from db.database import db_session
    user_name = request.headers.get('x-webauth-user')

    post_data = request.get_json()
    social_events = post_data['social_events']
    comments = post_data['comments']

    FreshmanEvalData.query.filter(
        FreshmanEvalData.uid == user_name).\
        update(
            {
                'social_events': social_events,
                'other_notes': comments
            })

    from db.database import db_session
    db_session.flush()
    db_session.commit()
    return jsonify({"success": True}), 200
<commit_msg>Only intromembers access intro eval form<commit_after>from flask import Blueprint
from flask import render_template
from flask import request
from flask import redirect
from flask import jsonify
from db.models import FreshmanEvalData
from db.models import EvalSettings
from util.ldap import ldap_is_intromember

intro_evals_form_bp = Blueprint('intro_evals_form_bp', __name__)

@intro_evals_form_bp.route('/intro_evals_form/')
def display_intro_evals_form():
    # get user data
    user_name = request.headers.get('x-webauth-user')

    if not ldap_is_intromember(user_name):
        return redirect("/dashboard")

    evalData = FreshmanEvalData.query.filter(
                FreshmanEvalData.uid == user_name).first()

    is_open = EvalSettings.query.first().intro_form_active
    # return names in 'first last (username)' format
    return render_template('intro_evals_form.html',
                           username = user_name,
                           social_events = evalData.social_events,
                           other_notes = evalData.other_notes,
                           is_open = is_open)

@intro_evals_form_bp.route('/intro_evals/submit', methods=['POST'])
def submit_intro_evals():
    from db.database import db_session
    user_name = request.headers.get('x-webauth-user')

    post_data = request.get_json()
    social_events = post_data['social_events']
    comments = post_data['comments']

    FreshmanEvalData.query.filter(
        FreshmanEvalData.uid == user_name).\
        update(
            {
                'social_events': social_events,
                'other_notes': comments
            })

    from db.database import db_session
    db_session.flush()
    db_session.commit()
    return jsonify({"success": True}), 200

{'fraction_non_alphanumeric': 0.08930704898446834, 'fraction_numerical': 0.0017921146953405018, 'mean_word_length': 2.8851508120649654, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6804051', 'n_tokens_mistral': 1005, 'n_tokens_neox': 951, 'n_words': 202}