<commit_before>from flask import Flask, render_template, flash, request, Markup, \
    session, redirect, url_for, escape, Response, abort, send_file, jsonify
from flask.ext.login import login_required, current_user
                            
from maediprojects import app, db, models
from maediprojects.query import activity as qactivity
from maediprojects.query import location as qlocation
from maediprojects.lib import codelists

import json

@app.route("/")
def dashboard():
    return render_template("home.html",
                loggedinuser=current_user,
                stats = qactivity.get_stats(current_user),
                activities = qactivity.list_activities_user(current_user)
                          )

@app.route("/activities/new/", methods=['GET', 'POST'])
@login_required
def activity_new():
    if request.method == "GET":
        return render_template("activity_edit.html",
                    # Specify some defaults
                    activity = {
                        "flow_type": "10",
                        "aid_type": "C01",
                        "collaboration_type": "1",
                        "finance_type": "110",
                        "tied_status": "5",
                        "recipient_country_code": current_user.recipient_country_code,
                    },
                    loggedinuser=current_user,
                    codelists = codelists.get_codelists()
                              )

    elif request.method == "POST":
        # Create new activity
        data = request.form.to_dict()<commit_msg>Show IATI data list<commit_after>from flask import Flask, render_template, flash, request, Markup, \
    session, redirect, url_for, escape, Response, abort, send_file, jsonify
from flask.ext.login import login_required, current_user
                            
from maediprojects import app, db, models
from maediprojects.query import activity as qactivity
from maediprojects.query import location as qlocation
from maediprojects.lib import codelists

import json

@app.route("/")
def dashboard():
    return render_template("home.html",
                loggedinuser=current_user,
                stats = qactivity.get_stats(current_user),
                activities = qactivity.list_activities_user(current_user)
                          )

@app.route("/iati_data_list/")
def iati_data_list():
    return render_template("iati_data_list.html",
                loggedinuser=current_user,
                country_files = qactivity.get_iati_list()
                          )

@app.route("/activities/new/", methods=['GET', 'POST'])
@login_required
def activity_new():
    if request.method == "GET":
        return render_template("activity_edit.html",
                    # Specify some defaults
                    activity = {
                        "flow_type": "10",
                        "aid_type": "C01",
                        "collaboration_type": "1",
                        "finance_type": "110",
                        "tied_status": "5",
                        "recipient_country_code": current_user.recipient_country_code,
                    },
                    loggedinuser=current_user,
                    codelists = codelists.get_codelists()
                              )

    elif request.method == "POST":
        # Create new activity
        data = request.form.to_dict()
{'fraction_non_alphanumeric': 0.09139307897071872, 'fraction_numerical': 0.005323868677905945, 'mean_word_length': 1.8661016949152542, 'pattern_counts': {'":': 16, '<': 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': '5543483', 'n_tokens_mistral': 930, 'n_tokens_neox': 878, 'n_words': 196}